00001 /* 00002 ** ip.c for in /home/anoman/work/lse/atomix/lseos-net/inet 00003 ** 00004 ** Copyright (c)2004 Arthur Kopatsy 00005 ** Login <kopats_a@epita.fr> 00006 ** 00007 ** Started on Thu Aug 26 10:46:18 2004 Arthur Kopatsy 00008 ** Last update Wed Dec 1 16:49:44 2004 Arthur Kopatsy 00009 */ 00010 00011 #ifndef ARP_H_ 00012 #define ARP_H_ 00013 00014 #define ARP_HEADER_LEN 28 00015 00016 #define ARP_HARD_TYPE_ETHERNET 0x0001 00017 #define ARP_PROT_TYPE_IP 0x0800 00018 00019 #define ARP_OP_REQUEST 1 00020 #define ARP_OP_ANSWER 2 00021 00022 struct s_arp_hdr 00023 { 00024 u_int16_t arp_h; /* Hardware type */ 00025 u_int16_t arp_p; /* Protocol */ 00026 #if 1 /* Little Indian */ 00027 u_int8_t arp_hs; /* Harware size */ 00028 u_int8_t arp_ps; /* Protocol size */ 00029 #else 00030 u_int8_t arp_ps; /* Protocol size */ 00031 u_int8_t arp_hs; /* Harware size */ 00032 #endif 00033 u_int16_t arp_op; 00034 00035 struct mac_addr arp_sha; /* Sender harware addr */ 00036 struct in_addr arp_spa; /* Sender protocole addr */ 00037 struct mac_addr arp_tha; /* Target harware addr */ 00038 struct in_addr arp_tpa; /* Target protocol addr */ 00039 } __attribute__ ((__packed__)); 00040 00041 #ifdef __INET__ 00042 struct s_arp_entry 00043 { 00044 LIST_ENTRY(s_arp_entry) next; 00045 struct in_addr in_addr; 00046 struct mac_addr mac_addr; 00047 00048 int resolved; 00049 00050 int64_t timer_id; 00051 00052 struct s_pkq waiting_pk; 00053 }; 00054 00055 LIST_HEAD(s_arp_cache, s_arp_entry); 00056 00057 struct s_arp_proto_info 00058 { 00059 struct s_arp_cache arp_cache; 00060 int arp_cache_lock; 00061 }; 00062 00063 int arp_proto_init(void); 00064 00065 /* Arp timer actions */ 00066 #define ARP_LIFE_TIME (20*60*1000000) /* 2 minutes of validity */ 00067 #define ARP_RQST_TIMEOUT (5*1000000) /* After 5s wating packet are freed */ 00068 00069 #endif 00070 00071 /* PROTO arp.c */ 00072 #ifdef __INET__ 00073 /* arp.c */ 00074 int arp_proto_init(void); 00075 void arp_request_timeout(struct s_arp_entry *entry); 00076 void arp_invalid_entry(struct s_arp_entry *entry); 00077 void arp_entry_remove(struct s_arp_entry *entry); 00078 void arp_dump(struct s_pkbuf *pk); 00079 int arp_request_haddr(struct s_pkbuf *pk, struct mac_addr *mac_addr); 00080 int aa_arp_input(struct s_pkbuf *pk); 00081 #endif /* __INET__ */ 00082 #endif