mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-29 00:36:32 +00:00
279 lines
22 KiB
HTML
Executable file
279 lines
22 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V1.08">
|
|
<style type="text/css">
|
|
body {background-color:#1f1f1f;}
|
|
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
|
|
.cF1{color:#4f84a6;background-color:#1f1f1f;}
|
|
.cF2{color:#73a255;background-color:#1f1f1f;}
|
|
.cF3{color:#297582;background-color:#1f1f1f;}
|
|
.cF4{color:#b34f4b;background-color:#1f1f1f;}
|
|
.cF5{color:#8a52c3;background-color:#1f1f1f;}
|
|
.cF6{color:#b7822f;background-color:#1f1f1f;}
|
|
.cF7{color:#444444;background-color:#1f1f1f;}
|
|
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
|
|
.cF9{color:#94bfde;background-color:#1f1f1f;}
|
|
.cFA{color:#a1ce97;background-color:#1f1f1f;}
|
|
.cFB{color:#6db4be;background-color:#1f1f1f;}
|
|
.cFC{color:#e88e88;background-color:#1f1f1f;}
|
|
.cFD{color:#ca94e8;background-color:#1f1f1f;}
|
|
.cFE{color:#d4b475;background-color:#1f1f1f;}
|
|
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<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>
|
|
<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>
|
|
<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>
|
|
<a name="l7"></a>
|
|
<a name="l8"></a></span><span class=cF1>class</span><span class=cF0> CARPHeader
|
|
<a name="l9"></a>{
|
|
<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;
|
|
<a name="l12"></a>
|
|
<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;
|
|
<a name="l15"></a>
|
|
<a name="l16"></a> </span><span class=cF9>U16</span><span class=cF0> operation;
|
|
<a name="l17"></a>
|
|
<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;
|
|
<a name="l20"></a>
|
|
<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;
|
|
<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>
|
|
<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];
|
|
<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>{
|
|
<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>
|
|
<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>{
|
|
<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>;
|
|
<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,
|
|
<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)
|
|
<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>
|
|
<a name="l54"></a> </span><span class=cF1>U8</span><span class=cF0> *arp_frame;
|
|
<a name="l55"></a> CARPHeader *header;
|
|
<a name="l56"></a>
|
|
<a name="l57"></a> </span><span class=cF9>I64</span><span class=cF0> de_index = EthernetFrameAllocate(&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>);
|
|
<a name="l62"></a>
|
|
<a name="l63"></a> </span><span class=cF1>if</span><span class=cF0> (de_index < </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>
|
|
<a name="l65"></a>
|
|
<a name="l66"></a> header = arp_frame;
|
|
<a name="l67"></a>
|
|
<a name="l68"></a> header->hardware_type = </span><span class=cF5>EndianU16</span><span class=cF0>(HTYPE_ETHERNET);
|
|
<a name="l69"></a> header->protocol_type = </span><span class=cF5>EndianU16</span><span class=cF0>(ETHERTYPE_IPV4);
|
|
<a name="l70"></a> header->hardware_addr_len = MAC_ADDRESS_LENGTH;
|
|
<a name="l71"></a> header->protocol_addr_len = IP_ADDRESS_LENGTH;
|
|
<a name="l72"></a> header->operation = </span><span class=cF5>EndianU16</span><span class=cF0>(operation);
|
|
<a name="l73"></a>
|
|
<a name="l74"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(header->sender_hardware_addr, send_mac_address, MAC_ADDRESS_LENGTH);
|
|
<a name="l75"></a> header->sender_protocol_addr = send_ip;
|
|
<a name="l76"></a>
|
|
<a name="l77"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(header->target_hardware_addr, target_mac_address, MAC_ADDRESS_LENGTH);
|
|
<a name="l78"></a> header->target_protocol_addr = target_ip;
|
|
<a name="l79"></a>
|
|
<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>;
|
|
<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>{
|
|
<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>"%X"</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);
|
|
<a name="l88"></a>
|
|
<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>"ARP CACHE FIND BY IP: Could not find an IP in ARP cache."</span><span class=cF0>);
|
|
<a name="l92"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l93"></a>
|
|
<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;
|
|
<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>{
|
|
<a name="l100"></a> CARPHash *entry;
|
|
<a name="l101"></a>
|
|
<a name="l102"></a> NetLog(</span><span class=cF6>"ARP CACHE PUT: Attempting to look for entry in ARP Cache."</span><span class=cF0>);
|
|
<a name="l103"></a>
|
|
<a name="l104"></a> entry = ARPCacheFind(ip_address);
|
|
<a name="l105"></a>
|
|
<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>);
|
|
<a name="l109"></a>
|
|
<a name="l110"></a> NetLog(</span><span class=cF6>"ARP CACHE PUT: Attempting add to cache: addr, mac:"</span><span class=cF0>);
|
|
<a name="l111"></a> NetLog(</span><span class=cF6>" 0x%0X, 0x%0X 0x%0X 0x%0X 0x%0X 0x%0X 0x%0X"</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>]);
|
|
<a name="l113"></a>
|
|
<a name="l114"></a> entry->str = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%X"</span><span class=cF0>, ip_address);
|
|
<a name="l115"></a> entry->type = HTT_ARP;
|
|
<a name="l116"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(entry->mac_address, mac_address, </span><span class=cFE>6</span><span class=cF0>);
|
|
<a name="l117"></a>
|
|
<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>"ARP CACHE Put: Entry was already found in Cache. Overwriting."</span><span class=cF0>);
|
|
<a name="l123"></a> </span><span class=cF5>MemCopy</span><span class=cF0>(entry->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>
|
|
<a name="l125"></a>
|
|
<a name="l126"></a> </span><span class=cF1>return</span><span class=cF0> entry;
|
|
<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>
|
|
<a name="l131"></a> arp_globals.local_ipv4 = </span><span class=cF5>EndianU32</span><span class=cF0>(ip_address);
|
|
<a name="l132"></a>
|
|
<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);
|
|
<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>
|
|
<a name="l143"></a> CARPHeader *header;
|
|
<a name="l144"></a> </span><span class=cF9>U16</span><span class=cF0> operation;
|
|
<a name="l145"></a>
|
|
<a name="l146"></a> NetLog(</span><span class=cF6>"ARP HANDLER: Entering ARP Handler."</span><span class=cF0>);
|
|
<a name="l147"></a>
|
|
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (ethernet_frame->ethertype != ETHERTYPE_ARP)
|
|
<a name="l149"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l150"></a> NetErr(</span><span class=cF6>"ARP HANDLER: Caught wrong frame ethertype."</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->length < </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>"ARP HANDLER: Caught wrong frame length."</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>
|
|
<a name="l158"></a>
|
|
<a name="l159"></a> header = ethernet_frame->data;
|
|
<a name="l160"></a> operation = </span><span class=cF5>EndianU16</span><span class=cF0>(header->operation);
|
|
<a name="l161"></a>
|
|
<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->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>"ARP HANDLER: Caught wrong frame hardware type."</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->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>"ARP HANDLER: Caught wrong frame protocol type."</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->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>"ARP HANDLER: Caught wrong frame hardware address length."</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->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>"ARP HANDLER: Caught wrong frame protocol address length."</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>
|
|
<a name="l182"></a>
|
|
<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->target_protocol_addr == arp_globals.local_ipv4)
|
|
<a name="l187"></a> {
|
|
<a name="l188"></a> NetLog(</span><span class=cF6>"ARP HANDLER: Saw request, sending back reply."</span><span class=cF0>);
|
|
<a name="l189"></a> ARPSend(ARP_REPLY,
|
|
<a name="l190"></a> header->sender_hardware_addr,
|
|
<a name="l191"></a> EthernetMACGet,
|
|
<a name="l192"></a> arp_globals.local_ipv4,
|
|
<a name="l193"></a> header->sender_hardware_addr,
|
|
<a name="l194"></a> header->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>"ARP HANDLER: Saw request, target IP address is not this machine."</span><span class=cF0>);
|
|
<a name="l198"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l199"></a>
|
|
<a name="l200"></a> </span><span class=cF1>case</span><span class=cF0> ARP_REPLY:
|
|
<a name="l201"></a> NetLog(</span><span class=cF6>"ARP HANDLER: Saw reply, putting into ARP Cache."</span><span class=cF0>);
|
|
<a name="l202"></a> ARPCachePut(</span><span class=cF5>EndianU32</span><span class=cF7>(</span><span class=cF0>header->sender_protocol_addr</span><span class=cF7>)</span><span class=cF0>, header->sender_hardware_addr);
|
|
<a name="l203"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l204"></a>
|
|
<a name="l205"></a> </span><span class=cF1>default</span><span class=cF0>:
|
|
<a name="l206"></a> NetErr(</span><span class=cF6>"ARP HANDLER: Unrecognized operation: 0x%X"</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>
|
|
<a name="l209"></a>
|
|
<a name="l210"></a> NetLog(</span><span class=cF6>"ARP HANDLER: Exiting."</span><span class=cF0>);
|
|
<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>{
|
|
<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;
|
|
<a name="l218"></a>
|
|
<a name="l219"></a> </span><span class=cF6>"$LTBLUE$ARP Report:$FG$\n\n"</span><span class=cF0>;
|
|
<a name="l220"></a> </span><span class=cF6>"ARP Local Address:</span><span class=cF0> </span><span class=cF6>%d.%d.%d.%d\n\n"</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>];
|
|
<a name="l225"></a>
|
|
<a name="l226"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i <= arp_cache->mask; i++)
|
|
<a name="l227"></a> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l228"></a> temp_hash = arp_cache->body[i];
|
|
<a name="l229"></a>
|
|
<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>"ARP Hash @ 0x%X:\n"</span><span class=cF0>, temp_hash;
|
|
<a name="l233"></a>
|
|
<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->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>"</span><span class=cF0> </span><span class=cF6>IP Address:</span><span class=cF0> </span><span class=cF6>%d.%d.%d.%d\n"</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>
|
|
<a name="l237"></a>
|
|
<a name="l238"></a> </span><span class=cF6>"</span><span class=cF0> </span><span class=cF6>MAC Address:</span><span class=cF0> </span><span class=cF6>";</span><span class=cF0>
|
|
<a name="l239"></a>
|
|
<a name="l240"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j < MAC_ADDRESS_LENGTH; j++)
|
|
<a name="l241"></a> </span><span class=cF6>"%02X "</span><span class=cF0>, temp_hash->mac_address[j];
|
|
<a name="l242"></a>
|
|
<a name="l243"></a> </span><span class=cF6>"\n\n"</span><span class=cF0>;
|
|
<a name="l244"></a>
|
|
<a name="l245"></a> temp_hash = temp_hash->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>"\n"</span><span class=cF0>;
|
|
<a name="l249"></a>}
|
|
<a name="l250"></a>
|
|
<a name="l251"></a>ARPCacheInit;</span></pre></body>
|
|
</html>
|