n2n/examples/example_edge_embed_quick_edge_init.c

60 lines
1.8 KiB
C
Raw Normal View History

/**
2022-03-12 10:22:42 +01:00
* (C) 2007-22 - ntop.org and contributors
*
* 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/>
*
*/
2023-06-14 21:14:11 +02:00
2023-06-18 13:31:12 +02:00
#include <stdbool.h>
2023-06-14 21:14:11 +02:00
#include "n2n.h" // for quick_edge_init, setTraceLevel
#include "random_numbers.h" // for n2n_seed, n2n_srand
/*
This tool demonstrates how to easily embed
n2n on an existing application
*/
2020-12-19 12:28:06 +01:00
int main (int argc, char* argv[]) {
char *device_name = (char*)"n2n0";
char *network_name = (char*)"mynetwork";
char *secret_key = (char*)"mysecret";
char *my_mac_address = (char*)"DE:AD:BE:EF:01:10";
char *my_ipv4_addr = (char*)"1.2.3.4";
char *supernode = (char*)"7.8.9.10:1234";
bool keep_on_running = true;
/* Increase tracelevel to see what's happening */
setTraceLevel(10);
/* Random seed */
Basic C Code lint checker and shell checker (#859) * Factor build packages out into a more maintainable list * Create a location for scripts to live * Provide a make target to return the source dir as close as reasonable to the original distributed state * Add a code lint step, checking the coding style * Change test harness as recommended by shellcheck * Ensure we actually have the linter tool installed * Use the correct directory for cmake to run the tests * Adjust for the older uncrustify in the current github ubuntu-latest * Make one file pass the linter * Integrate the lint with the existing test workflow * Add files with minimal changes needed to the linter * Add more files with minimal changes needed to the linter * Dont build binaries if we fail the lint test * Update the phony targets with the lint steps * Ensure the flake8 package is installed in the new lint workflow job * Use the makefile to drive the packages needed to install for linting * No need to add dependancies on lint, just rely on the workflow status to show failure * Update the scripts dir README to reflect current assumptions * Rename and briefly document the indent.sh script * Fix the ignore to ignore the right Makefile * Rename the test_harness script to make it clear it is a shell script * Provide a master lint make target and add a shell script lint tool * Elminate stray tabs * Drop include/auth.h from linter - there are inconsistant results with function definitions when using the current uncrustify rules
2021-10-23 21:36:18 +02:00
n2n_srand(n2n_seed());
/*
NOTE
As the function below won't end, you should
call it inside a separate thread
*/
return(quick_edge_init(device_name,
network_name,
secret_key,
my_mac_address,
my_ipv4_addr,
supernode,
&keep_on_running));
}