Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Modules | Functions
Networking

Networking subsystem and protocols. More...

Modules

 ARP
 Address Resolution Protocol.
 
 DHCP client
 Client for Dynamic Host Configuration Protocol (IPv4 version)
 
 ICMP
 Internet Control Message Protocol.
 
 IPv4
 Internet Protocol Version 4.
 
 Network Emulation
 Automatically drop and corrupt packets for testing.
 
 Packet snooping
 View the data of packets being send and received over a network interface.
 
 Routing
 IPv4 routing support.
 
 TFTP client
 Trivial File Transfer Protocol client.
 

Functions

ushort netChksum (void *data, uint len)
 
syscall netDown (int descrp)
 
syscall netFreebuf (struct packet *pkt)
 
struct packet * netGetbuf (void)
 
syscall netInit ()
 
struct netif * netLookup (int devnum)
 
thread netRecv (struct netif *netptr)
 
syscall netSend (struct packet *pkt, const struct netaddr *hwaddr, const struct netaddr *praddr, ushort type)
 
syscall netUp (int descrp, const struct netaddr *ip, const struct netaddr *mask, const struct netaddr *gateway)
 
bool netaddrequal (const struct netaddr *a, const struct netaddr *b)
 
syscall netaddrhost (struct netaddr *a, const struct netaddr *mask)
 
syscall netaddrmask (struct netaddr *a, const struct netaddr *mask)
 
int netaddrsprintf (char *str, const struct netaddr *addr)
 

Detailed Description

Networking subsystem and protocols.

Note: although they are network protocols, UDP and TCP are implemented as device drivers and therefore are not grouped in this section.

Function Documentation

bool netaddrequal ( const struct netaddr *  a,
const struct netaddr *  b 
)

Compare two network addresses

Parameters
afirst network address
bsecond network address
Returns
::TRUE if addresses are the same, otherwise ::FALSE.
syscall netaddrhost ( struct netaddr *  a,
const struct netaddr *  mask 
)

Calculate the host portion of a network address, which is essentially the opposite of masking it with netaddrmask(). For example, with IPv4, extracting the host portion of 192.168.0.50 with a mask of 255.255.255.0 will produce 0.0.0.50.

Parameters
aNetwork address from which to extract the host portion.
maskThe netmask to use.
Returns
SYSERR if a and mask are not the same type of network address; otherwise returns OK and modifies a in place to produce just the host portion of the network address.
syscall netaddrmask ( struct netaddr *  a,
const struct netaddr *  mask 
)

Apply a mask to a network address. For example, with IPv4, masking 192.168.0.50 with 255.255.255.0 will produce 192.168.0.0.

Parameters
aNetwork address to mask.
maskThe mask to apply.
Returns
SYSERR if a and mask are not the same type of network address; otherwise returns OK and modifies a in place to mask it.
int netaddrsprintf ( char *  str,
const struct netaddr *  addr 
)

Format a network address and place in a null-terminated string.

Parameters
strPointer to the output string, which must have enough space for the appropriate type of network address, including the null terminator.
addrNetwork address to format.
Returns
A pointer to the resulting string cast to an int.
syscall netDown ( int  descrp)

Bring down a network interface.

Parameters
descrpDevice descriptor for the underlying network device of the interface.
Returns
::OK if the interface was successfully brought down; ::SYSERR otherwise. Currently, ::SYSERR is only returned if no network interface is running on the device.
syscall netFreebuf ( struct packet *  pkt)

file netGetbuf.c

Frees a buffer for storing a packet.

Returns
OK if successful, SYSERR if an error occured
struct packet* netGetbuf ( void  )

file netGetbuf.c

Provides a buffer for storing a packet.

Returns
pointer to a packet buffer, SYSERR if an error occured

< pointer to packet

syscall netInit ( )

Initialize network interfaces

Returns
OK if initialized properly, otherwise SYSERR
struct netif* netLookup ( int  devnum)

Lookup a network interface, given an underlying device.

Parameters
devnumdevice number to find netif for.
Returns
network interface, NULL if none exists
thread netRecv ( struct netif *  netptr)

Receive thread to handle one incoming packet at a time

Parameters
netptrnetwork interface device to open netRecv on
Returns
This thread never returns.

< maximum packet length

syscall netSend ( struct packet *  pkt,
const struct netaddr *  hwaddr,
const struct netaddr *  praddr,
ushort  type 
)

file netSend.c

Appends the Link-Level header to a packet and writes to the underlying interface.

Parameters
pktpacket to send
hwaddrhardware address of the destination, NULL if should lookup
praddrprotocol address of the destination, NULL if hwaddr is known
typetype of the packet to put in link level header
Returns
OK if packet was sent, TIMEOUT if ARP request timed out, otherwise SYSERR

< pointer to network interface

< pointer to Ethernet header

< result of ARP lookup

syscall netUp ( int  descrp,
const struct netaddr *  ip,
const struct netaddr *  mask,
const struct netaddr *  gateway 
)

Starts a network interface using the specified protocol addresses.

Parameters
descrpIndex of the underlying network device on which to open the interface.
ipProtocol address; cannot be NULL.
maskProtocol address mask; cannot be NULL.
gatewayProtocol address of the gateway, or NULL if unspecified. If unspecified, it is interpreted as "no gateway".
Returns
OK if the network interface was successfully started; otherwise SYSERR.