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.7 by pcg, Sun Apr 6 18:12:18 2003 UTC vs.
Revision 1.8 by pcg, Mon Apr 7 01:28:56 2003 UTC

71} 71}
72 72
73int 73int
74vpn::setup () 74vpn::setup ()
75{ 75{
76 ipv4_fd = -1;
77
78 if (THISNODE->protocols & PROT_IPv4 && ::conf.ip_proto)
79 {
80 ipv4_fd = socket (PF_INET, SOCK_RAW, ::conf.ip_proto);
81
82 if (ipv4_fd < 0)
83 return -1;
84
85 sockinfo si (THISNODE, PROT_IPv4);
86
87 if (bind (ipv4_fd, si.sav4 (), si.salenv4 ()))
88 {
89 slog (L_ERR, _("can't bind ipv4 socket on %s: %s"), (const char *)si, strerror (errno));
90 exit (1);
91 }
92
93#ifdef IP_MTU_DISCOVER
94 // this I really consider a linux bug. I am neither connected
95 // nor do I fragment myself. Linux still sets DF and doesn't
96 // fragment for me sometimes.
97 {
98 int oval = IP_PMTUDISC_DONT;
99 setsockopt (ipv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
100 }
101#endif
102
103 ipv4_ev_watcher.start (ipv4_fd, POLLIN);
104 }
105
76 udpv4_fd = -1; 106 udpv4_fd = -1;
77 107
78 if (THISNODE->protocols & PROT_UDPv4) 108 if (THISNODE->protocols & PROT_UDPv4 && THISNODE->udp_port)
79 { 109 {
80 udpv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); 110 udpv4_fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP);
81 111
82 if (udpv4_fd < 0) 112 if (udpv4_fd < 0)
83 return -1; 113 return -1;
107#endif 137#endif
108 138
109 udpv4_ev_watcher.start (udpv4_fd, POLLIN); 139 udpv4_ev_watcher.start (udpv4_fd, POLLIN);
110 } 140 }
111 141
112 ipv4_fd = -1; 142 tcpv4_fd = -1;
113 if (THISNODE->protocols & PROT_IPv4)
114 {
115 ipv4_fd = socket (PF_INET, SOCK_RAW, ::conf.ip_proto);
116
117 if (ipv4_fd < 0)
118 return -1;
119
120 sockinfo si (THISNODE, PROT_IPv4);
121
122 if (bind (ipv4_fd, si.sav4 (), si.salenv4 ()))
123 {
124 slog (L_ERR, _("can't bind ipv4 socket on %s: %s"), (const char *)si, strerror (errno));
125 exit (1);
126 }
127
128#ifdef IP_MTU_DISCOVER
129 // this I really consider a linux bug. I am neither connected
130 // nor do I fragment myself. Linux still sets DF and doesn't
131 // fragment for me sometimes.
132 {
133 int oval = IP_PMTUDISC_DONT;
134 setsockopt (ipv4_fd, SOL_IP, IP_MTU_DISCOVER, &oval, sizeof oval);
135 }
136#endif
137
138 ipv4_ev_watcher.start (ipv4_fd, POLLIN);
139 }
140 143
141#if ENABLE_TCP 144#if ENABLE_TCP
142 if (THISNODE->protocols & PROT_TCPv4) 145 if (THISNODE->protocols & PROT_TCPv4 && THISNODE->tcp_port)
143 { 146 {
144 tcpv4_fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); 147 tcpv4_fd = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
145 148
146 if (tcpv4_fd < 0) 149 if (tcpv4_fd < 0)
147 return -1; 150 return -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines