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

Comparing gvpe/src/vpn_tcp.C (file contents):
Revision 1.20 by pcg, Sat Dec 1 23:35:31 2007 UTC vs.
Revision 1.22 by pcg, Sun Dec 2 00:45:42 2007 UTC

57 { 57 {
58 return *a < *b; 58 return *a < *b;
59 } 59 }
60}; 60};
61 61
62struct tcp_si_map : public map<const sockinfo *, tcp_connection *, lt_sockinfo> { 62struct tcp_si_map : public map<const sockinfo *, tcp_connection *, lt_sockinfo>
63{
63 void cleaner_cb (ev::timer &w, int revents); ev::timer cleaner; 64 void cleaner_cb (ev::timer &w, int revents); ev::timer cleaner;
64 65
65 tcp_si_map () 66 tcp_si_map ()
66 : cleaner(this, &tcp_si_map::cleaner_cb) 67 : cleaner(this, &tcp_si_map::cleaner_cb)
67 { 68 {
68 cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2); 69 cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2);
69 } 70 }
70 71
71} tcp_si; 72} tcp_si;
72 73
73struct tcp_connection : ev::io { 74struct tcp_connection : ev::io
75{
76 int tos;
74 tstamp last_activity; 77 tstamp last_activity;
75 const sockinfo si; 78 const sockinfo si;
76 vpn &v; 79 vpn &v;
77 bool active; // this connection has been actively established 80 bool active; // this connection has been actively established
78 enum { ERROR, IDLE, CONNECTING, CONNECTING_PROXY, ESTABLISHED } state; 81 enum { ERROR, IDLE, CONNECTING, CONNECTING_PROXY, ESTABLISHED } state;
409 if (!w_pkt) 412 if (!w_pkt)
410 { 413 {
411 // how this maps to the underlying tcp packets we don't know 414 // how this maps to the underlying tcp packets we don't know
412 // and we don't care. at least we tried ;) 415 // and we don't care. at least we tried ;)
413#if defined(SOL_IP) && defined(IP_TOS) 416#if defined(SOL_IP) && defined(IP_TOS)
417 if (tos != this->tos)
418 {
419 this->tos = tos;
414 setsockopt (fd, SOL_IP, IP_TOS, &tos, sizeof tos); 420 setsockopt (fd, SOL_IP, IP_TOS, &tos, sizeof tos);
421 }
415#endif 422#endif
416 423
417 w_pkt = pkt; 424 w_pkt = pkt;
418 w_ofs = 0; 425 w_ofs = 0;
419 w_len = pkt->len + 2; // length + size header 426 w_len = pkt->len + 2; // length + size header
438 stop (); 445 stop ();
439 446
440 if (fd >= 0) 447 if (fd >= 0)
441 { 448 {
442 close (fd); 449 close (fd);
450 tos = -1;
443 fd = -1; 451 fd = -1;
444 } 452 }
445 453
446 delete r_pkt; r_pkt = 0; 454 delete r_pkt; r_pkt = 0;
447 delete w_pkt; w_pkt = 0; 455 delete w_pkt; w_pkt = 0;
448#if ENABLE_HTTP_PROXY 456#if ENABLE_HTTP_PROXY
456: v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) 464: v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev)
457{ 465{
458 last_activity = ev_now (); 466 last_activity = ev_now ();
459 r_pkt = 0; 467 r_pkt = 0;
460 w_pkt = 0; 468 w_pkt = 0;
469 tos = -1;
461 fd = fd_; 470 fd = fd_;
462#if ENABLE_HTTP_PROXY 471#if ENABLE_HTTP_PROXY
463 proxy_req = 0; 472 proxy_req = 0;
464#endif 473#endif
465 474

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines