mirror of https://github.com/ntop/n2n.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
4 years ago
|
/**
|
||
3 years ago
|
* (C) 2007-22 - ntop.org and contributors
|
||
4 years ago
|
*
|
||
|
* 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
|
||
|
* the Free Software Foundation; either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* 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/>
|
||
|
*
|
||
|
*/
|
||
|
|
||
1 year ago
|
|
||
1 year ago
|
#include <stdbool.h>
|
||
1 year ago
|
#include <stdlib.h> // for exit
|
||
|
#include "n2n.h" // for n2n_sn_t, open_socket, run_sn_loop, sn_init
|
||
|
|
||
1 year ago
|
#ifdef _WIN32
|
||
1 year ago
|
#include <winsock2.h>
|
||
1 year ago
|
#else
|
||
|
#include <netinet/in.h> // for INADDR_ANY, INADDR_LOOPBACK
|
||
|
#endif
|
||
|
|
||
5 years ago
|
|
||
1 year ago
|
static bool keep_running = true;
|
||
5 years ago
|
|
||
4 years ago
|
int main () {
|
||
5 years ago
|
|
||
4 years ago
|
n2n_sn_t sss_node;
|
||
|
int rc;
|
||
5 years ago
|
|
||
3 years ago
|
sn_init_defaults(&sss_node);
|
||
4 years ago
|
sss_node.daemon = 0; // Whether to daemonize
|
||
|
sss_node.lport = 1234; // Main UDP listen port
|
||
5 years ago
|
|
||
3 years ago
|
sss_node.sock = open_socket(sss_node.lport, INADDR_ANY, 0 /* UDP */);
|
||
4 years ago
|
if(-1 == sss_node.sock) {
|
||
|
exit(-2);
|
||
|
}
|
||
5 years ago
|
|
||
3 years ago
|
sss_node.mgmt_sock = open_socket(5645, INADDR_LOOPBACK, 0 /* UDP */); // Main UDP management port
|
||
4 years ago
|
if(-1 == sss_node.mgmt_sock) {
|
||
|
exit(-2);
|
||
|
}
|
||
5 years ago
|
|
||
3 years ago
|
sn_init(&sss_node);
|
||
|
|
||
3 years ago
|
sss_node.keep_running = &keep_running;
|
||
|
rc = run_sn_loop(&sss_node);
|
||
5 years ago
|
|
||
4 years ago
|
sn_term(&sss_node);
|
||
|
|
||
|
return rc;
|
||
4 years ago
|
}
|