Select one of the symbols to view example projects that use it.
 
Outline
#include "lwip/sockets.h"
#include "lwip/priv/sockets_priv.h"
#include "lwip/api.h"
#include "lwip/sys.h"
#include "lwip/tcp.h"
#include "lwip/raw.h"
#include "lwip/udp.h"
lwip_setsockopt_impl_ext(struct lwip_sock *, int, int, const void *, socklen_t, int *)
lwip_getsockopt_impl_ext(struct lwip_sock *, int, int, void *, uint32_t *, int *)
Files
loading...
SourceVuESP-IDF Framework and ExampleslwIPport/sockets_ext.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include "lwip/sockets.h" #include "lwip/priv/sockets_priv.h" #include "lwip/api.h" #include "lwip/sys.h" #include "lwip/tcp.h" #include "lwip/raw.h" #include "lwip/udp.h"7 includes #define LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, opttype) do { \ if (((optlen) < sizeof(opttype)) || ((sock)->conn == NULL) || ((sock)->conn->pcb.tcp == NULL)) { *err=EINVAL; goto exit; } }{...}while(0)... #define LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, opttype, netconntype) do { \ LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, optlen, opttype); \ if (NETCONNTYPE_GROUP(netconn_type((sock)->conn)) != netconntype) { *err=ENOPROTOOPT; goto exit; } }{...} while(0)... bool lwip_setsockopt_impl_ext(struct lwip_sock* sock, int level, int optname, const void *optval, socklen_t optlen, int *err) { #if LWIP_IPV6 if (level != IPPROTO_IPV6) #endif /* LWIP_IPV6 */ { return false; }{...} #if LWIP_IPV6 switch (optname) { default: return false;... case IPV6_MULTICAST_IF: /* NB: like IP_MULTICAST_IF, this takes an IP not an index */ { LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, u8_t, NETCONN_UDP); udp_set_multicast_netif_index(sock->conn->pcb.udp, (u8_t)(*(const u8_t*)optval)); }{...} break;... case IPV6_MULTICAST_HOPS: LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, u8_t, NETCONN_UDP); udp_set_multicast_ttl(sock->conn->pcb.udp, (u8_t)(*(const u8_t*)optval)); break;... case IPV6_MULTICAST_LOOP: LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, u8_t, NETCONN_UDP); if (*(const u8_t*)optval) { udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) | UDP_FLAGS_MULTICAST_LOOP); }{...} else { udp_setflags(sock->conn->pcb.udp, udp_flags(sock->conn->pcb.udp) & ~UDP_FLAGS_MULTICAST_LOOP); }{...} break;... }{...} exit: return true;/* ... */ #endif /* LWIP_IPV6 */ }{ ... } bool lwip_getsockopt_impl_ext(struct lwip_sock* sock, int level, int optname, void *optval, uint32_t *optlen, int *err) { #if LWIP_IPV6 if (level != IPPROTO_IPV6) #endif /* LWIP_IPV6 */ { return false; }{...} #if LWIP_IPV6 switch (optname) { default: return false;... case IPV6_MULTICAST_IF: /* NB: like IP_MULTICAST_IF, this returns an IP not an index */ LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, u8_t); if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) { *err = ENOPROTOOPT; goto exit; }{...} *(u8_t*)optval = udp_get_multicast_netif_index(sock->conn->pcb.udp); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt_ext(IPPROTO_IPV6, IPV6_MULTICAST_IF) = 0x%"X32_F"\n", *(u32_t *)optval)); break;... case IPV6_MULTICAST_HOPS: printf("IPV6_MULTICAST_HOPS\n"); LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, u8_t); if (NETCONNTYPE_GROUP(netconn_type(sock->conn)) != NETCONN_UDP) { *err = ENOPROTOOPT; goto exit; }{...} *(u8_t*)optval = udp_get_multicast_ttl(sock->conn->pcb.udp); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt_ext(IPPROTO_IPV6, IP_MULTICAST_LOOP) = %d\n", *(int *)optval)); break;... case IPV6_MULTICAST_LOOP: LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB(sock, *optlen, u8_t); if ((udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_MULTICAST_LOOP) != 0) { *(u8_t*)optval = 1; }{...} else { *(u8_t*)optval = 0; }{...} LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt_ext(IPPROTO_IPV6, IP_MULTICAST_LOOP) = %d\n", *(int *)optval)); break;... }{...} exit: return true;/* ... */ #endif /* LWIP_IPV6 */ }{ ... }
Details