summaryrefslogtreecommitdiffstats
path: root/lib/socket_wrapper/socket_wrapper.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-06-03 14:54:28 +0200
committerMichael Adam <obnox@samba.org>2014-06-05 23:57:09 +0200
commited3c219ec5cfd2c491296c753202275d46e488d4 (patch)
tree702bc03de974156cda1c070ea2bc2472c5840550 /lib/socket_wrapper/socket_wrapper.c
parent1921da49c29724df3a51bb8039e99749466bd0de (diff)
downloadsamba-ed3c219ec5cfd2c491296c753202275d46e488d4.tar.gz
samba-ed3c219ec5cfd2c491296c753202275d46e488d4.tar.xz
samba-ed3c219ec5cfd2c491296c753202275d46e488d4.zip
swrap: Add IP_PKTINFO support in setsockopt.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/socket_wrapper/socket_wrapper.c')
-rw-r--r--lib/socket_wrapper/socket_wrapper.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 4bca74624a2..e1b69fa94b1 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -119,6 +119,12 @@ enum swrap_dbglvl_e {
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
#endif
+#ifdef IPV6_PKTINFO
+# ifndef IPV6_RECVPKTINFO
+# define IPV6_RECVPKTINFO IPV6_PKTINFO
+# endif /* IPV6_RECVPKTINFO */
+#endif /* IPV6_PKTINFO */
+
#define SWRAP_DLIST_ADD(list,item) do { \
if (!(list)) { \
(item)->prev = NULL; \
@@ -199,6 +205,7 @@ struct socket_info
int is_server;
int connected;
int defer_connect;
+ int pktinfo;
char *tmp_path;
@@ -2872,9 +2879,23 @@ static int swrap_setsockopt(int s, int level, int optname,
switch (si->family) {
case AF_INET:
+ if (level == IPPROTO_IP) {
+#ifdef IP_PKTINFO
+ if (optname == IP_PKTINFO) {
+ si->pktinfo = AF_INET;
+ }
+#endif /* IP_PKTINFO */
+ }
return 0;
#ifdef HAVE_IPV6
case AF_INET6:
+ if (level == IPPROTO_IPV6) {
+#ifdef IPV6_RECVPKTINFO
+ if (optname == IPV6_RECVPKTINFO) {
+ si->pktinfo = AF_INET6;
+ }
+#endif /* IPV6_PKTINFO */
+ }
return 0;
#endif
default: