along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.20 2000/07/02 13:40:57 guus Exp $
+ $Id: net.c,v 1.35.4.23 2000/08/08 13:47:56 guus Exp $
*/
#include "config.h"
int xsend(conn_list_t *cl, void *packet)
{
- int r;
real_packet_t rp;
cp
do_encrypt((vpn_packet_t*)packet, &rp, cl->key);
syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
ntohs(rp.len), cl->vpn_hostname, cl->real_hostname);
- if((r = send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0)
+ total_socket_out += ntohs(rp.len);
+
+ cl->want_ping = 1;
+
+ if((cl->flags | myself->flags) & TCPONLY)
+ return send_tcppacket(cl, (void*)&rp, ntohs(rp.len));
+
+ if((send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0)
{
syslog(LOG_ERR, _("Error sending packet to %s (%s): %m"),
cl->vpn_hostname, cl->real_hostname);
return -1;
}
-
- total_socket_out += r;
-
- cl->want_ping = 1;
cp
return 0;
}
}
flags = fcntl(cl->meta_socket, F_GETFL);
- if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0)
+/* if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0)
{
syslog(LOG_ERR, _("fcntl for %s port %d: %m"),
cl->real_hostname, cl->port);
return -1;
}
-
+*/
if(debug_lvl > 0)
syslog(LOG_INFO, _("Connected to %s port %hd"),
cl->real_hostname, cl->port);
else
myself->port = cfg->data.val;
- if(cfg = get_config_val(indirectdata))
+ if((cfg = get_config_val(indirectdata)))
if(cfg->data.val == stupid_true)
myself->flags |= EXPORTINDIRECTDATA;
+ if((cfg = get_config_val(tcponly)))
+ if(cfg->data.val == stupid_true)
+ myself->flags |= TCPONLY;
+
if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
{
syslog(LOG_ERR, _("Unable to set up a listening socket"));
*/
void terminate_connection(conn_list_t *cl)
{
- conn_list_t *p, *q;
+ conn_list_t *p;
cp
if(cl->status.remove)
if(errno==EINTR)
return 0;
if(errno==0)
- if(debug_lvl>0)
- syslog(LOG_NOTICE, _("Connection closed by %s (%s)"),
- cl->vpn_hostname, cl->real_hostname);
+ {
+ if(debug_lvl>0)
+ syslog(LOG_NOTICE, _("Connection closed by %s (%s)"),
+ cl->vpn_hostname, cl->real_hostname);
+ }
else
syslog(LOG_ERR, _("Metadata socket read error for %s (%s): %m"),
cl->vpn_hostname, cl->real_hostname);