example_sn_embed.c (n2n-2.8) | : | example_sn_embed.c (n2n-3.0) | ||
---|---|---|---|---|
/** | /** | |||
* (C) 2007-20 - ntop.org and contributors | * (C) 2007-21 - ntop.org and contributors | |||
* | * | |||
* This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation; either version 3 of the License, or | * the Free Software Foundation; either version 3 of the License, or | |||
* (at your option) any later version. | * (at your option) any later version. | |||
* | * | |||
* This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | * GNU General Public License for more details. | |||
* | * | |||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | |||
* along with this program; if not see see <http://www.gnu.org/licenses/> | * along with this program; if not see see <http://www.gnu.org/licenses/> | |||
* | * | |||
*/ | */ | |||
#include "n2n.h" | #include "n2n.h" | |||
static int keep_running; | static int keep_running; | |||
int main() | int main () { | |||
{ | ||||
n2n_sn_t sss_node; | ||||
int rc; | ||||
sn_init(&sss_node); | ||||
sss_node.daemon = 0; // Whether to daemonize | ||||
sss_node.lport = 1234; // Main UDP listen port | ||||
sss_node.sock = open_socket(sss_node.lport, 1); | ||||
if (-1 == sss_node.sock) | ||||
{ | ||||
exit(-2); | ||||
} | ||||
sss_node.mgmt_sock = open_socket(5645, 0); // Main UDP management port | ||||
if (-1 == sss_node.mgmt_sock) | ||||
{ | ||||
exit(-2); | ||||
} | ||||
keep_running = 1; | n2n_sn_t sss_node; | |||
rc = run_sn_loop(&sss_node, &keep_running); | int rc; | |||
sn_term(&sss_node); | sn_init_defaults(&sss_node); | |||
sss_node.daemon = 0; // Whether to daemonize | ||||
sss_node.lport = 1234; // Main UDP listen port | ||||
return rc; | sss_node.sock = open_socket(sss_node.lport, INADDR_ANY, 0 /* UDP */); | |||
if(-1 == sss_node.sock) { | ||||
exit(-2); | ||||
} | ||||
sss_node.mgmt_sock = open_socket(5645, INADDR_LOOPBACK, 0 /* UDP */); // | ||||
Main UDP management port | ||||
if(-1 == sss_node.mgmt_sock) { | ||||
exit(-2); | ||||
} | ||||
sn_init(&sss_node); | ||||
keep_running = 1; | ||||
sss_node.keep_running = &keep_running; | ||||
rc = run_sn_loop(&sss_node); | ||||
sn_term(&sss_node); | ||||
return rc; | ||||
} | } | |||
End of changes. 5 change blocks. | ||||
25 lines changed or deleted | 27 lines changed or added |