SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
RAW sockets in layer 3 let the host application send and receive packets, which include the network header. When opening a RAW socket with UDP/TCP protocol, TCP/UDP packets are forwarded directly to the RAW socket, and any other UDP/TCP sockets are useless. Calling sl_SetSockOpt with the option SL_IP_HDRINCL must contain an IP header. IPv4 checksum is calculated and set by the SimpleLink device. The received packet includes the IP header. This socket type is not supported for IPv6.
Example:
#define MY_PROTOCOL 90
_i16 Sd, protocol = MY_PROTOCOL , Status;
_u32 IncludeIpHeader = 1;
Sd = sl_Socket(SL_AF_INET, SL_SOCK_RAW, protocol);
if( 0 > Sd )
{
// error
}
Status = sl_SetSockOpt(Sd, SL_IPPROTO_IP, SL_IP_HDRINCL, & IncludeIpHeader, sizeof(IncludeIpHeader));
if( Status )
{
// error
}