RN/Blatt02/A203/arp_packet.h

44 lines
947 B
C
Raw Permalink Normal View History

2024-11-23 18:09:49 +01:00
#ifndef ARP_PACKET_H
#define ARP_PACKET_H
#include <assert.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include "arp_packet_st.h"
#include "util.h"
#define IP_A_S 4
#define OP_A_S 2
#define SUCCESS 0
#define FAILED -1
#define UNEQUAL 1
#define ARES_OP_REQ 0x0001
#define ARES_OP_REP 0x0002
#define ARES_HRD_ETHERNET 0x0001
#define ETHER_T_ARP 0x0806
#define ARES_PRO_IP 0x0800
#define TB_L 100
int parse_arp_packet(mac_hdr * hdr, pkt_data * pkt, uint8_t * buf, size_t size);
int receive_arp_packet(mac_hdr * hdr, pkt_data * pkt, uint8_t * buf, size_t size, uint8_t * local_ip, uint8_t * local_mac);
int send_arp_response(int tun_fd, uint8_t * resp_buffer, size_t length, const pkt_data * pkt, const mac_hdr * hdr);
#endif