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

Low-level functions mostly internal to the UDP driver. More...

Functions

ushort udpChksum (struct packet *pkt, ushort len, const struct netaddr *src, const struct netaddr *dst)
 
struct udp * udpDemux (ushort dstpt, ushort srcpt, const struct netaddr *dstip, const struct netaddr *srcip)
 
syscall udpFreebuf (struct udpPkt *udppkt)
 
struct udpPkt * udpGetbuf (struct udp *udpptr)
 
syscall udpRecv (struct packet *pkt, const struct netaddr *src, const struct netaddr *dst)
 
syscall udpSend (struct udp *udpptr, ushort datalen, const void *buf)
 

Detailed Description

Low-level functions mostly internal to the UDP driver.

Function Documentation

ushort udpChksum ( struct packet *  pkt,
ushort  len,
const struct netaddr *  src,
const struct netaddr *  dst 
)

Calculate the checksum of a UDP packet based on UDP and IP information

Parameters
udppktUDP packet to calculate checksum for
lenLength of UDP packet
srcSource IP Address
dstDestination IP Address
Returns
The checksum of the UDP packet
struct udp* udpDemux ( ushort  dstpt,
ushort  srcpt,
const struct netaddr *  dstip,
const struct netaddr *  srcip 
)

Locate the UDP socket for a UDP packet

Parameters
dstptdestination port of the UDP packet
srcptsource port of the UDP packet
dstipdestination IP of the UDP packet
srcipsource IP of the UDP packet
Returns
most completely matched socket, NULL if no match
Precondition
-condition interrupts are already disabled
Postcondition
-condition interrupts are still disabled
syscall udpRecv ( struct packet *  pkt,
const struct netaddr *  src,
const struct netaddr *  dst 
)

Receive a UDP packet and place it in the UDP device's input buffer

Parameters
pktIncoming UDP packet
srcSource address
dstDestination address
Returns
OK if UDP packet is received properly, otherwise SYSERR
syscall udpSend ( struct udp *  udpptr,
ushort  datalen,
const void *  buf 
)

Send a UDP packet through a UDP device, thereby sending it over the network with the address/port parameters with which the UDP device is configured.

This function is intended to be internal to the UDP code. From external code use write(), which calls udpWrite().

Note: depending on the lower levels of the network stack, this function likely only buffers the packet to be sent at some later time. Therefore, it may not have actually been transmitted on the wire when this function returns.

The UDP device MUST be open and MUST remain open throughout the execution of this function.

Parameters
udpptrPointer to the control block for the UDP device.
datalenNumber of bytes of data to send, which must be a valid value for the current UDP device mode (e.g. if in passive mode, it must be at least the length of the UDP pseudo-header plus UDP header).
bufBuffer of data to send. In the default mode, this will interpreted as the UDP payload; however, if the UDP device is in passive mode, this will interpreted as the UDP pseudo-header follewed by the UDP header followed by the UDP payload.
Returns
OK if packet was sent successfully; otherwise SYSERR or an error code returned by ipv4Send().