ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/vpn.C
(Generate patch)

Comparing gvpe/src/vpn.C (file contents):
Revision 1.33 by pcg, Wed Mar 23 21:55:39 2005 UTC vs.
Revision 1.36 by pcg, Fri Apr 8 16:48:16 2005 UTC

58 mtu -= mtu % EVP_CIPHER_block_size (CIPHER); // round 58 mtu -= mtu % EVP_CIPHER_block_size (CIPHER); // round
59 mtu -= ETH_OVERHEAD - 6 - 6; // and get interface mtu again 59 mtu -= ETH_OVERHEAD - 6 - 6; // and get interface mtu again
60 60
61 char *env; 61 char *env;
62 asprintf (&env, "CONFBASE=%s", confbase); putenv (env); 62 asprintf (&env, "CONFBASE=%s", confbase); putenv (env);
63 asprintf (&env, "NODENAME=%s", THISNODE->nodename); putenv (env);
64 asprintf (&env, "NODEID=%d", THISNODE->id); putenv (env);
65 asprintf (&env, "IFNAME=%s", tap->interface ()); putenv (env); 63 asprintf (&env, "IFNAME=%s", tap->interface ()); putenv (env);
66 asprintf (&env, "IFTYPE=%s", IFTYPE); putenv (env); 64 asprintf (&env, "IFTYPE=%s", IFTYPE); putenv (env);
67 asprintf (&env, "IFSUBTYPE=%s", IFSUBTYPE); putenv (env); 65 asprintf (&env, "IFSUBTYPE=%s", IFSUBTYPE); putenv (env);
68 asprintf (&env, "MTU=%d", mtu); putenv (env); 66 asprintf (&env, "MTU=%d", mtu); putenv (env);
69 asprintf (&env, "MAC=%02x:%02x:%02x:%02x:%02x:%02x", 67 asprintf (&env, "NODES=%d", conns.size ()); putenv (env);
70 0xfe, 0xfd, 0x80, 0x00, THISNODE->id >> 8, 68 asprintf (&env, "NODEID=%d", THISNODE->id); putenv (env);
71 THISNODE->id & 0xff); putenv (env);
72 69
73 // TODO: info for other nodes, maybe? 70 conns [THISNODE->id - 1]->script_init_env ("");
71
72 for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c)
73 {
74 char ext[16];
75 snprintf (ext, 16, "_%d", (*c)->conf->id);
76 (*c)->script_init_env (ext);
77 }
74} 78}
75 79
76const char *vpn::script_if_init () 80const char *vpn::script_if_init ()
77{ 81{
78 script_init_env (); 82 script_init_env ();
193 // this I really consider a linux bug. I am neither connected 197 // this I really consider a linux bug. I am neither connected
194 // nor do I fragment myself. Linux still sets DF and doesn't 198 // nor do I fragment myself. Linux still sets DF and doesn't
195 // fragment for me sometimes. 199 // fragment for me sometimes.
196 { 200 {
197 int oval = IP_PMTUDISC_DONT; 201 int oval = IP_PMTUDISC_DONT;
198 setsockopt (udpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval); 202 setsockopt (icmpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
199 } 203 }
200#endif 204#endif
201 205
202 sockinfo si (THISNODE, PROT_ICMPv4); 206 sockinfo si (THISNODE, PROT_ICMPv4);
203 207
255 dnsv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); 259 dnsv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
256 260
257 if (dnsv4_fd < 0) 261 if (dnsv4_fd < 0)
258 return -1; 262 return -1;
259 263
260#if defined(SOL_IP) && defined(IP_MTU_DISCOVER) 264# if defined(SOL_IP) && defined(IP_MTU_DISCOVER)
261 // this I really consider a linux bug. I am neither connected 265 // this I really consider a linux bug. I am neither connected
262 // nor do I fragment myself. Linux still sets DF and doesn't 266 // nor do I fragment myself. Linux still sets DF and doesn't
263 // fragment for me sometimes. 267 // fragment for me sometimes.
264 { 268 {
265 int oval = IP_PMTUDISC_DONT; 269 int oval = IP_PMTUDISC_DONT;
266 setsockopt (udpv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval); 270 setsockopt (dnsv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
267 } 271 }
268#endif 272# endif
269 273
270 // standard daemon practise... 274 // standard daemon practise...
271 { 275 {
272 int oval = 1; 276 int oval = 1;
273 setsockopt (dnsv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval); 277 setsockopt (dnsv4_fd, SOL_SOCKET, SO_REUSEADDR, &oval, sizeof oval);
285 289
286 dnsv4_ev_watcher.start (dnsv4_fd, EVENT_READ); 290 dnsv4_ev_watcher.start (dnsv4_fd, EVENT_READ);
287 } 291 }
288#endif 292#endif
289 293
294 /////////////////////////////////////////////////////////////////////////////
295
296 reconnect_all ();
297
298 /////////////////////////////////////////////////////////////////////////////
299
290 tap = new tap_device (); 300 tap = new tap_device ();
291 if (!tap) //D this, of course, never catches 301 if (!tap) //D this, of course, never catches
292 { 302 {
293 slog (L_ERR, _("cannot create network interface '%s'"), conf.ifname); 303 slog (L_ERR, _("cannot create network interface '%s'"), conf.ifname);
294 exit (EXIT_FAILURE); 304 exit (EXIT_FAILURE);
307 slog (L_ERR, _("if-up command execution failed, exiting.")); 317 slog (L_ERR, _("if-up command execution failed, exiting."));
308 exit (EXIT_FAILURE); 318 exit (EXIT_FAILURE);
309 } 319 }
310 320
311 tap_ev_watcher.start (tap->fd, EVENT_READ); 321 tap_ev_watcher.start (tap->fd, EVENT_READ);
312
313 reconnect_all ();
314 322
315 return 0; 323 return 0;
316} 324}
317 325
318bool 326bool

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines