static int ipvlan_parse_opt(struct link_util *lu, int argc, char **argv, struct nlmsghdr *n) { __u16 flags = 0; bool mflag_given = false; while (argc > 0) { if (matches(*argv, "mode") == 0) { __u16 mode = 0; NEXT_ARG(); if (strcmp(*argv, "l2") == 0) mode = IPVLAN_MODE_L2; else if (strcmp(*argv, "l3") == 0) mode = IPVLAN_MODE_L3; else if (strcmp(*argv, "l3s") == 0) mode = IPVLAN_MODE_L3S; else { fprintf(stderr, "Error: argument of \"mode\" must be either \"l2\", \"l3\" or \"l3s\"\n"); return -1; } addattr16(n, 1024, IFLA_IPVLAN_MODE, mode); } else if (matches(*argv, "private") == 0 && !mflag_given) { flags |= IPVLAN_F_PRIVATE; mflag_given = true; } else if (matches(*argv, "vepa") == 0 && !mflag_given) { flags |= IPVLAN_F_VEPA; mflag_given = true; } else if (matches(*argv, "bridge") == 0 && !mflag_given) { mflag_given = true; } else if (matches(*argv, "help") == 0) { ipvlan_explain(stderr); return -1; } else { fprintf(stderr, "ipvlan: unknown option \"%s\"?\n", *argv); ipvlan_explain(stderr); return -1; } argc--; argv++; } addattr16(n, 1024, IFLA_IPVLAN_FLAGS, flags); return 0; }
static void ipvlan_print_help(struct link_util *lu, int argc, char **argv, FILE *f) { ipvlan_explain(f); }
static void explain(void) { ipvlan_explain(stderr); }