source: trunk/src/ocatsetup.c @ 392

Last change on this file since 392 was 392, checked in by eagle, 8 years ago

replaced ether_ntoa by ether_ntoa_r
added some comments

File size: 4.1 KB
Line 
1/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
2 *
3 * This file is part of OnionCat.
4 *
5 * OnionCat 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, version 3 of the License.
8 *
9 * OnionCat is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*! ocatsetup_.c
19 *  This file contains the global settings structure.
20 *
21 *  @author Bernhard Fischer <rahra _at_ cypherpunk at>
22 *  @version 2008/02/03-01
23 */
24
25
26#include "ocat.h"
27
28struct OcatSetup setup_ =
29{
30   // fhd_keys
31   {0, 0},
32   // fhd_key_len
33   sizeof(uint32_t),
34   TOR_SOCKS_PORT, OCAT_LISTEN_PORT, OCAT_DEST_PORT, OCAT_CTRL_PORT, 
35   //! default tunfd is stdin/stdout
36   {0, 1},
37   //! default debug level
38   LOG_DEBUG,
39   OCAT_UNAME, {0}, {{{0}}}, 0, 0, 1, OCAT_DIR, TUN_DEV,
40   0, TOR_PREFIX4, TOR_PREFIX4_MASK,
41   NULL, 1,
42   0,                                      // use_tap
43   {0x00, 0x00, 0x6c, 0x00, 0x00, 0x00},   // ocat_hwaddr (OnionCat MAC address)
44   PID_FILE,
45   NULL, NULL,                             // logfile
46   0,                                      // daemon
47   {
48      {{{0xfd, 0x87, 0xd8, 0x7e, 0xeb, 0x43,
49           0xed, 0xb1, 0x8, 0xe4, 0x35, 0x88, 0xe5, 0x46, 0x35, 0xca}}} // initial permanent peer "5wyqrzbvrdsumnok"
50   }
51};
52
53
54void init_setup(void)
55{
56   setup_.logf = stderr;
57}
58
59
60#define _SB 100
61
62void print_setup_struct(FILE *f)
63{
64   char ip[_SB], nm[_SB], ip6[_SB], logf[_SB], hw[_SB], rp[ROOT_PEERS][_SB];
65   int i;
66
67   inet_ntop(AF_INET, &setup_.ocat_addr4, ip, _SB);
68   inet_ntop(AF_INET, &setup_.ocat_addr4_mask, nm, _SB);
69   inet_ntop(AF_INET6, &setup_.ocat_addr, ip6, _SB);
70   for (i = 0; i < ROOT_PEERS; i++)
71      inet_ntop(AF_INET6, &setup_.root_peer[i], rp[i], _SB);
72
73   ether_ntoa_r((struct ether_addr*) setup_.ocat_hwaddr, hw);
74
75   if (setup_.logf == stderr)
76      strlcpy(logf, "stderr", sizeof(logf));
77   else
78      snprintf(logf, sizeof(logf), "%p", setup_.logf);
79
80   fprintf(f,
81         "fhd_key[IPV4(%d)]  = 0x%04x\n"
82         "fhd_key[IPV6(%d)]  = 0x%04x\n"
83         "fhd_key_len       = %d\n"
84         "tor_socks_port    = %d\n"
85         "ocat_listen_port  = %d\n"
86         "ocat_dest_port    = %d\n"
87         "ocat_ctrl_port    = %d\n"
88         "tunfd[0]          = %d\n"
89         "tunfd[1]          = %d\n"
90         "debug_level       = %d\n"
91         "usrname           = \"%s\"\n"
92         "onion_url         = \"%s\"\n"
93         "ocat_addr         = %s\n"
94         "create_clog       = %d\n"
95         "runasroot         = %d\n"
96         "controller        = %d\n"
97         "ocat_dir          = \"%s\"\n"
98         "tun_dev           = \"%s\"\n"
99         "ipv4_enable       = %d\n"
100         "ocat_addr4        = %s\n"
101         "ocat_addr4_mask   = %s\n"
102         "config_file       = \"%s\"\n"
103         "config_read       = %d\n"
104         "use_tap           = %d\n"
105         "ocat_hwaddr       = %s\n"
106         "pid_file          = \"%s\"\n"
107         "logfn             = \"%s\"\n"
108         "logf              = %s\n"
109         "daemon            = %d\n"
110         "root_peer[0]      = %s\n",
111 
112         IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]),
113         setup_.fhd_key_len,
114         setup_.tor_socks_port,
115         setup_.ocat_listen_port,
116         setup_.ocat_dest_port,
117         setup_.ocat_ctrl_port,
118         setup_.tunfd[0], setup_.tunfd[1],
119         setup_.debug_level,
120         setup_.usrname,
121         setup_.onion_url,
122         ip6,
123         setup_.create_clog,
124         setup_.runasroot,
125         setup_.controller,
126         setup_.ocat_dir,
127         setup_.tun_dev,
128         setup_.ipv4_enable,
129         ip,
130         nm,
131         setup_.config_file,
132         setup_.config_read,
133         setup_.use_tap,
134         hw,
135         setup_.pid_file,
136         setup_.logfn,
137         logf,
138         setup_.daemon,
139         rp[0]
140         );
141}
142
Note: See TracBrowser for help on using the repository browser.