Debian Codegraph @

ifconfig/options.h

raw
1 /*
2 Copyright (C) 2001-2026 Free Software Foundation, Inc.
3
4 This file is part of GNU Inetutils.
5
6 GNU Inetutils is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
10
11 GNU Inetutils is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see `http://www.gnu.org/licenses/'. */
18
19 /* Written by Marcus Brinkmann. */
20
21 #ifndef IFCONFIG_OPTIONS_H
22 # define IFCONFIG_OPTIONS_H
23
24 # include <sys/types.h>
25 # include <sys/socket.h>
26
27 struct ifconfig *parse_opt_new_ifs (char *name);
28
29 /* One per interface mentioned on the command line. */
30 struct ifconfig
31 {
32 char *name;
33 int valid;
34 # define IF_VALID_SYSTEM 0x001
35 struct system_ifconfig *system;
36 # define IF_VALID_FORMAT 0x002
37 const char *format;
38 # define IF_VALID_AF 0x004
39 sa_family_t af;
40 # define IF_VALID_ADDR 0x008
41 char *address;
42 # define IF_VALID_NETMASK 0x010
43 char *netmask;
44 # define IF_VALID_DSTADDR 0x020
45 char *dstaddr;
46 # define IF_VALID_BRDADDR 0x040
47 char *brdaddr;
48 # define IF_VALID_MTU 0x080
49 int mtu;
50 # define IF_VALID_METRIC 0x100
51 int metric;
52 # define IF_VALID_FLAGS 0x200
53 int setflags;
54 int clrflags;
55 # define IF_VALID_HWADDR 0x400
56 char *hwaddr;
57 };
58
59 struct format
60 {
61 const char *name;
62 const char *docstr;
63 const char *templ;
64 };
65
66 extern struct format formats[];
67 extern int all_option;
68 extern int ifs_cmdline;
69
70 /* Array of interfaces mentioned on the command line. */
71 extern struct ifconfig *ifs;
72 extern int nifs;
73
74 /* List available interfaces. */
75 extern int list_mode;
76
77 /* Be verbose about what we do. */
78 extern int verbose;
79
80 void usage (int err);
81 struct format *format_find (const char *name);
82 void parse_opt_set_address (struct ifconfig *ifp, char *addr);
83 void parse_opt_set_brdaddr (struct ifconfig *ifp, char *addr);
84 void parse_opt_set_dstaddr (struct ifconfig *ifp, char *addr);
85 void parse_opt_set_netmask (struct ifconfig *ifp, char *addr);
86 void parse_opt_set_hwaddr (struct ifconfig *ifp, char *addr);
87 void parse_opt_set_mtu (struct ifconfig *ifp, char *addr);
88 void parse_opt_set_metric (struct ifconfig *ifp, char *addr);
89 void parse_opt_set_default_format (const char *format);
90 void parse_opt_set_flag (struct ifconfig *ifp, int flag, int rev);
91 void parse_opt_flag_list (struct ifconfig *ifp, const char *name);
92 void parse_opt_set_point_to_point (struct ifconfig *ifp, char *addr);
93
94 void parse_opt_finalize (struct ifconfig *ifp);
95
96 void parse_cmdline (int argc, char *argv[]);
97
98 #endif