"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/tests-transform.c" between
n2n-3.0.tar.gz and n2n-3.1.1.tar.gz

About: n2n is a layer-two peer-to-peer virtual private network (VPN) which allows bypassing intermediate firewalls.
Pre-release.

tests-transform.c  (n2n-3.0):tests-transform.c  (n2n-3.1.1)
/* /*
* (C) 2007-21 - ntop.org and contributors * (C) 2007-22 - 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.
skipping to change at line 51 skipping to change at line 51
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 , 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ,
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 , 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 ,
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
}; };
/* Prototypes */ /* Prototypes */
static ssize_t do_encode_packet ( uint8_t * pktbuf, size_t bufsize, const n2n_co mmunity_t c ); static ssize_t do_encode_packet ( uint8_t * pktbuf, size_t bufsize, const n2n_co mmunity_t c );
static void run_transop_benchmark (const char *op_name, n2n_trans_op_t *op_fn, n 2n_edge_conf_t *conf, uint8_t *pktbuf); static void run_transop_benchmark (const char *op_name, n2n_trans_op_t *op_fn, n 2n_edge_conf_t *conf, uint8_t *pktbuf);
int main (int argc, char * argv[]) { int main (int argc, char * argv[]) {
uint8_t pktbuf[N2N_PKT_BUF_SIZE]; uint8_t pktbuf[N2N_PKT_BUF_SIZE];
n2n_trans_op_t transop_null, transop_tf; n2n_trans_op_t transop_null, transop_tf;
n2n_trans_op_t transop_aes; n2n_trans_op_t transop_aes;
n2n_trans_op_t transop_cc20; n2n_trans_op_t transop_cc20;
n2n_trans_op_t transop_speck; n2n_trans_op_t transop_speck;
n2n_trans_op_t transop_lzo;
#ifdef HAVE_ZSTD
n2n_trans_op_t transop_zstd;
#endif
n2n_edge_conf_t conf; n2n_edge_conf_t conf;
/* Init configuration */ /* Init configuration */
edge_init_conf_defaults(&conf); edge_init_conf_defaults(&conf);
strncpy((char *)conf.community_name, "abc123def456", sizeof(conf.community_n ame)); strncpy((char *)conf.community_name, "abc123def456", sizeof(conf.community_n ame));
conf.encrypt_key = "SoMEVer!S$cUREPassWORD"; conf.encrypt_key = "SoMEVer!S$cUREPassWORD";
char *test_name = "environment"; char *test_name = "environment";
printf("%s: community_name = \"%s\"\n", test_name, conf.community_name); printf("%s: community_name = \"%s\"\n", test_name, conf.community_name);
printf("%s: encrypt_key = \"%s\"\n", test_name, conf.encrypt_key); printf("%s: encrypt_key = \"%s\"\n", test_name, conf.encrypt_key);
printf("%s: input size = 0x%" PRIx64 "\n", test_name, sizeof(PKT_CONTENT)); printf("%s: input size = 0x%" PRIx64 "\n", test_name, sizeof(PKT_CONTENT));
fhexdump(0, PKT_CONTENT, sizeof(PKT_CONTENT), stdout); fhexdump(0, PKT_CONTENT, sizeof(PKT_CONTENT), stdout);
printf("\n"); printf("\n");
/* Init transopts */ /* Init transopts */
n2n_transop_null_init(&conf, &transop_null); n2n_transop_null_init(&conf, &transop_null);
n2n_transop_tf_init(&conf, &transop_tf); n2n_transop_tf_init(&conf, &transop_tf);
n2n_transop_aes_init(&conf, &transop_aes); n2n_transop_aes_init(&conf, &transop_aes);
n2n_transop_cc20_init(&conf, &transop_cc20); n2n_transop_cc20_init(&conf, &transop_cc20);
n2n_transop_speck_init(&conf, &transop_speck); n2n_transop_speck_init(&conf, &transop_speck);
n2n_transop_lzo_init(&conf, &transop_lzo);
#ifdef HAVE_ZSTD
n2n_transop_zstd_init(&conf, &transop_zstd);
#endif
/* Run the tests */ /* Run the tests */
/* FIXME: interop tests are pretty useless without the expected encrypted bu ffer data */ /* FIXME: interop tests are pretty useless without the expected encrypted bu ffer data */
run_transop_benchmark("null", &transop_null, &conf, pktbuf); run_transop_benchmark("null", &transop_null, &conf, pktbuf);
run_transop_benchmark("tf", &transop_tf, &conf, pktbuf); run_transop_benchmark("tf", &transop_tf, &conf, pktbuf);
run_transop_benchmark("aes", &transop_aes, &conf, pktbuf); run_transop_benchmark("aes", &transop_aes, &conf, pktbuf);
run_transop_benchmark("cc20", &transop_cc20, &conf, pktbuf); run_transop_benchmark("cc20", &transop_cc20, &conf, pktbuf);
run_transop_benchmark("speck", &transop_speck, &conf, pktbuf); run_transop_benchmark("speck", &transop_speck, &conf, pktbuf);
run_transop_benchmark("lzo", &transop_lzo, &conf, pktbuf);
#ifdef HAVE_ZSTD
run_transop_benchmark("zstd", &transop_zstd, &conf, pktbuf);
#else
// FIXME - output dummy data to the stdout for easy comparison
printf("zstd: output size = 0x47\n");
printf("000: 03 02 00 03 61 62 63 31 32 33 64 65 66 34 35 36 | abc123d
ef456|\n");
printf("010: 00 00 00 00 00 00 00 00 00 01 02 03 04 05 00 01 |
|\n");
printf("020: 02 03 04 05 00 00 28 b5 2f fd 60 00 01 bd 00 00 | ( / `
|\n");
printf("030: 80 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e |
|\n");
printf("040: 0f 01 00 da 47 9d 4b | G K|\n"
);
fprintf(stderr, "%s: not compiled - dummy data output\n", "zstd");
printf("\n");
#endif
/* Cleanup */ /* Cleanup */
transop_null.deinit(&transop_null); transop_null.deinit(&transop_null);
transop_tf.deinit(&transop_tf); transop_tf.deinit(&transop_tf);
transop_aes.deinit(&transop_aes); transop_aes.deinit(&transop_aes);
transop_cc20.deinit(&transop_cc20); transop_cc20.deinit(&transop_cc20);
transop_speck.deinit(&transop_speck); transop_speck.deinit(&transop_speck);
transop_lzo.deinit(&transop_lzo);
#ifdef HAVE_ZSTD
transop_zstd.deinit(&transop_zstd);
#endif
return 0; return 0;
} }
// --- cipher benchmark -------------------------------------------------------- ----------- // --- transop benchmark ------------------------------------------------------- -----------
static void run_transop_benchmark (const char *op_name, n2n_trans_op_t *op_fn, n 2n_edge_conf_t *conf, uint8_t *pktbuf) { static void run_transop_benchmark (const char *op_name, n2n_trans_op_t *op_fn, n 2n_edge_conf_t *conf, uint8_t *pktbuf) {
n2n_common_t cmn; n2n_common_t cmn;
n2n_PACKET_t pkt; n2n_PACKET_t pkt;
n2n_mac_t mac_buf; n2n_mac_t mac_buf;
uint8_t decodebuf[N2N_PKT_BUF_SIZE]; uint8_t decodebuf[N2N_PKT_BUF_SIZE];
size_t idx; size_t idx;
size_t rem; size_t rem;
size_t nw; size_t nw;
 End of changes. 8 change blocks. 
3 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)