Skip to content

Commit

Permalink
sample/udld: allow user set output interface
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Ivanov <[email protected]>
  • Loading branch information
ivalery111 committed Jun 6, 2024
1 parent 125823e commit 1ec574a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions sample/udld.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,39 @@

#include <assert.h>

#define DEVICE_NAME "lo"
void usage(char *);

int
main(int argc, char *argv[])
{
(void)argc; /* unused */

int c;
char *device = NULL;
libnet_t *l;
libnet_ptag_t t;
char errbuf[LIBNET_ERRBUF_SIZE];
size_t udld_payload_size = 0;

l = libnet_init(LIBNET_LINK, DEVICE_NAME, errbuf);
while((c = getopt(argc, argv, "i:h")) != EOF)
{
switch (c)
{
case 'i':
device = optarg;
break;
case 'h':
usage(argv[0]);
exit(EXIT_FAILURE);
}
}

if (device == NULL)
{
device = "lo";
}

l = libnet_init(LIBNET_LINK, device, errbuf);
if (l == NULL)
{
fprintf(stderr, "libnet_init() failed: %s", errbuf);
Expand Down Expand Up @@ -157,3 +176,9 @@ main(int argc, char *argv[])
libnet_destroy(l);
return (EXIT_FAILURE);
}

void
usage(char *name)
{
fprintf(stderr, "usage: %s [-i iface] \n ", name);
}

0 comments on commit 1ec574a

Please sign in to comment.