3 * Copyright (C) 2010 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #include "heartbeat.h"
36 int cont
; /* Continue in tunnel processing ? 1 - yes / 0 - no */
38 int init (char *addr
, unsigned short port
, char *name
, char *pwd
)
40 if (tundev_init () == -1)
43 if (tunnel_init (addr
, port
, name
, pwd
) == -1)
46 if (ipv6_init () == -1)
49 if (tundev_setup () == -1)
52 if (heartbeat_init () == -1)
55 if (poll_init () == -1)
58 if (sig_init () == -1)
68 /* loop until cont is non-zero */
70 poll_loop (); /* check socket events */
72 heartbeat_loop (); /* send heartbeat packets in interval */
78 int syntax (char *bin
)
80 printf ("Syntax error\n\t%s: name password tunnel6server\n", bin
);
85 int main (int argc
, char **argv
)
87 printf ("TUNNEL6 client v%s by ZeXx86\n", DEFAULT_VERSION
);
93 /* tunnel server address */
96 unsigned short port
= DEFAULT_PORT
;
98 /* we've found config */
100 if (config_init () == -1) {
106 /* set config values */
109 server
= config
.server
;
114 /* set values from parameters */
120 port
= (unsigned short) atoi (argv
[4]);
123 printf ("User name: %s\n"
125 "Port: %u\n", name
, server
, port
);
127 /* Initialize routines */
128 if (init (server
, port
, name
, pwd
) == -1)
133 printf ("> closing tunnel\n");
135 /* disconnect from server */
136 proto_cmd_disconnect2 ();