Amit Pundir | d477f82 | 2020-02-07 22:26:08 +0530 | [diff] [blame] | 1 | #include <err.h> |
| 2 | #include <errno.h> |
| 3 | #include <libgen.h> |
| 4 | #include <limits.h> |
| 5 | #include <linux/netlink.h> |
| 6 | #include <linux/rtnetlink.h> |
| 7 | #include <linux/qrtr.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | #include <string.h> |
| 11 | #include <sys/socket.h> |
| 12 | #include <sys/types.h> |
| 13 | #include <unistd.h> |
| 14 | |
| 15 | #include "addr.h" |
| 16 | #include "libqrtr.h" |
| 17 | #include "logging.h" |
| 18 | |
| 19 | static void usage(const char *progname) |
| 20 | { |
| 21 | fprintf(stderr, "%s <node-id>\n", progname); |
| 22 | exit(1); |
| 23 | } |
| 24 | |
| 25 | int main(int argc, char **argv) |
| 26 | { |
| 27 | unsigned long addrul; |
| 28 | uint32_t addr; |
| 29 | char *ep; |
| 30 | const char *progname = basename(argv[0]); |
| 31 | |
| 32 | qlog_setup(progname, false); |
| 33 | |
| 34 | if (argc != 2) |
| 35 | usage(progname); |
| 36 | |
| 37 | addrul = strtoul(argv[1], &ep, 10); |
| 38 | if (argv[1][0] == '\0' || *ep != '\0' || addrul >= UINT_MAX) |
| 39 | usage(progname); |
| 40 | addr = addrul; |
| 41 | qrtr_set_address(addr); |
| 42 | |
| 43 | return 0; |
| 44 | } |