#include "net\mac.h"
Data Structures | |
union | _IP_ADDR |
struct | _IP_HEADER |
struct | _NODE_INFO |
Defines | |
#define | IP_PROT_ICMP (1ul) |
#define | IP_PROT_TCP (6ul) |
#define | IP_PROT_UDP (17ul) |
#define | IPDiscard() MACDiscard() |
#define | IPGetArray(a, b) MACGetArray(a, b) |
#define | IPIsTxReady(HighPriority) MACIsTxReady(HighPriority) |
#define | IPPutArray(a, b) MACPutArray(a, b) |
#define | IPSetTxBuffer(buffer, offset) MACSetTxBuffer(buffer, offset+sizeof(IP_HEADER)) |
#define | MY_IP_TTL (100ul) |
Typedefs | |
typedef union _IP_ADDR | IP_ADDR |
typedef struct _IP_HEADER | IP_HEADER |
typedef struct _NODE_INFO | NODE_INFO |
Functions | |
BOOL | IPGetHeader (IP_ADDR *localIP, NODE_INFO *remote, BYTE *protocol, WORD *len) |
WORD | IPPutHeader (NODE_INFO *remote, BYTE protocol, WORD len) |
void | IPSetRxBuffer (WORD offset) |
//********************************************************************* //-------------------- IP Configuration -------------------- //********************************************************************* //Time-To-Live in Seconds #define MY_IP_TTL (100ul) //When defined, the code will be compiled for optimal speed. If not defined, code is defined //for smallest size. #define IP_SPEED_OPTIMIZE
#define IP_PROT_ICMP (1ul) |
#define IP_PROT_TCP (6ul) |
#define IP_PROT_UDP (17ul) |
#define IPDiscard | ( | ) | MACDiscard() |
#define IPGetArray | ( | a, | |||
b | ) | MACGetArray(a, b) |
Data is copied from IP data to given buffer
a | Data buffer | |
b | Buffer length |
#define IPIsTxReady | ( | HighPriority | ) | MACIsTxReady(HighPriority) |
Check if ready for next transmission.
HighPriority | High priority messages are those that don't need to be acknowledged before being discarded (TCP control packets, all ICMP packets, all UDP packets, etc.) |
#define IPPutArray | ( | a, | |||
b | ) | MACPutArray(a, b) |
Data is copied to IP data area.
a | Data buffer | |
b | Buffer length |
#define IPSetTxBuffer | ( | buffer, | |||
offset | ) | MACSetTxBuffer(buffer, offset+sizeof(IP_HEADER)) |
This function makes the given transmit buffer active, and sets it's access pointer to be:
buffer | Buffer identifier | |
offset | Offset |
#define MY_IP_TTL (100ul) |
typedef struct _IP_HEADER IP_HEADER |
IP packet header definition
typedef struct _NODE_INFO NODE_INFO |
Structure to store a nodes info
Only one IP message can be received. Caller may not transmit and receive a message at the same time. If this function returns false, the caller must call MACDiscardRx() to discard and release the current receive buffer!
localIP | Local node IP Address (Destination IP Address) as received in current IP header. If this information is not required caller may pass NULL value. | |
remote | Remote node info | |
protocol | Current packet protocol | |
len | Length of IP data. For example, if TCP is contained in this IP packet, this will be = TCP Header length + TCP Data Length |
Write the Ethernet Header (MAC Header) and IP Header to the current TX buffer. The last parameter (len) is the length of the data to follow. This function will do the following:
remote | Destination node address | |
protocol | Protocol of data to follow, for example IP_PROT_ICMP, IP_PROT_TCP.... | |
len | Total length of IP data bytes to follow, excluding IP header. This is the length of the bytes to follow. |
void IPSetRxBuffer | ( | WORD | offset | ) |
Sets the receive buffer access pointer to given offset in IP Data. For example, if IP data is a TCP packet, an offset of 0 will set access to first byte of TCP header. Layers that use IP services (TCP, UDP...) should call this macro to set the access pointer for the current buffer.
offset | Offset, An offset with respect to IP Data |