@ -30,35 +30,35 @@
struct in_addr net_arp_wait_packet_ip ;
static struct in_addr net_arp_wait_reply_ip ;
/* MAC address of waiting packet's destination */
uchar * NetArpWaitPacketMAC ;
int NetArpWaitTxPacketS ize;
ulong NetArpWaitTimerS tart;
int NetArpWaitT ry;
uchar * arp_wait_packet_ethaddr ;
int arp_wait_tx_packet_s ize;
ulong arp_wait_timer_s tart;
int arp_wait_t ry;
static uchar * net_ arp_tx_packet; /* THE ARP transmit packet */
static uchar NetArpPacketB uf[ PKTSIZE_ALIGN + PKTALIGN ] ;
static uchar * arp_tx_packet ; /* THE ARP transmit packet */
static uchar arp_tx_packet_b uf[ PKTSIZE_ALIGN + PKTALIGN ] ;
void ArpI nit( void )
void arp_i nit( void )
{
/* XXX problem with bss workaround */
NetArpWaitPacketMAC = NULL ;
arp_wait_packet_ethaddr = NULL ;
net_arp_wait_packet_ip . s_addr = 0 ;
net_arp_wait_reply_ip . s_addr = 0 ;
NetArpWaitTxPacketS ize = 0 ;
net_ arp_tx_packet = & NetArpPacketB uf[ 0 ] + ( PKTALIGN - 1 ) ;
net_ arp_tx_packet - = ( ulong ) net_ arp_tx_packet % PKTALIGN ;
arp_wait_tx_packet_s ize = 0 ;
arp_tx_packet = & arp_tx_packet_b uf[ 0 ] + ( PKTALIGN - 1 ) ;
arp_tx_packet - = ( ulong ) arp_tx_packet % PKTALIGN ;
}
void arp_raw_request ( struct in_addr source_ip , const uchar * targetEthe r ,
void arp_raw_request ( struct in_addr source_ip , const uchar * target_ethadd r ,
struct in_addr target_ip )
{
uchar * pkt ;
struct arp_hdr * arp ;
int eth_hdr_size ;
debug_cond ( DEBUG_DEV_PKT , " ARP broadcast %d \n " , NetArpWaitT ry) ;
debug_cond ( DEBUG_DEV_PKT , " ARP broadcast %d \n " , arp_wait_t ry) ;
pkt = net_ arp_tx_packet;
pkt = arp_tx_packet ;
eth_hdr_size = net_set_ether ( pkt , net_bcast_ethaddr , PROT_ARP ) ;
pkt + = eth_hdr_size ;
@ -73,13 +73,13 @@ void arp_raw_request(struct in_addr source_ip, const uchar *targetEther,
memcpy ( & arp - > ar_sha , net_ethaddr , ARP_HLEN ) ; /* source ET addr */
net_write_ip ( & arp - > ar_spa , source_ip ) ; /* source IP addr */
memcpy ( & arp - > ar_tha , targetEthe r , ARP_HLEN ) ; /* target ET addr */
memcpy ( & arp - > ar_tha , target_ethadd r , ARP_HLEN ) ; /* target ET addr */
net_write_ip ( & arp - > ar_tpa , target_ip ) ; /* target IP addr */
net_send_packet ( net_ arp_tx_packet, eth_hdr_size + ARP_HDR_SIZE ) ;
net_send_packet ( arp_tx_packet , eth_hdr_size + ARP_HDR_SIZE ) ;
}
void ArpR equest( void )
void arp_r equest( void )
{
if ( ( net_arp_wait_packet_ip . s_addr & net_netmask . s_addr ) ! =
( net_ip . s_addr & net_netmask . s_addr ) ) {
@ -96,7 +96,7 @@ void ArpRequest(void)
arp_raw_request ( net_ip , net_null_ethaddr , net_arp_wait_reply_ip ) ;
}
void ArpTimeoutC heck( void )
void arp_timeout_c heck( void )
{
ulong t ;
@ -106,21 +106,21 @@ void ArpTimeoutCheck(void)
t = get_timer ( 0 ) ;
/* check for arp timeout */
if ( ( t - NetArpWaitTimerS tart) > ARP_TIMEOUT ) {
NetArpWaitT ry+ + ;
if ( ( t - arp_wait_timer_s tart) > ARP_TIMEOUT ) {
arp_wait_t ry+ + ;
if ( NetArpWaitT ry > = ARP_TIMEOUT_COUNT ) {
if ( arp_wait_t ry > = ARP_TIMEOUT_COUNT ) {
puts ( " \n ARP Retry count exceeded; starting again \n " ) ;
NetArpWaitT ry = 0 ;
arp_wait_t ry = 0 ;
NetStartAgain ( ) ;
} else {
NetArpWaitTimerS tart = t ;
ArpR equest( ) ;
arp_wait_timer_s tart = t ;
arp_r equest( ) ;
}
}
}
void ArpR eceive( struct ethernet_hdr * et , struct ip_udp_hdr * ip , int len )
void arp_r eceive( struct ethernet_hdr * et , struct ip_udp_hdr * ip , int len )
{
struct arp_hdr * arp ;
struct in_addr reply_ip_addr ;
@ -209,8 +209,8 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
arp - > ar_data ) ;
/* save address for later use */
if ( NetArpWaitPacketMAC ! = NULL )
memcpy ( NetArpWaitPacketMAC ,
if ( arp_wait_packet_ethaddr ! = NULL )
memcpy ( arp_wait_packet_ethaddr ,
& arp - > ar_sha , ARP_HLEN ) ;
net_get_arp_handler ( ) ( ( uchar * ) arp , 0 , reply_ip_addr ,
@ -220,13 +220,12 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
and transmit it */
memcpy ( ( ( struct ethernet_hdr * ) net_tx_packet ) - > et_dest ,
& arp - > ar_sha , ARP_HLEN ) ;
net_send_packet ( net_tx_packet , NetArpWaitTxPacketS ize) ;
net_send_packet ( net_tx_packet , arp_wait_tx_packet_s ize) ;
/* no arp request pending now */
net_arp_wait_packet_ip . s_addr = 0 ;
NetArpWaitTxPacketSize = 0 ;
NetArpWaitPacketMAC = NULL ;
arp_wait_tx_packet_size = 0 ;
arp_wait_packet_ethaddr = NULL ;
}
return ;
default :