mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-30 12:32:37 +00:00
Implemented socket options SO_NO_CHECK for UDP sockets to disable UDP checksum generation on transmit.
This commit is contained in:
parent
1db9013bc4
commit
ea7b0052f3
@ -19,6 +19,10 @@ HISTORY
|
||||
|
||||
++ 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
|
||||
* 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
|
||||
|
@ -1338,6 +1338,16 @@ int lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t
|
||||
err = EINVAL;
|
||||
}
|
||||
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:
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n",
|
||||
s, optname));
|
||||
@ -1512,6 +1522,13 @@ static void lwip_setsockopt_internal(void *arg)
|
||||
sock->conn->recv_timeout = ( *(int*)optval );
|
||||
break;
|
||||
#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) */
|
||||
break;
|
||||
|
||||
|
@ -94,6 +94,7 @@ struct sockaddr {
|
||||
#define SO_ERROR 0x1007 /* get error status and clear */
|
||||
#define SO_TYPE 0x1008 /* get socket type */
|
||||
#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_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
|
||||
#endif
|
||||
#endif /* LWIP_UDP && LWIP_UDPLITE*/
|
||||
|
||||
|
||||
#if LWIP_IGMP
|
||||
|
Loading…
x
Reference in New Issue
Block a user