1717enum {
1818 OPT_HELP = 'h' ,
1919 OPT_VERSION = 'v' ,
20+ OPT_MAXCOUNT = 'c' ,
2021_OPT_SHOPT_MAX = 255 ,
2122 OPT_FILE_PREFIX ,
2223 OPT_DROPS ,
@@ -27,6 +28,7 @@ _OPT_SHOPT_MAX = 255,
2728};
2829
2930#define OPTSTRING ":hv" \
31+ "c:" \
3032
3133static const struct option dp_conf_longopts [] = {
3234 { "help" , 0 , 0 , OPT_HELP },
@@ -36,12 +38,14 @@ static const struct option dp_conf_longopts[] = {
3638 { "nodes" , 1 , 0 , OPT_NODES },
3739 { "filter" , 1 , 0 , OPT_FILTER },
3840 { "pcap" , 1 , 0 , OPT_PCAP },
41+ { "maxcount" , 1 , 0 , OPT_MAXCOUNT },
3942 { "stop" , 0 , 0 , OPT_STOP },
4043 { NULL , 0 , 0 , 0 }
4144};
4245
4346static char eal_file_prefix [32 ];
4447static bool showing_drops = false;
48+ static int count = 0 ;
4549static bool stop_mode = false;
4650
4751const char * dp_conf_get_eal_file_prefix (void )
@@ -54,6 +58,11 @@ bool dp_conf_is_showing_drops(void)
5458 return showing_drops ;
5559}
5660
61+ int dp_conf_get_count (void )
62+ {
63+ return count ;
64+ }
65+
5766bool dp_conf_is_stop_mode (void )
5867{
5968 return stop_mode ;
@@ -78,6 +87,7 @@ static inline void dp_argparse_help(const char *progname, FILE *outfile)
7887 " --nodes=REGEX show graph node traversal, limit to REGEX-matched nodes (empty string for all)\n"
7988 " --filter=FILTER show only packets matching a pcap-style FILTER\n"
8089 " --pcap=FILE write packets into a PCAP file\n"
90+ " -c, --maxcount=COUNT exit after receiving COUNT packets\n"
8191 " --stop do nothing, only make sure tracing is disabled in dp-service\n"
8292 , progname );
8393}
@@ -96,6 +106,8 @@ static int dp_conf_parse_arg(int opt, const char *arg)
96106 return dp_argparse_opt_filter (arg );
97107 case OPT_PCAP :
98108 return dp_argparse_opt_pcap (arg );
109+ case OPT_MAXCOUNT :
110+ return dp_argparse_int (arg , & count , 0 , INT_MAX );
99111 case OPT_STOP :
100112 return dp_argparse_store_true (& stop_mode );
101113 default :
0 commit comments