Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.

0033001 /*
0033002 io.c
0033003 
0033004 Copyright 1995 Philip Homburg
0033005 */
Test Comment


Test Comment 1


Test Comment 1 Body


Test Comment 2


Test Comment 2 Body


Test Comment 1


Test Comment 1 Body


Test Comment 2


Test Comment 2 Body

Participant comment / Author: Test Andy 5 / Date of Posting: 2005-07-11

Test Andy 5


Participant comment / Author: Andy Again / Date of Posting: 2005-07-11

This is the second comment that I've added to this comment.



0033006 
0033006 
0033006 
0033007 #include <stdlib.h>
0033008 
0033009 #include "inet.h"
get_time()

get_time() returns the number of clock ticks since reboot.

Several of the clients (eth, arp, ip, tcp, and udp) use get_time() to determine an appropriate timeout value for a given operation. For example, the arp code calls get_time() to determine an appropriate amount of time to wait for a response from an arp request before giving up.


0033010 #include "io.h"
0033011 
0033012 PUBLIC void writeIpAddr(addr)
0033013 ipaddr_t addr;
0033014 {
0033015 #define addrInBytes ((u8_t *)&addr)
test


alloc_cache_ent()


alloc_cache_ent() finds an unused entry within the arp table and returns the entry's index within the table. If there are no unused entries within the arp table, the entry that was last used is returned instead.


arp_ip_eth()


arp_ip_eth(eth_port, ipaddr, ethaddr) looks for an entry in the arp table that matches ipaddr, the second parameter, and if it finds it, returns the corresponding ethernet address in ethaddr, the third parameter. If arp_ip_eth() does not find a valid entry in the arp table for the ip address, it sends out an arp broadcast in an attempt to find the ethernet address for the ip address and returns NW_SUSPEND.


arp_init()


arp_init() sets the ap_state field of all the arp ports to APS_ERROR. Later, when the ip code acquires an arp port, the ap_state field of the acquired arp port is set to APS_INITIAL.


alloc_cache_ent()


alloc_cache_ent() finds an unused entry within the arp table and returns the entry's index within the table. If there are no unused entries within the arp table, the entry that was last used is returned instead.


arp_ip_eth()


arp_ip_eth(eth_port, ipaddr, ethaddr) looks for an entry in the arp table that matches ipaddr, the second parameter, and if it finds it, returns the corresponding ethernet address in ethaddr, the third parameter. If arp_ip_eth() does not find a valid entry in the arp table for the ip address, it sends out an arp broadcast in an attempt to find the ethernet address for the ip address and returns NW_SUSPEND.


arp_init()


arp_init() sets the ap_state field of all the arp ports to APS_ERROR. Later, when the ip code acquires an arp port, the ap_state field of the acquired arp port is set to APS_INITIAL.

Participant comment / Author: Andy Test 99 / Date of Posting: 2005-07-13

Andy Test 99


Participant comment / Author: Andy Test 100 / Date of Posting: 2005-07-13

Andy Test 100



0033016 
0033017          printf("%d.%d.%d.%d", addrInBytes[0], addrInBytes[1],
0033018                   addrInBytes[2], addrInBytes[3]);
0033019 #undef addrInBytes
0033020 }
0033021 
0033022 PUBLIC void writeEtherAddr(addr)
0033023 ether_addr_t *addr;
test 2


arp_getdata()


arp_getdata(fd, offset, count, for_ioctl) accomplishes several different tasks, depending on the state of the arp port:

APS_ARPPROTO (configuration state):

If count, arp_getdata()'s third parameter, is non-zero, arp_getdata() creates a nwio_eth_opt struct and sets the appropriate flags and type for an ethernet file descriptor that services an arp port:

nweo_flags= NWEO_COPY|NWEO_EN_BROAD|NWEO_TYPESPEC;
nweo_type= HTONS(ETH_ARP_PROTO);

and then returns an accessor that contains the struct.

ARS_ARPMAIN (operational state):

If count, arp_getdata()'s third parameter, is non-zero, arp_getdata() creates an arp packet (an arp46_t struct) and returns the struct. eth_write() calls arp_getdata() to create an arp-request or arp_reply packet (the packets that build the arp table. The ip and ethernet address of the arp-reply or request is gotten from the ap_write_ipaddr and ap_write_ethaddr fields, respectively, of the arp port.


0033024 {
0033025 #define addrInBytes ((u8_t *)addr->ea_addr)
0033026 
0033027          printf("%x:%x:%x:%x:%x:%x", addrInBytes[0], addrInBytes[1],
0033028                   addrInBytes[2], addrInBytes[3], addrInBytes[4], addrInBytes[5]);
0033029 #undef addrInBytes
0033030 }
0033031 
0033032 /*
0033033  * $PchId: io.c,v 1.5 1995/11/21 06:45:27 philip Exp $
0033034  */