Skip to content

Commit

Permalink
sample: add --dhcp support
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx committed Oct 27, 2023
1 parent f89d52e commit 97ecc00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/sample/sample_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum sample_args_cmd {
SAMPLE_ARG_RSS_MODE,
SAMPLE_ARG_NB_TX_DESC,
SAMPLE_ARG_NB_RX_DESC,
SAMPLE_ARG_DHCP,

SAMPLE_ARG_TX_VIDEO_URL = 0x200,
SAMPLE_ARG_RX_VIDEO_URL,
Expand Down Expand Up @@ -100,6 +101,7 @@ static struct option sample_args_options[] = {
{"rss_mode", required_argument, 0, SAMPLE_ARG_RSS_MODE},
{"nb_tx_desc", required_argument, 0, SAMPLE_ARG_NB_TX_DESC},
{"nb_rx_desc", required_argument, 0, SAMPLE_ARG_NB_RX_DESC},
{"dhcp", no_argument, 0, SAMPLE_ARG_DHCP},

{"tx_url", required_argument, 0, SAMPLE_ARG_TX_VIDEO_URL},
{"rx_url", required_argument, 0, SAMPLE_ARG_RX_VIDEO_URL},
Expand Down Expand Up @@ -252,6 +254,10 @@ static int _sample_parse_args(struct st_sample_context* ctx, int argc, char** ar
case SAMPLE_ARG_UDP_LCORE:
p->flags |= MTL_FLAG_UDP_LCORE;
break;
case SAMPLE_ARG_DHCP:
for (int port = 0; port < MTL_PORT_MAX; port++)
p->net_proto[port] = MTL_PROTO_DHCP;
break;
case SAMPLE_ARG_RSS_MODE:
if (!strcmp(optarg, "l3"))
p->rss_mode = MTL_RSS_MODE_L3;
Expand Down
2 changes: 1 addition & 1 deletion app/udp/udp_client_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int main(int argc, char** argv) {
int ret;

memset(&ctx, 0, sizeof(ctx));
ret = sample_parse_args(&ctx, argc, argv, true, false, true);
ret = sample_parse_args(&ctx, argc, argv, true, true, true);
if (ret < 0) return ret;

ctx.st = mtl_init(&ctx.param);
Expand Down
2 changes: 1 addition & 1 deletion app/udp/udp_server_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int main(int argc, char** argv) {
int ret;

memset(&ctx, 0, sizeof(ctx));
ret = sample_parse_args(&ctx, argc, argv, false, true, true);
ret = sample_parse_args(&ctx, argc, argv, true, true, true);
if (ret < 0) return ret;

ctx.st = mtl_init(&ctx.param);
Expand Down

0 comments on commit 97ecc00

Please sign in to comment.