git ssb

0+

cel / sslh



Commit ece6e28e453e8361b583570d95594fefb40f7647

#ifdef IP_BINDANY/IPV6_BINDANY cases

Ruben van Staveren committed on 7/24/2014, 3:29:53 PM
Parent: 0d8e2438de261523952af08263f4c0c2a763a4b9

Files changed

common.cchanged
common.cView
@@ -119,15 +119,22 @@
119119 /* getpeername can fail with ENOTCONN if connection was dropped before we
120120 * got here */
121121 res = getpeername(fd_from, from.ai_addr, &from.ai_addrlen);
122122 CHECK_RES_RETURN(res, "getpeername");
123+#ifndef IP_BINDANY /* use IP_TRANSPARENT */
124+ res = setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &trans, sizeof(trans));
125+ CHECK_RES_DIE(res, "setsockopt");
126+#else
123127 if (from.ai_addr->sa_family==AF_INET) { /* IPv4 */
124128 res = setsockopt(fd, IPPROTO_IP, IP_BINDANY, &trans, sizeof(trans));
125- CHECK_RES_RETURN(res, "setsockopt IP_BINDANY");
129+ CHECK_RES_RETURN(res, "setsockopt IP_BINDANY");
130+#ifdef IPV6_BINDANY
126131 } else { /* IPv6 */
127132 res = setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &trans, sizeof(trans));
128- CHECK_RES_RETURN(res, "setsockopt IPV6_BINDANY");
133+ CHECK_RES_RETURN(res, "setsockopt IPV6_BINDANY");
134+#endif /* IPV6_BINDANY */
129135 }
136+#endif /* IP_TRANSPARENT / IP_BINDANY */
130137 res = bind(fd, from.ai_addr, from.ai_addrlen);
131138 CHECK_RES_RETURN(res, "bind");
132139
133140 return 0;
@@ -159,9 +166,9 @@
159166 fprintf(stderr, "connecting to %s family %d len %d\n",
160167 sprintaddr(buf, sizeof(buf), a),
161168 a->ai_addr->sa_family, a->ai_addrlen);
162169
163- /* XXX Needs to match ai_family from fd_from when being transparent! */
170+ /* XXX Needs to match ai_family from fd_from when being transparent! */
164171 fd = socket(a->ai_family, SOCK_STREAM, 0);
165172 if (fd == -1) {
166173 log_message(LOG_ERR, "forward to %s failed:socket: %s\n",
167174 cnx->proto->description, strerror(errno));

Built with git-ssb-web