1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* SPDX-License-Identifier: GPL-2.0 */
#include <stdio.h>
#include <linux/netlink.h>
#include <linux/wwan.h>
#include "utils.h"
#include "ip_common.h"
static void print_explain(FILE *f)
{
fprintf(f,
"Usage: ... wwan linkid LINKID\n"
"\n"
"Where: LINKID := 0-4294967295\n"
);
}
static void explain(void)
{
print_explain(stderr);
}
static int wwan_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
while (argc > 0) {
if (matches(*argv, "linkid") == 0) {
__u32 linkid;
NEXT_ARG();
if (get_u32(&linkid, *argv, 0))
invarg("linkid", *argv);
addattr32(n, 1024, IFLA_WWAN_LINK_ID, linkid);
} else if (matches(*argv, "help") == 0) {
explain();
return -1;
} else {
fprintf(stderr, "wwan: unknown command \"%s\"?\n",
*argv);
explain();
return -1;
}
argc--, argv++;
}
return 0;
}
static void wwan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
{
if (!tb)
return;
if (tb[IFLA_WWAN_LINK_ID])
print_uint(PRINT_ANY, "linkid", "linkid %u ",
rta_getattr_u32(tb[IFLA_WWAN_LINK_ID]));
}
static void wwan_print_help(struct link_util *lu, int argc, char **argv,
FILE *f)
{
print_explain(f);
}
struct link_util wwan_link_util = {
.id = "wwan",
.maxattr = IFLA_WWAN_MAX,
.parse_opt = wwan_parse_opt,
.print_opt = wwan_print_opt,
.print_help = wwan_print_help,
};
|