Browse Source

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

STABLE-2_1_x
goldsimon 19 years ago
parent
commit
ea7b0052f3
  1. 4
      CHANGELOG
  2. 17
      src/api/sockets.c
  3. 3
      src/include/lwip/sockets.h

4
CHANGELOG

@ -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

17
src/api/sockets.c

@ -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;

3
src/include/lwip/sockets.h

@ -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…
Cancel
Save