Data Structures | |
struct | ifnet |
Network interface structure. More... | |
struct | ifnet |
Network interface structure. More... | |
Defines | |
#define | IP_DF 0x4000 |
Don't fragment flag. | |
#define | IP_MF 0x2000 |
More fragments flag. | |
#define | IP_OFFMASK 0x1fff |
Mask for fragmenting bits. | |
#define | IPDEFTTL 64 |
Default time to live. | |
#define | IPFRAGTTL 60 |
Time to live for fragments. | |
#define | IPOPT_EOL 0 |
End of option list. | |
#define | IPOPT_LSRR 131 |
Loose source route. | |
#define | IPOPT_MINOFF 4 |
Minimum offset within option. | |
#define | IPOPT_NOP 1 |
No operation. | |
#define | IPOPT_OFFSET 2 |
Offset within option. | |
#define | IPOPT_OLEN 1 |
Option length offset. | |
#define | IPOPT_OPTVAL 0 |
Option identifier offset. | |
#define | IPOPT_RR 7 |
Record packet route. | |
#define | IPOPT_SATID 136 |
Satnet id. | |
#define | IPOPT_SECURITY 130 |
Provide s,c,h,tcc. | |
#define | IPOPT_SSRR 137 |
Strict source route. | |
#define | IPOPT_TS 68 |
Timestamp. | |
#define | IPTTLDEC 1 |
Subtracted from time to live when forwarding. | |
#define | IPVERSION 4 |
IP protocol version. | |
#define | MAXTTL 255 |
Maximum time to live (seconds). | |
Typedefs | |
typedef ifnet | IFNET |
Network interface type. | |
Functions | |
struct | __attribute__ ((packed)) ip IPHDR |
Internet header type. | |
u_long | inet_addr (CONST char *str) |
Convert decimal dotted ASCII representation into numeric IP address. | |
char * | inet_ntoa (u_long addr) |
Convert numeric IP address into decimal dotted ASCII representation. | |
u_short | NutIpChkSum (u_short ics, CONST void *buf, size_t len) |
Calculates an the final IP checksum over a block of data. | |
u_short | NutIpChkSumPartial (u_short ics, CONST void *buf, size_t len) |
Calculate a partial IP checksum of a buffer. | |
void | NutIpInput (NUTDEVICE *dev, NETBUF *nb) |
Process incoming IP datagrams. | |
int | NutIpOutput (u_char proto, u_long dest, NETBUF *nb) |
Send IP datagram. | |
u_long | NutIpPseudoChkSumPartial (u_long src_addr, u_long dest_addr, u_char protocol, u_short len) |
Calculates the partial IP pseudo checksum. | |
int | NutIpRouteAdd (u_long ip, u_long mask, u_long gate, NUTDEVICE *dev) |
Add a new entry to the IP routing table. | |
int | NutIpRouteDel (u_long ip, u_long mask, u_long gate, NUTDEVICE *dev) |
Delete the specified route table entry. | |
int | NutIpRouteDelAll (NUTDEVICE *dev) |
Delete all route table entries for the given device. | |
RTENTRY * | NutIpRouteList (int *numEntries) |
Return an array of RTENTRY structures which contain all the current route table entries. | |
NUTDEVICE * | NutIpRouteQuery (u_long ip, u_long *gate) |
Find a device associated with a particular IP route. | |
void | NutIpSetInputFilter (NutIpFilterFunc callbackFunc) |
Set filter function for incoming IP datagrams. | |
int | NutNetIfConfig (CONST char *name, void *params, u_long ip_addr, u_long ip_mask) |
Configure a network interface. | |
int | NutNetIfConfig2 (CONST char *name, void *params, u_long ip_addr, u_long ip_mask, u_long gateway) |
Configure a network interface including the default gateway. | |
int | NutNetIfSetup (NUTDEVICE *dev, u_long ip_addr, u_long ip_mask, u_long gateway) |
Network interface setup. | |
Variables | |
RTENTRY * | rteList |
struct __attribute__ | ( | (packed) | ) |
Internet header type.
Once created, this structure will never change if it points to another directory. Except if the entry is removed.
< Packet opcode type: 1=request, 2=reply
< Hardware address type: 1=Ethernet
< Hardware address length: 6 for Ethernet
< Gateway hops
< Transaction ID
< Seconds since boot began
< RFC1532 broadcast, etc.
< Client IP address
< 'Your' IP address
< Server IP address
< Gateway IP address
< Client hardware address
< Server host name
< Boot file name
< Vendor-specific area
u_long inet_addr | ( | CONST char * | str | ) |
Convert decimal dotted ASCII representation into numeric IP address.
str | String containing the ASCII representation. |
char* inet_ntoa | ( | u_long | addr | ) |
Convert numeric IP address into decimal dotted ASCII representation.
addr | IP address in network byte order. |
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.
Calculate a partial IP checksum of a buffer.
The caller must create the one's complement of the final result.
ics | Initial checksum from previous parts. | |
buf | Pointer to the buffer. | |
len | Number of bytes in the buffer. |
Process incoming IP datagrams.
Datagrams addressed to other destinations and datagrams whose version number is not 4 are silently discarded.
dev | Identifies the device that received this datagram. | |
nb | The network buffer received. |
Send IP datagram.
Route an IP datagram to the proper interface.
The function will not return until the data has been stored in the network device hardware for transmission. If the device is not ready for transmitting a new packet, the calling thread will be suspended until the device becomes ready again. If the hardware address of the target host needs to be resolved the function will be suspended too.
proto | Protocol type. | |
dest | Destination IP address. The function will determine the proper network interface by checking the routing table. It will also perform any neccessary hardware address resolution. | |
nb | Network buffer structure containing the datagram. This buffer will be released if the function returns an error. |
Add a new entry to the IP routing table.
Note, that there is currently no support for detecting duplicates. Anyway, newer entries will be found first, because they are inserted in front of older entries. However, this works only for equal masks, i.e. new network routes will never overwrite old host routes.
ip | Network or host IP address to be routed. Set 0 for default route. | |
mask | Mask for this entry. -1 for host routes, 0 for default or net mask for net routes. | |
gate | Route through this gateway, otherwise 0. | |
dev | Network interface to use. |
Delete the specified route table entry.
All fields must exactly match an existing entry.
ip | Network or host IP address of the route entry. | |
mask | Mask for this entry. -1 for host routes, 0 for default or net mask for net routes. | |
gate | Route through this gateway, 0 for default gate. | |
dev | Network interface to use. |
int NutIpRouteDelAll | ( | NUTDEVICE * | dev | ) |
Delete all route table entries for the given device.
dev | Pointer to the device. If NULL, it deletes all route table entries. |
RTENTRY* NutIpRouteList | ( | int * | numEntries | ) |
Return an array of RTENTRY structures which contain all the current route table entries.
The calling function is responsible for deleting the array.
numEntries | Points to an integer, which receives the length of the array. |
Find a device associated with a particular IP route.
Gateway routes will be automatically resolved up to four levels of redirection.
ip | IP address to find a route for, given in network byte order. | |
gate | Points to a buffer which optionally receives the IP address of a gateway. The pointer may be NULL, if the caller is not interested in this information. |
void NutIpSetInputFilter | ( | NutIpFilterFunc | callbackFunc | ) |
Set filter function for incoming IP datagrams.
The callbackFunc is called by the IP layer on every incoming IP datagram. Thus it must not block. The implementer returns 0 for allow, -1 for deny.
It is recommended to set the filer after DHCP has done its thing, just in case your DHCP server is on a different subnet for example.
callbackFunc | Pointer to callback function to filter IP packets. Set to 0 to disable the filter again. |
Configure a network interface.
Devices must have been registered by NutRegisterDevice() before calling this function.
For Ethernet devices applications may alternatively call NutDhcpIfConfig(), which allows automatic configuration by DHCP or the so called ARP method.
name | Name of the device to configure. | |
params | Pointer to interface specific parameters. For Ethernet interfaces this parameter may be a pointer to a buffer containing the 6 byte long MAC address. This will override the MAC address stored in the non-volatile configuration memory. If this memory is uninitialized or not available, the MAC address must be specified. For PPP interfaces this parameter is ignored and should be set to zero. | |
ip_addr | Specified IP address in network byte order. This must be a unique address within the Internet. If you do not directly communicate with other Internet hosts, you can use a locally assigned address. With PPP interfaces this may be set to 0.0.0.0, in which case the remote peer will be queried for an IP address. | |
ip_mask | Specified IP network mask in network byte order. Typical Ethernet networks use 255.255.255.0, which allows upto 254 hosts. For PPP interfaces 255.255.255.255 is the default. |
int NutNetIfConfig2 | ( | CONST char * | name, | |
void * | params, | |||
u_long | ip_addr, | |||
u_long | ip_mask, | |||
u_long | gateway | |||
) |
Configure a network interface including the default gateway.
Devices must have been registered by NutRegisterDevice() before calling this function.
For Ethernet devices applications may alternatively call NutDhcpIfConfig(), which allows automatic configuration by DHCP or the so called ARP method.
name | Name of the device to configure. | |
params | Pointer to interface specific parameters. | |
ip_addr | Specified IP address in network byte order. This must be a unique address within the Internet. If you do not directly communicate with other Internet hosts, you can use a locally assigned address. With PPP interfaces this may be set to 0.0.0.0, in which case the remote peer will be queried for an IP address. | |
ip_mask | Specified IP network mask in network byte order. Typical Ethernet networks use 255.255.255.0, which allows upto 254 hosts. For PPP interfaces 255.255.255.255 is the default. | |
gateway | Specified IP address of gateway or next router in LAN. |
Network interface setup.
dev | Identifies the network device to setup. | |
ip_addr | Specified IP address in network byte order. | |
ip_mask | Specified IP network mask in network byte order. | |
gateway | Optional default gateway. |