added the --save-packet argument so that SPA packet data can be saved to the local filesystem by the fwknop-c client
git-svn-id: file:///home/mbr/svn/fwknop/trunk@78 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
parent
d19e2777f7
commit
f3e4694a0c
@ -221,6 +221,9 @@ config_init(fko_cli_options_t *options, int argc, char **argv)
|
||||
case 'G':
|
||||
strlcpy(options->get_key_file, optarg, MAX_PATH_LEN);
|
||||
break;
|
||||
case 'B':
|
||||
strlcpy(options->save_packet_file, optarg, MAX_PATH_LEN);
|
||||
break;
|
||||
case 'Q':
|
||||
strlcpy(options->spoof_ip_src_str, optarg, MAX_IP_STR_LEN);
|
||||
break;
|
||||
|
||||
@ -54,6 +54,7 @@ static struct option cmd_opts[] =
|
||||
{"source-port", 1, NULL, 'S'},
|
||||
{"spoof-src", 1, NULL, 'Q'},
|
||||
{"spoof-user", 1, NULL, 'U'},
|
||||
{"save-packet", 1, NULL, 'B'},
|
||||
{"get-key", 1, NULL, 'G'},
|
||||
{"quiet", 0, NULL, 'q'},
|
||||
{"debug", 0, NULL, 'd'},
|
||||
|
||||
@ -197,6 +197,9 @@ main(int argc, char **argv)
|
||||
if (! options.quiet)
|
||||
display_ctx(ctx);
|
||||
|
||||
if (options.save_packet_file[0] != 0x0)
|
||||
write_spa_packet_data(ctx, options.save_packet_file);
|
||||
|
||||
/* If not in test mode, send the SPA data across the wire with a
|
||||
* protocol/port specified on the command line (default is UDP/62201).
|
||||
* Otherwise, run through a decode cycle (--DSS XXX: This test/decode
|
||||
|
||||
@ -86,6 +86,7 @@ typedef struct fko_cli_options
|
||||
char config_file[MAX_PATH_LEN];
|
||||
char access_str[MAX_PATH_LEN];
|
||||
char get_key_file[MAX_LINE_LEN];
|
||||
char save_packet_file[MAX_LINE_LEN];
|
||||
char spa_server_ip_str[MAX_IP_STR_LEN];
|
||||
char allow_ip_str[MAX_IP_STR_LEN];
|
||||
char spoof_ip_src_str[MAX_IP_STR_LEN];
|
||||
|
||||
@ -114,5 +114,22 @@ send_spa_packet(fko_ctx_t ctx, fko_cli_options_t *options)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Function to write SPA packet data to the filesystem
|
||||
*/
|
||||
int write_spa_packet_data(fko_ctx_t ctx, const char *save_packet_file)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
|
||||
if((fp = fopen(save_packet_file, "w")) == NULL)
|
||||
return 0;
|
||||
|
||||
fprintf(fp, "%s\n",
|
||||
(fko_get_spa_data(ctx) == NULL) ? "<NULL>" : fko_get_spa_data(ctx));
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***EOF***/
|
||||
|
||||
@ -31,5 +31,6 @@
|
||||
/* Prototypes
|
||||
*/
|
||||
int send_spa_packet(fko_ctx_t ctx, fko_cli_options_t *options);
|
||||
int write_spa_packet_data(fko_ctx_t ctx, const char *save_packet_file);
|
||||
|
||||
#endif /* SPA_COMM_H */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user