Implemented socket options SO_NO_CHECK for UDP sockets to disable UDP checksum generation on transmit.

This commit is contained in:
goldsimon 2007-06-17 11:46:30 +00:00
parent 1db9013bc4
commit ea7b0052f3
3 changed files with 23 additions and 1 deletions

View File

@ -19,6 +19,10 @@ HISTORY
++ New features: ++ New features:
2007-06-17 Simon Goldschmidt
* sockets.c, sockets.h: Implemented socket options SO_NO_CHECK for UDP sockets
to disable UDP checksum generation on transmit.
2007-06-13 Frédéric Bernon, Simon Goldschmidt 2007-06-13 Frédéric Bernon, Simon Goldschmidt
* debug.h, api_msg.c: change LWIP_ERROR to use it to check errors like invalid * debug.h, api_msg.c: change LWIP_ERROR to use it to check errors like invalid
pointers or parameters, and let the possibility to redefined it in cc.h. Use pointers or parameters, and let the possibility to redefined it in cc.h. Use

View File

@ -1338,6 +1338,16 @@ int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t
err = EINVAL; err = EINVAL;
} }
break; break;
case SO_NO_CHECK:
if (optlen < sizeof(int)) {
err = EINVAL;
}
if ((sock->conn->type != NETCONN_UDP) ||
((sock->conn->pcb.udp->flags & UDP_FLAGS_UDPLITE) == 1)) {
/* this flag is only available for UDP, not for UDP lite */
err = EAFNOSUPPORT;
}
break;
default: default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
s, optname)); s, optname));
@ -1512,6 +1522,13 @@ static void lwip_setsockopt_internal(void *arg)
sock->conn->recv_timeout = ( *(int*)optval ); sock->conn->recv_timeout = ( *(int*)optval );
break; break;
#endif /* LWIP_SO_RCVTIMEO */ #endif /* LWIP_SO_RCVTIMEO */
case SO_NO_CHECK:
if (*(int*)optval) {
udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_NOCHKSUM);
} else {
udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_NOCHKSUM);
}
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;

View File

@ -94,6 +94,7 @@ struct sockaddr {
#define SO_ERROR 0x1007 /* get error status and clear */ #define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */ #define SO_TYPE 0x1008 /* get socket type */
#define SO_CONTIMEO 0x1009 /* connect timeout */ #define SO_CONTIMEO 0x1009 /* connect timeout */
#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
/* /*
@ -150,7 +151,7 @@ struct linger {
*/ */
#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ #define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ #define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
#endif #endif /* LWIP_UDP && LWIP_UDPLITE*/
#if LWIP_IGMP #if LWIP_IGMP