Revision: 14874
Author: adrian.chadd
Date: Sat Jul 9 08:09:10 2011
Log:
Code up some new functions which allow the v4 and v6 outgoing address
fields to be set.
I don't entirely like the direction this is heading - eg that TPROXY
may need to be set on V4 but not on V6 sockets, or vice versa - but
I can revisit all of this later.
http://code.google.com/p/lusca-cache/source/detail?r=14874
Modified:
/playpen/LUSCA_HEAD_ipv6/src/comm2.c
/playpen/LUSCA_HEAD_ipv6/src/comm2.h
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/comm2.c Sat Jul 9 07:49:03 2011
+++ /playpen/LUSCA_HEAD_ipv6/src/comm2.c Sat Jul 9 08:09:10 2011
@@ -81,6 +81,13 @@
cs->comm_flags = flags;
sqinet_init(&cs->in_addr6);
+ sqinet_init(&cs->lcl_addr4);
+ sqinet_init(&cs->lcl_addr6);
+
+ sqinet_set_family(&cs->lcl_addr4, AF_INET);
+ sqinet_set_family(&cs->lcl_addr6, AF_INET6);
+ sqinet_set_anyaddr(&cs->lcl_addr4);
+ sqinet_set_anyaddr(&cs->lcl_addr6);
/* Do we have a local address? Use it */
if (addr6 != NULL) {
@@ -95,6 +102,18 @@
return cs;
}
+void
+commConnectNewSetupOutgoingV4(ConnectStateDataNew *cs, struct in_addr lcl)
+{
+ sqinet_set_family(&cs->lcl_addr4, AF_INET);
+ sqinet_set_v4_inaddr(&cs->lcl_addr4, &lcl);
+}
+
+void
+commConnectNewSetupOutgoingV6(ConnectStateDataNew *cs, sqaddr_t *lcl)
+{
+ sqinet_copy(&cs->lcl_addr6, lcl);
+}
/*
* Attempt to connect to host:port.
@@ -134,7 +153,6 @@
commConnectCreateSocket(ConnectStateDataNew *cs)
{
int af;
- sqaddr_t a;
/* Does a socket exist? It shouldn't at this point. */
if (cs->fd != -1) {
@@ -148,13 +166,10 @@
/* Create a new socket for the given destination address */
af = sqinet_get_family(&cs->in_addr6);
- /* XXX there's not outgoing address support at the present moment
*/
- sqinet_init(&a);
- sqinet_set_family(&a, af);
- sqinet_set_anyaddr(&a);
- cs->fd = comm_open6(SOCK_STREAM, IPPROTO_TCP, &a,
+ /* Open with the correct local address */
+ cs->fd = comm_open6(SOCK_STREAM, IPPROTO_TCP, (af == AF_INET ?
+ &cs->lcl_addr4 : &cs->lcl_addr6),
cs->comm_flags | COMM_NONBLOCKING, cs->comm_tos,
cs->comm_note);
- sqinet_done(&a);
/* Did socket creation fail? Then pass it up the stack */
if (cs->fd == -1)
@@ -242,6 +257,8 @@
cbdataUnlock(cs->data);
safe_free(cs->host);
sqinet_done(&cs->in_addr6);
+ sqinet_done(&cs->lcl_addr4);
+ sqinet_done(&cs->lcl_addr6);
cbdataFree(cs);
}
=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/comm2.h Sat Jul 9 07:49:03 2011
+++ /playpen/LUSCA_HEAD_ipv6/src/comm2.h Sat Jul 9 08:09:10 2011
@@ -7,6 +7,8 @@
CNCB *callback;
void *data;
sqaddr_t in_addr6;
+ sqaddr_t lcl_addr4; /* outgoing_addr for v4 sockets */
+ sqaddr_t lcl_addr6; /* outgoing_addr for v6 sockets */
int fd;
int tries;
int addrcount;
@@ -21,5 +23,9 @@
int tos, const char *note);
extern void commConnectStartNewBegin(ConnectStateDataNew *cs);
+extern void commConnectNewSetupOutgoingV4(ConnectStateDataNew *cs,
+ struct in_addr lcl);
+extern void commConnectNewSetupOutgoingV6(ConnectStateDataNew *cs,
+ sqaddr_t *lcl);
#endif /* __SQUID_COMM2_H__ */
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.