Commit ece6e28e453e8361b583570d95594fefb40f7647
#ifdef IP_BINDANY/IPV6_BINDANY cases
Ruben van Staveren committed on 7/24/2014, 3:29:53 PMParent: 0d8e2438de261523952af08263f4c0c2a763a4b9
Files changed
common.c | changed |
common.c | ||
---|---|---|
@@ -119,15 +119,22 @@ | ||
119 | 119 | /* getpeername can fail with ENOTCONN if connection was dropped before we |
120 | 120 | * got here */ |
121 | 121 | res = getpeername(fd_from, from.ai_addr, &from.ai_addrlen); |
122 | 122 | CHECK_RES_RETURN(res, "getpeername"); |
123 | + | |
124 | + res = setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &trans, sizeof(trans)); | |
125 | + CHECK_RES_DIE(res, "setsockopt"); | |
126 | + | |
123 | 127 | if (from.ai_addr->sa_family==AF_INET) { /* IPv4 */ |
124 | 128 | 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 | + | |
126 | 131 | } else { /* IPv6 */ |
127 | 132 | 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 | + | |
129 | 135 | } |
136 | + | |
130 | 137 | res = bind(fd, from.ai_addr, from.ai_addrlen); |
131 | 138 | CHECK_RES_RETURN(res, "bind"); |
132 | 139 | |
133 | 140 | return 0; |
@@ -159,9 +166,9 @@ | ||
159 | 166 | fprintf(stderr, "connecting to %s family %d len %d\n", |
160 | 167 | sprintaddr(buf, sizeof(buf), a), |
161 | 168 | a->ai_addr->sa_family, a->ai_addrlen); |
162 | 169 | |
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! */ | |
164 | 171 | fd = socket(a->ai_family, SOCK_STREAM, 0); |
165 | 172 | if (fd == -1) { |
166 | 173 | log_message(LOG_ERR, "forward to %s failed:socket: %s\n", |
167 | 174 | cnx->proto->description, strerror(errno)); |
Built with git-ssb-web