Nut/OS  4.10.3
API Reference
ICMP

RFC 792 Internet Control Message Protocol. More...

Collaboration diagram for ICMP:

Functions

void NutIcmpInput (NUTDEVICE *dev, NETBUF *nb)
 Handle incoming ICMP packets.
int NutIcmpOutput (uint8_t type, uint32_t dest, NETBUF *nb)
 Send an ICMP datagram.
int NutIcmpReply (uint8_t type, uint8_t code, uint32_t spec, uint32_t dest, NETBUF *nb)
 Send an ICMP message to a given destination.
int NutIcmpResponse (uint8_t type, uint8_t code, uint32_t spec, NETBUF *nb)
 Send an ICMP message as a response to a given destination.

Detailed Description

RFC 792 Internet Control Message Protocol.

Provides routing, diagnostic and error functionality for IP. Although ICMP messages are encapsulated within IP datagrams, ICMP processing is considered to be part of the IP layer.

There is currently no API support for this layer.


Function Documentation

void NutIcmpInput ( NUTDEVICE dev,
NETBUF nb 
)

Handle incoming ICMP packets.

Incoming ICMP packets are processed in the background. NutNet currently handles echo request and destination unreachable packets. Any other packet type is silently discarded.

Note:
This routine is called by the IP layer on incoming ICMP datagrams. Applications typically do not call this function.
Parameters:
devIdentifies the device that received the packet.
nbPointer to a network buffer structure containing the ICMP datagram.

Definition at line 261 of file icmpin.c.

References icmp::icmp_code, ICMP_ECHO, ICMP_ECHOREPLY, icmp::icmp_type, ICMP_UNREACH, _NETBUF::nb_ap, _NETBUF::nb_tp, NutNetBufFree(), _NBDATA::sz, and _NBDATA::vp.

Referenced by NutIpInput().

Here is the call graph for this function:

int NutIcmpOutput ( uint8_t  type,
uint32_t  dest,
NETBUF nb 
)

Send an ICMP datagram.

Known ICMP types are:

Parameters:
typeType of the ICMP message.
destDestination IP address.
nbNetwork buffer structure containing the datagram.
Returns:
0 on success, -1 otherwise.

Definition at line 159 of file icmpout.c.

References icmp::icmp_cksum, icmp::icmp_type, IPPROTO_ICMP, _NETBUF::nb_ap, _NETBUF::nb_tp, NutIpChkSum(), NutIpChkSumPartial(), NutIpOutput(), _NBDATA::sz, and _NBDATA::vp.

Referenced by NutIcmpReply().

Here is the call graph for this function:

int NutIcmpReply ( uint8_t  type,
uint8_t  code,
uint32_t  spec,
uint32_t  dest,
NETBUF nb 
)

Send an ICMP message to a given destination.

Parameters:
typeType of the ICMP message. See NutIcmpOutput() for a list of valid types.
codeType subcode.
specType specific data item.
destIP address of the target.
nbNetwork buffer structure containing the message to be sent. The structure must have been allocated by a previous call NutNetBufAlloc() and will be freed if this function returns with an error.
Returns:
0 on success, -1 otherwise.

Definition at line 189 of file icmpout.c.

References icmp::icmp_code, icmp::icmp_spec, _NETBUF::nb_tp, NBAF_TRANSPORT, NutIcmpOutput(), NutNetBufAlloc(), and _NBDATA::vp.

Referenced by NutIcmpResponse().

Here is the call graph for this function:

int NutIcmpResponse ( uint8_t  type,
uint8_t  code,
uint32_t  spec,
NETBUF nb 
)

Send an ICMP message as a response to a given destination.

Parameters:
typeType of the ICMP message. See NutIcmpOutput() for a list of valid types.
codeType subcode.
specType specific data item.
nbNetwork buffer structure containing the previously recevied network packet. According to RFC792 the complete ip header and the first 8 bytes of the transport netbuf is used as the application data for the response. If this function returns with an error, the buffer is freed. The destination addess is taken from the ip header.
Returns:
0 on success, -1 otherwise.

Definition at line 219 of file icmpout.c.

References ip::ip_src, memcpy(), _NETBUF::nb_ap, _NETBUF::nb_nw, _NETBUF::nb_tp, NBAF_APPLICATION, NutIcmpReply(), NutNetBufAlloc(), and _NBDATA::vp.

Referenced by NutIpInput(), and NutUdpInput().

Here is the call graph for this function: