Annotation of embedaddon/dhcdrop/src/net.h, revision 1.1
1.1 ! misho 1: /*
! 2: * net.h
! 3: *
! 4: * Created on: 05.08.2009
! 5: * Author: Chebotarev Roman
! 6: */
! 7:
! 8: #ifndef NET_H_
! 9: #define NET_H_
! 10:
! 11: #pragma pack(1)
! 12:
! 13: #define ETH_ALEN 6 /* Octets in one ethernet addr */
! 14:
! 15: #define ETHERTYPE_IP 0x0800 /* IP */
! 16: #define ETHERTYPE_ARP 0x0806 /* Address resolution */
! 17:
! 18: /* 10Mb/s ethernet header */
! 19: struct eth_header
! 20: {
! 21: u_int8_t ether_dhost[ETH_ALEN]; /* destination eth addr */
! 22: u_int8_t ether_shost[ETH_ALEN]; /* source ether addr */
! 23: u_int16_t ether_type; /* packet type ID field */
! 24: } __attribute__ ((__packed__));
! 25:
! 26: /*
! 27: * Structure of an internet header, naked of options.
! 28: */
! 29: struct iphdr
! 30: {
! 31: #if __BYTE_ORDER == __LITTLE_ENDIAN
! 32: unsigned int ihl:4;
! 33: unsigned int version:4;
! 34: #elif __BYTE_ORDER == __BIG_ENDIAN
! 35: unsigned int version:4;
! 36: unsigned int ihl:4;
! 37: #else
! 38: # error "Please fix <bits/endian.h>"
! 39: #endif
! 40: uint8_t tos;
! 41: uint16_t tot_len;
! 42: uint16_t id;
! 43: uint16_t frag_off;
! 44: uint8_t ttl;
! 45: uint8_t protocol;
! 46: uint16_t check;
! 47: uint32_t saddr;
! 48: uint32_t daddr;
! 49: /*The options start here. */
! 50: };
! 51:
! 52: /* ARP header */
! 53: struct arp_header
! 54: {
! 55: uint16_t arp_hwtype; /* Format of hardware address */
! 56: uint16_t arp_proto; /* Format of protocol address */
! 57: uint8_t arp_hwlen; /* Length of hardware address */
! 58: uint8_t arp_palen; /* Length of protocol address */
! 59: uint16_t arp_oper; /* ARP opcode (command) */
! 60: };
! 61:
! 62: /* UDP header as specified by RFC 768, August 1980. */
! 63:
! 64: struct pseudo_header
! 65: {
! 66: unsigned int src_addr;
! 67: unsigned int dst_addr;
! 68: unsigned char zero ;
! 69: unsigned char proto;
! 70: unsigned short length;
! 71: };
! 72:
! 73: struct udphdr
! 74: {
! 75: uint16_t source;
! 76: uint16_t dest;
! 77: uint16_t len;
! 78: uint16_t check;
! 79: };
! 80:
! 81: struct arp_packet_net_header
! 82: {
! 83: struct eth_header eth_head;
! 84: struct arp_header arp_head;
! 85: };
! 86:
! 87: struct arp_data
! 88: {
! 89: uint8_t from_ether[ETH_ALEN];
! 90: uint32_t from_ip;
! 91: uint8_t to_ether[ETH_ALEN];
! 92: uint32_t to_ip;
! 93: };
! 94:
! 95: struct dhcp_packet_net_header
! 96: {
! 97: struct eth_header eth_head;
! 98: struct iphdr ip_header;
! 99: struct udphdr udp_header;
! 100: };
! 101:
! 102: #endif /* NET_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>