TCPIP_IPV4_PacketAlloc Function
C
IPV4_PACKET* TCPIP_IPV4_PacketAlloc(
uint16_t pktPayload,
TCPIP_IPV4_OPTION_DCPT* pOptions,
int nOptions,
TCPIP_MAC_PACKET_FLAGS flags
);
Description
The function is a helper to allocate an IPv4 packet that supports options. For fixed size options, the size of the options is determined by its type and the supplied size is ignored.
Preconditions
IPv4 properly initialized.
Parameters
Parameters | Description |
---|---|
PktPayload | The packet payload. |
pOptions | Pointer to an array of option descriptors to be part of this packet. |
nOptions | Number of supplied options. |
flags | Standard MAC packet flags. |
Returns
A valid IPV4_PACKET - If the allocation succeeded.
0 - The packet cannot be allocated.
Remarks
If the option type contains a fixed option length for a supported type (TCPIP_IPV4_OPTION_ROUTER_ALERT, for ex.), then the size of the the fixed option is calculated internally and the supplied option size is ignored.
For not supported or variable size options the supplied optionLen bytes will be added to the allocated packet.