Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

XgStack


Data Structures

struct  ARPENTRY
struct  ARPFRAME
struct  ether_arp
 Ethernet ARP protocol structure. More...

struct  ether_header
 Ethernet protocol header. More...

struct  ip
 Structure of an internet header. More...

struct  nic_pkt_header
struct  udphdr
 UDP protocol header structure. More...


Defines

#define ARPHRD_ETHER   1
 ethernet hardware format

#define ARPOP_REQUEST   1
 request to resolve address

#define ARPOP_REPLY   2
 response to previous request

#define ETHERTYPE_IP   0x0008
 IP protocol.

#define ETHERTYPE_ARP   0x0608
 Address resolution protocol.

#define IPPROTO_IP   0
 Dummy for IP.

#define IPPROTO_ICMP   1
 Control message protocol.

#define IPPROTO_TCP   6
 Transmission control protocol.

#define IPPROTO_UDP   17
 User datagram protocol.

#define IPVERSION   4
 IP protocol version.

#define IP_DF   0x4000
 Don't fragment flag.

#define IP_MF   0x2000
 More fragments flag.

#define IP_OFFMASK   0x1fff
 Mask for fragmenting bits.


Typedefs

typedef ether_arp ETHERARP
 Ethernet ARP protocol type.

typedef ether_header ETHERHDR
 Ethernet protocol header type.

typedef udphdr UDPHDR
 UDP protocol header type.


Functions

int ArpRequest (u_long dip, u_char *dmac)
 Request the MAC address of a specified IP address.

void ArpRespond (void)
 Process incoming ARP packets.

void NicInit (void)
 Initialize the NIC.

int EtherOutput (u_char *dmac, u_short type, u_short len)
 Send an Ethernet frame.

int EtherInput (u_short type, u_short tms)
 Receive an Ethernet frame.

u_short IpChkSumPartial (u_short partial_csum, void *buf, u_short count)
 Calculates a partial IP checksum over a block of data.

u_short IpChkSum (u_short partial_csum, void *buf, u_short count)
 Calculates an the final IP checksum over a block of data.

int IpInput (u_char proto, u_short tms)
 Receive an IP packet with the specified protocol type.

int IpOutput (u_long dip, u_char proto, u_short len)
int UdpInput (u_short port, u_short tms)
 Receive an UDP datagram on a specified port.

int UdpOutput (u_long dip, u_short dport, u_short sport, u_short len)
 Send an UDP datagram.


Function Documentation

int ArpRequest u_long    dip,
u_char   dmac
 

Request the MAC address of a specified IP address.

Parameters:
dip  IP address in network byte order.
dmac  Points to the buffer, that will receive the MAC address.
Returns:
0 on success, -1 otherwise.

void ArpRespond void   
 

Process incoming ARP packets.

We do not really respond to ARP requests.

int EtherInput u_short    type,
u_short    tms
 

Receive an Ethernet frame.

Parameters:
tms  Return with timeout after the specified number of waiting loops. On a 14 Mhz ATmega this value represents approximately the number of milliseconds to wait.
Returns:
The number of bytes received, 0 on timeout or -1 in case of a failure.

int EtherOutput u_char   dmac,
u_short    type,
u_short    len
 

Send an Ethernet frame.

Parameters:
dmac  Destination MAC address.
type  Frame type.
len  Frame size.
Returns:
0 on success, -1 otherwise.

u_short IpChkSum u_short    partial_csum,
void *    buf,
u_short    count
 

Calculates an the final IP checksum over a block of data.

Unlike the partial checksum in NutIpChkSumPartial(), this function takes the one's complement of the final result, thus making it the full checksum.

u_short IpChkSumPartial u_short    partial_csum,
void *    buf,
u_short    count
 

Calculates a partial IP checksum over a block of data.

Note that this returns the checksum in network byte order, and thus does not need to be converted via hton16(), etc. Of course this means that we mustn't use this value for normal arithmetic!

This is a partial checksum because it doesn't take the 1's complement of the overall sum.

Note:
by Harald Kipp: Yes, it looks wrong. I assume that this will not work for all packet sizes. Not yet confirmed.

int IpInput u_char    proto,
u_short    tms
 

Receive an IP packet with the specified protocol type.

This function calls EtherInput(). Any incoming Ethernet frame, which is not of the specified type will be discarded.

Parameters:
proto  Protocol type.
tms  Return with timeout after the specified number of waiting loops. On a 14 Mhz ATmega this value represents approximately the number of milliseconds to wait.
Returns:
The number of bytes received, 0 on timeout or -1 in case of a failure.

int IpOutput u_long    dip,
u_char    proto,
u_short    len
 

Returns:
0 on success, -1 otherwise.

void NicInit void   
 

Initialize the NIC.

For further description of the initialization please refer to the original Ethernut code.

int UdpInput u_short    port,
u_short    tms
 

Receive an UDP datagram on a specified port.

This function calls IpInput(). Any incoming Ethernet frame, which is not an UDP datagram to the specified port will be discarded.

Parameters:
port  UDP port to listen to.
tms  Return with timeout after the specified number of waiting loops. On a 14 Mhz ATmega this value represents approximately the number of milliseconds to wait.
Returns:
The number of bytes received, 0 on timeout or -1 in case of a failure.

int UdpOutput u_long    dip,
u_short    dport,
u_short    sport,
u_short    len
 

Send an UDP datagram.

This function fills the UDP header of the global send frame and calls IpOutput().

Parameters:
dip  Destination IP address in network byte order.
dport  Destination port.
sport  Source port.
len  Number of data bytes to transmit.
Returns:
0 on success, -1 otherwise.


Generated on Thu Jan 30 22:30:58 2003 for EduNet by doxygen1.2.18