2021-07-03 05:07:57 +01:00
< ! DOCTYPE HTML >
< html >
< head >
< meta http - equiv = " Content-Type " content = " text/html;charset=US-ASCII " >
< meta name = " generator " content = " ZealOS V0.05 " >
< style type = " text/css " >
body { background - color : # 000000 ; }
. cF0 { color : # ffffff ; background - color : # 000000 ; }
. cF1 { color : # 3465 a4 ; background - color : # 000000 ; }
. cF2 { color : # 4e9 a06 ; background - color : # 000000 ; }
. cF3 { color : # 06 989 a ; background - color : # 000000 ; }
. cF4 { color : # a24444 ; background - color : # 000000 ; }
. cF5 { color : # 75507 b ; background - color : # 000000 ; }
. cF6 { color : # ce982f ; background - color : # 000000 ; }
. cF7 { color : # bcc0b9 ; background - color : # 000000 ; }
. cF8 { color : # 555753 ; background - color : # 000000 ; }
. cF9 { color : # 729f cf ; background - color : # 000000 ; }
. cFA { color : # 82 bc49 ; background - color : # 000000 ; }
. cFB { color : # 34e2 e2 ; background - color : # 000000 ; }
. cFC { color : # ac3535 ; background - color : # 000000 ; }
. cFD { color : # ad7fa8 ; background - color : # 000000 ; }
. cFE { color : # fce94f ; background - color : # 000000 ; }
. cFF { color : # 000000 ; background - color : # 000000 ; }
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = " font-family:monospace;font-size:12pt " >
2021-07-04 23:11:34 +01:00
< a name = " l1 " > < / a > < span class = cF0 > # < / span > < span class = cF1 > define < / span > < span class = cF0 > ARP_HASHTABLE_SIZE < / span > < span class = cFE > 1024 < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l2 " > < / a >
< a name = " l3 " > < / a > # < / span > < span class = cF1 > define < / span > < span class = cF0 > HTT_ARP < / span > < span class = cFE > 0x00100 < / span > < span class = cF0 > < / span > < span class = cF2 > //identical to HTT_DICT_WORD</span><span class=cF0>
< a name = " l4 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l5 " > < / a > # < / span > < span class = cF1 > define < / span > < span class = cF0 > ARP_REQUEST < / span > < span class = cFE > 0x01 < / span > < span class = cF0 >
< a name = " l6 " > < / a > # < / span > < span class = cF1 > define < / span > < span class = cF0 > ARP_REPLY < / span > < span class = cFE > 0x02 < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l7 " > < / a >
< a name = " l8 " > < / a > < / span > < span class = cF1 > class < / span > < span class = cF0 > CARPHeader
< a name = " l9 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l10 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > hardware_type ;
< a name = " l11 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > protocol_type ;
2021-07-03 05:07:57 +01:00
< a name = " l12 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l13 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > hardware_addr_len ;
< a name = " l14 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > protocol_addr_len ;
2021-07-03 05:07:57 +01:00
< a name = " l15 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l16 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > operation ;
2021-07-03 05:07:57 +01:00
< a name = " l17 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l18 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > sender_hardware_addr [ MAC_ADDRESS_LENGTH ] ;
< a name = " l19 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > sender_protocol_addr ;
2021-07-03 05:07:57 +01:00
< a name = " l20 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l21 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > target_hardware_addr [ MAC_ADDRESS_LENGTH ] ;
< a name = " l22 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > target_protocol_addr ;
2021-07-03 05:07:57 +01:00
< a name = " l23 " > < / a >
< a name = " l24 " > < / a > } ;
< a name = " l25 " > < / a >
< a name = " l26 " > < / a > < / span > < span class = cF1 > class < / span > < span class = cF0 > CARPHash : < / span > < span class = cF9 > CHash < / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = " l27 " > < / a > { < / span > < span class = cF2 > //store U32 ip_address as CHash->str U8*, MStrPrint("%X")</span><span class=cF0>
< a name = " l28 " > < / a > < / span > < span class = cF2 > //</span><span class=cF0> </span><span class=cF2>U32 ip_address;</span><span class=cF0>
< a name = " l29 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > mac_address [ MAC_ADDRESS_LENGTH ] ;
2021-07-03 05:07:57 +01:00
< a name = " l30 " > < / a > } ;
< a name = " l31 " > < / a >
< a name = " l32 " > < / a > < / span > < span class = cF1 > class < / span > < span class = cF0 > CARPGlobals
< a name = " l33 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l34 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > local_ipv4 ; < / span > < span class = cF2 > // stored in Big Endian</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l35 " > < / a >
< a name = " l36 " > < / a > } arp_globals ;
< a name = " l37 " > < / a >
< a name = " l38 " > < / a > < / span > < span class = cF9 > CHashTable < / span > < span class = cF0 > * arp_cache = < / span > < span class = cF3 > NULL < / span > < span class = cF0 > ;
< a name = " l39 " > < / a >
< a name = " l40 " > < / a > < / span > < span class = cF1 > U0 < / span > < span class = cF0 > ARPCacheInit ( )
< a name = " l41 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l42 " > < / a > arp_cache = < / span > < span class = cF5 > HashTableNew < / span > < span class = cF0 > ( ARP_HASHTABLE_SIZE ) ;
< a name = " l43 " > < / a > arp_globals . local_ipv4 = < / span > < span class = cFE > 0 < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l44 " > < / a > }
< a name = " l45 " > < / a >
< a name = " l46 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > ARPSend ( < / span > < span class = cF9 > U16 < / span > < span class = cF0 > operation ,
2021-07-04 23:11:34 +01:00
< a name = " l47 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * dest_mac_address ,
< a name = " l48 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * send_mac_address ,
< a name = " l49 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > send_ip ,
< a name = " l50 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * target_mac_address ,
< a name = " l51 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > target_ip )
2021-07-03 05:07:57 +01:00
< a name = " l52 " > < / a > { < / span > < span class = cF2 > //method currently assumes send_ and target_ip EndianU16 already...</span><span class=cF0>
< a name = " l53 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l54 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * arp_frame ;
< a name = " l55 " > < / a > CARPHeader * header ;
2021-07-03 05:07:57 +01:00
< a name = " l56 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l57 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > de_index = EthernetFrameAllocate ( & amp ; arp_frame ,
< a name = " l58 " > < / a > send_mac_address ,
< a name = " l59 " > < / a > dest_mac_address ,
< a name = " l60 " > < / a > ETHERTYPE_ARP ,
< a name = " l61 " > < / a > < / span > < span class = cF1 > sizeof < / span > < span class = cF7 > ( < / span > < span class = cF0 > CARPHeader < / span > < span class = cF7 > ) < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l62 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l63 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( de_index & lt ; < / span > < span class = cFE > 0 < / span > < span class = cF0 > )
< a name = " l64 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > de_index ; < / span > < span class = cF2 > // error state</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l65 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l66 " > < / a > header = arp_frame ;
2021-07-03 05:07:57 +01:00
< a name = " l67 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l68 " > < / a > header - & gt ; hardware_type = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( HTYPE_ETHERNET ) ;
< a name = " l69 " > < / a > header - & gt ; protocol_type = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( ETHERTYPE_IPV4 ) ;
< a name = " l70 " > < / a > header - & gt ; hardware_addr_len = MAC_ADDRESS_LENGTH ;
< a name = " l71 " > < / a > header - & gt ; protocol_addr_len = IP_ADDRESS_LENGTH ;
< a name = " l72 " > < / a > header - & gt ; operation = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( operation ) ;
2021-07-03 05:07:57 +01:00
< a name = " l73 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l74 " > < / a > < / span > < span class = cF5 > MemCopy < / span > < span class = cF0 > ( header - & gt ; sender_hardware_addr , send_mac_address , MAC_ADDRESS_LENGTH ) ;
< a name = " l75 " > < / a > header - & gt ; sender_protocol_addr = send_ip ;
2021-07-03 05:07:57 +01:00
< a name = " l76 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l77 " > < / a > < / span > < span class = cF5 > MemCopy < / span > < span class = cF0 > ( header - & gt ; target_hardware_addr , target_mac_address , MAC_ADDRESS_LENGTH ) ;
< a name = " l78 " > < / a > header - & gt ; target_protocol_addr = target_ip ;
2021-07-03 05:07:57 +01:00
< a name = " l79 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l80 " > < / a > EthernetFrameFinish ( de_index ) ;
< a name = " l81 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > < / span > < span class = cFE > 0 < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l82 " > < / a > }
< a name = " l83 " > < / a >
< a name = " l84 " > < / a > CARPHash * ARPCacheFind ( < / span > < span class = cF9 > U32 < / span > < span class = cF0 > ip_address )
< a name = " l85 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l86 " > < / a > < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * ip_string = < / span > < span class = cF5 > MStrPrint < / span > < span class = cF0 > ( < / span > < span class = cF6 > & quot ; % X & quot ; < / span > < span class = cF0 > , ip_address ) ;
< a name = " l87 " > < / a > CARPHash * entry = < / span > < span class = cF5 > HashFind < / span > < span class = cF0 > ( ip_string , arp_cache , HTT_ARP ) ;
2021-07-03 05:07:57 +01:00
< a name = " l88 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l89 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( entry = = < / span > < span class = cF3 > NULL < / span > < span class = cF0 > )
< a name = " l90 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l91 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP CACHE FIND BY IP : Could not find an IP in ARP cache . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l92 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l93 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l94 " > < / a > < / span > < span class = cF5 > Free < / span > < span class = cF0 > ( ip_string ) ;
< a name = " l95 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > entry ;
2021-07-03 05:07:57 +01:00
< a name = " l96 " > < / a > }
< a name = " l97 " > < / a >
< a name = " l98 " > < / a > CARPHash * ARPCachePut ( < / span > < span class = cF9 > U32 < / span > < span class = cF0 > ip_address , < / span > < span class = cF1 > U8 < / span > < span class = cF0 > * mac_address )
< a name = " l99 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l100 " > < / a > CARPHash * entry ;
2021-07-03 05:07:57 +01:00
< a name = " l101 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l102 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP CACHE PUT : Attempting to look for entry in ARP Cache . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l103 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l104 " > < / a > entry = ARPCacheFind ( ip_address ) ;
2021-07-03 05:07:57 +01:00
< a name = " l105 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l106 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ! entry )
< a name = " l107 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l108 " > < / a > entry = < / span > < span class = cF5 > CAlloc < / span > < span class = cF0 > ( < / span > < span class = cF1 > sizeof < / span > < span class = cF7 > ( < / span > < span class = cF0 > CARPHash < / span > < span class = cF7 > ) < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l109 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l110 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP CACHE PUT : Attempting add to cache : addr , mac : & quot ; < / span > < span class = cF0 > ) ;
< a name = " l111 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; 0 x % 0 X , 0 x % 0 X 0 x % 0 X 0 x % 0 X 0 x % 0 X 0 x % 0 X 0 x % 0 X & quot ; < / span > < span class = cF0 > ,
< a name = " l112 " > < / a > ip_address , mac_address [ < / span > < span class = cFE > 0 < / span > < span class = cF0 > ] , mac_address [ < / span > < span class = cFE > 1 < / span > < span class = cF0 > ] , mac_address [ < / span > < span class = cFE > 2 < / span > < span class = cF0 > ] , mac_address [ < / span > < span class = cFE > 3 < / span > < span class = cF0 > ] , mac_address [ < / span > < span class = cFE > 4 < / span > < span class = cF0 > ] , mac_address [ < / span > < span class = cFE > 5 < / span > < span class = cF0 > ] ) ;
2021-07-03 05:07:57 +01:00
< a name = " l113 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l114 " > < / a > entry - & gt ; str = < / span > < span class = cF5 > MStrPrint < / span > < span class = cF0 > ( < / span > < span class = cF6 > & quot ; % X & quot ; < / span > < span class = cF0 > , ip_address ) ;
< a name = " l115 " > < / a > entry - & gt ; type = HTT_ARP ;
< a name = " l116 " > < / a > < / span > < span class = cF5 > MemCopy < / span > < span class = cF0 > ( entry - & gt ; mac_address , mac_address , < / span > < span class = cFE > 6 < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l117 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l118 " > < / a > < / span > < span class = cF5 > HashAdd < / span > < span class = cF0 > ( entry , arp_cache ) ;
< a name = " l119 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l120 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l121 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l122 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; ARP CACHE Put : Entry was already found in Cache . Overwriting . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l123 " > < / a > < / span > < span class = cF5 > MemCopy < / span > < span class = cF0 > ( entry - & gt ; mac_address , mac_address , < / span > < span class = cFE > 6 < / span > < span class = cF0 > ) ;
< a name = " l124 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l125 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l126 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > entry ;
2021-07-03 05:07:57 +01:00
< a name = " l127 " > < / a > }
< a name = " l128 " > < / a >
< a name = " l129 " > < / a > < / span > < span class = cF1 > U0 < / span > < span class = cF0 > ARPLocalIPV4Set ( < / span > < span class = cF9 > U32 < / span > < span class = cF0 > ip_address )
< a name = " l130 " > < / a > { < / span > < span class = cF2 > // takes in little endian IP, stores into globals as Big Endian</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l131 " > < / a > arp_globals . local_ipv4 = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( ip_address ) ;
2021-07-03 05:07:57 +01:00
< a name = " l132 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l133 " > < / a > ARPSend ( ARP_REPLY ,
< a name = " l134 " > < / a > ethernet_globals . ethernet_broadcast ,
< a name = " l135 " > < / a > EthernetMACGet ,
< a name = " l136 " > < / a > arp_globals . local_ipv4 ,
< a name = " l137 " > < / a > ethernet_globals . ethernet_broadcast ,
< a name = " l138 " > < / a > arp_globals . local_ipv4 ) ;
2021-07-03 05:07:57 +01:00
< a name = " l139 " > < / a > }
< a name = " l140 " > < / a >
< a name = " l141 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > ARPHandler ( CEthernetFrame * ethernet_frame )
< a name = " l142 " > < / a > { < / span > < span class = cF2 > // Use of ARPHandler must account for -1 error codes.</span><span class=cF0>
2021-07-04 23:11:34 +01:00
< a name = " l143 " > < / a > CARPHeader * header ;
< a name = " l144 " > < / a > < / span > < span class = cF9 > U16 < / span > < span class = cF0 > operation ;
2021-07-03 05:07:57 +01:00
< a name = " l145 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l146 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Entering ARP Handler . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l147 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l148 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ethernet_frame - & gt ; ethertype ! = ETHERTYPE_ARP )
< a name = " l149 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l150 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame ethertype . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l151 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l152 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l153 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( ethernet_frame - & gt ; length & lt ; < / span > < span class = cF1 > sizeof < / span > < span class = cF7 > ( < / span > < span class = cF0 > CARPHeader < / span > < span class = cF7 > ) < / span > < span class = cF0 > )
< a name = " l154 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l155 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame length . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l156 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l157 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l158 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l159 " > < / a > header = ethernet_frame - & gt ; data ;
< a name = " l160 " > < / a > operation = < / span > < span class = cF5 > EndianU16 < / span > < span class = cF0 > ( header - & gt ; operation ) ;
2021-07-03 05:07:57 +01:00
< a name = " l161 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l162 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; hardware_type < / span > < span class = cF7 > ) < / span > < span class = cF0 > ! = HTYPE_ETHERNET )
< a name = " l163 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l164 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame hardware type . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l165 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l166 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l167 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( < / span > < span class = cF5 > EndianU16 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; protocol_type < / span > < span class = cF7 > ) < / span > < span class = cF0 > ! = ETHERTYPE_IPV4 )
< a name = " l168 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l169 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame protocol type . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l170 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l171 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l172 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( header - & gt ; hardware_addr_len ! = HLEN_ETHERNET )
< a name = " l173 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l174 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame hardware address length . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l175 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l176 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l177 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( header - & gt ; protocol_addr_len ! = PLEN_IPV4 )
< a name = " l178 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l179 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Caught wrong frame protocol address length . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l180 " > < / a > < / span > < span class = cF1 > return < / span > < span class = cF0 > - < / span > < span class = cFE > 1 < / span > < span class = cF0 > ;
< a name = " l181 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l182 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l183 " > < / a > < / span > < span class = cF1 > switch < / span > < span class = cF0 > ( operation )
< a name = " l184 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l185 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > ARP_REQUEST :
< a name = " l186 " > < / a > < / span > < span class = cF1 > if < / span > < span class = cF0 > ( header - & gt ; target_protocol_addr = = arp_globals . local_ipv4 )
< a name = " l187 " > < / a > {
< a name = " l188 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Saw request , sending back reply . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l189 " > < / a > ARPSend ( ARP_REPLY ,
< a name = " l190 " > < / a > header - & gt ; sender_hardware_addr ,
< a name = " l191 " > < / a > EthernetMACGet ,
< a name = " l192 " > < / a > arp_globals . local_ipv4 ,
< a name = " l193 " > < / a > header - & gt ; sender_hardware_addr ,
< a name = " l194 " > < / a > header - & gt ; sender_protocol_addr ) ;
< a name = " l195 " > < / a > }
< a name = " l196 " > < / a > < / span > < span class = cF1 > else < / span > < span class = cF0 >
< a name = " l197 " > < / a > NetWarn ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Saw request , target IP address is not this machine . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l198 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l199 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l200 " > < / a > < / span > < span class = cF1 > case < / span > < span class = cF0 > ARP_REPLY :
< a name = " l201 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Saw reply , putting into ARP Cache . & quot ; < / span > < span class = cF0 > ) ;
< a name = " l202 " > < / a > ARPCachePut ( < / span > < span class = cF5 > EndianU32 < / span > < span class = cF7 > ( < / span > < span class = cF0 > header - & gt ; sender_protocol_addr < / span > < span class = cF7 > ) < / span > < span class = cF0 > , header - & gt ; sender_hardware_addr ) ;
< a name = " l203 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l204 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l205 " > < / a > < / span > < span class = cF1 > default < / span > < span class = cF0 > :
< a name = " l206 " > < / a > NetErr ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Unrecognized operation : 0 x % X & quot ; < / span > < span class = cF0 > , operation ) ;
< a name = " l207 " > < / a > < / span > < span class = cF1 > break < / span > < span class = cF0 > ;
< a name = " l208 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l209 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l210 " > < / a > NetLog ( < / span > < span class = cF6 > & quot ; ARP HANDLER : Exiting . & quot ; < / span > < span class = cF0 > ) ;
2021-07-03 05:07:57 +01:00
< a name = " l211 " > < / a > }
< a name = " l212 " > < / a >
< a name = " l213 " > < / a > < / span > < span class = cF1 > U0 < / span > < span class = cF0 > ARPRep ( )
< a name = " l214 " > < / a > {
2021-07-04 23:11:34 +01:00
< a name = " l215 " > < / a > < / span > < span class = cF9 > I64 < / span > < span class = cF0 > i , j ;
< a name = " l216 " > < / a > CARPHash * temp_hash ;
< a name = " l217 " > < / a > < / span > < span class = cF9 > U32 < / span > < span class = cF0 > address ;
2021-07-03 05:07:57 +01:00
< a name = " l218 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l219 " > < / a > < / span > < span class = cF6 > & quot ; $ LTBLUE $ ARP Report : $ FG $ \ n \ n & quot ; < / span > < span class = cF0 > ;
< a name = " l220 " > < / a > < / span > < span class = cF6 > & quot ; ARP Local Address : < / span > < span class = cF0 > < / span > < span class = cF6 > % d . % d . % d . % d \ n \ n & quot ; < / span > < span class = cF0 > ,
< a name = " l221 " > < / a > arp_globals . local_ipv4 . u8 [ < / span > < span class = cFE > 0 < / span > < span class = cF0 > ] ,
< a name = " l222 " > < / a > arp_globals . local_ipv4 . u8 [ < / span > < span class = cFE > 1 < / span > < span class = cF0 > ] ,
< a name = " l223 " > < / a > arp_globals . local_ipv4 . u8 [ < / span > < span class = cFE > 2 < / span > < span class = cF0 > ] ,
< a name = " l224 " > < / a > arp_globals . local_ipv4 . u8 [ < / span > < span class = cFE > 3 < / span > < span class = cF0 > ] ;
2021-07-03 05:07:57 +01:00
< a name = " l225 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l226 " > < / a > < / span > < span class = cF1 > for < / span > < span class = cF0 > ( i = < / span > < span class = cFE > 0 < / span > < span class = cF0 > ; i & lt ; = arp_cache - & gt ; mask ; i + + )
< a name = " l227 " > < / a > < / span > < span class = cF7 > { < / span > < span class = cF0 >
< a name = " l228 " > < / a > temp_hash = arp_cache - & gt ; body [ i ] ;
2021-07-03 05:07:57 +01:00
< a name = " l229 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l230 " > < / a > < / span > < span class = cF1 > while < / span > < span class = cF0 > ( temp_hash )
< a name = " l231 " > < / a > {
< a name = " l232 " > < / a > < / span > < span class = cF6 > & quot ; ARP Hash @ 0 x % X : \ n & quot ; < / span > < span class = cF0 > , temp_hash ;
2021-07-03 05:07:57 +01:00
< a name = " l233 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l234 " > < / a > address = < / span > < span class = cF5 > EndianU32 < / span > < span class = cF0 > ( < / span > < span class = cF5 > Str2I64 < / span > < span class = cF7 > ( < / span > < span class = cF0 > temp_hash - & gt ; str , < / span > < span class = cFE > 16 < / span > < span class = cF7 > ) ( < / span > < span class = cF9 > U32 < / span > < span class = cF7 > ) < / span > < span class = cF0 > ) ;
< a name = " l235 " > < / a > < / span > < span class = cF6 > & quot ; < / span > < span class = cF0 > < / span > < span class = cF6 > IP Address : < / span > < span class = cF0 > < / span > < span class = cF6 > % d . % d . % d . % d \ n & quot ; < / span > < span class = cF0 > ,
< a name = " l236 " > < / a > address . u8 [ < / span > < span class = cFE > 0 < / span > < span class = cF0 > ] , address . u8 [ < / span > < span class = cFE > 1 < / span > < span class = cF0 > ] , address . u8 [ < / span > < span class = cFE > 2 < / span > < span class = cF0 > ] , address . u8 [ < / span > < span class = cFE > 3 < / span > < span class = cF0 > ] ; < / span > < span class = cF2 > // todo: kludge</span><span class=cF0>
2021-07-03 05:07:57 +01:00
< a name = " l237 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l238 " > < / a > < / span > < span class = cF6 > & quot ; < / span > < span class = cF0 > < / span > < span class = cF6 > MAC Address : < / span > < span class = cF0 > < / span > < span class = cF6 > & quot ; ; < / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = " l239 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l240 " > < / a > < / span > < span class = cF1 > for < / span > < span class = cF0 > ( j = < / span > < span class = cFE > 0 < / span > < span class = cF0 > ; j & lt ; MAC_ADDRESS_LENGTH ; j + + )
< a name = " l241 " > < / a > < / span > < span class = cF6 > & quot ; % 02 X & quot ; < / span > < span class = cF0 > , temp_hash - & gt ; mac_address [ j ] ;
2021-07-03 05:07:57 +01:00
< a name = " l242 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l243 " > < / a > < / span > < span class = cF6 > & quot ; \ n \ n & quot ; < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l244 " > < / a >
2021-07-04 23:11:34 +01:00
< a name = " l245 " > < / a > temp_hash = temp_hash - & gt ; next ;
< a name = " l246 " > < / a > }
< a name = " l247 " > < / a > < / span > < span class = cF7 > } < / span > < span class = cF0 >
< a name = " l248 " > < / a > < / span > < span class = cF6 > & quot ; \ n & quot ; < / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = " l249 " > < / a > }
< a name = " l250 " > < / a >
< a name = " l251 " > < / a > ARPCacheInit ; < / span > < / pre > < / body >
< / html >