Browse code

- added bind_address (per process listen socket ip address)

Andrei Pelinescu-Onciul authored on 08/03/2002 02:26:58
Showing 4 changed files
... ...
@@ -24,8 +24,9 @@ extern int port_no_str_len;
24 24
 extern unsigned int maxbuffer;
25 25
 extern char * names[];
26 26
 extern int names_len[];
27
-extern unsigned long addresses[];
27
+extern unsigned int addresses[];
28 28
 extern int addresses_no;
29
+extern unsigned int bind_address;
29 30
 extern int children_no;
30 31
 extern int debug;
31 32
 extern int dont_fork;
... ...
@@ -194,10 +194,11 @@ char* chroot_dir = 0;
194 194
 int uid = 0;
195 195
 int gid = 0;
196 196
 
197
-char* names[MAX_LISTEN];               /* our names */
198
-int names_len[MAX_LISTEN];    /* lengths of the names*/
199
-unsigned long addresses[MAX_LISTEN];   /* our ips */
200
-int addresses_no=0;                    /* number of names/ips */
197
+char* names[MAX_LISTEN];              /* our names */
198
+int names_len[MAX_LISTEN];            /* lengths of the names*/
199
+unsigned int addresses[MAX_LISTEN];   /* our ips */
200
+int addresses_no=0;                   /* number of names/ips */
201
+unsigned int bind_address=0;          /* listen address of the crt. process */
201 202
 
202 203
 /* ipc related globals */
203 204
 int process_no = 0;
... ...
@@ -41,6 +41,7 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
41 41
 	msg->buf=buf;
42 42
 	msg->len=len;
43 43
 	msg->src_ip=src_ip;
44
+	msg->dst_ip=bind_address; /* won't work if listening on 0.0.0.0 */
44 45
 	msg->id=msg_no;
45 46
 	/* make a copy of the message */
46 47
 	msg->orig=(char*) pkg_malloc(len+1);
... ...
@@ -120,6 +120,7 @@ int udp_init(unsigned long ip, unsigned short port)
120 120
 	addr->sin_port=htons(port);
121 121
 	addr->sin_addr.s_addr=ip;
122 122
 
123
+	
123 124
 	udp_sock = socket(PF_INET, SOCK_DGRAM, 0);
124 125
 	if (udp_sock==-1){
125 126
 		LOG(L_ERR, "ERROR: udp_init: socket: %s\n", strerror(errno));
... ...
@@ -135,7 +136,7 @@ int udp_init(unsigned long ip, unsigned short port)
135 135
 	}
136 136
 
137 137
 	if ( probe_max_receive_buffer(udp_sock)==-1) goto error;
138
-
138
+	bind_address=ip;
139 139
 
140 140
 	if (bind(udp_sock, (struct sockaddr*) addr, sizeof(struct sockaddr))==-1){
141 141
 		LOG(L_ERR, "ERROR: udp_init: bind: %s\n", strerror(errno));