| 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_FLAGS_H |
| 22 |
# define IFCONFIG_FLAGS_H |
| 23 |
|
| 24 |
# include <sys/types.h> |
| 25 |
|
| 26 |
/* Using these avoid strings with if_flagtoname, the caller can set a |
| 27 |
preference on returned flag names. If one of the names in the list |
| 28 |
is found for the flag, the search continues to attempt a better |
| 29 |
match. */ |
| 30 |
/* FreeBSD */ |
| 31 |
# define EXPECT_LINK2 ":LINK2/ALTPHYS:ALTPHYS:" |
| 32 |
# define EXPECT_ALTPHYS ":LINK2/ALTPHYS:LINK2:" |
| 33 |
|
| 34 |
/* OSF 4.0g */ |
| 35 |
# define EXPECT_D2 ":D2/SNAP:SNAP:" |
| 36 |
# define EXPECT_SNAP ":D2/SNAP:D2:" |
| 37 |
|
| 38 |
/* Suppress flags that are not changeable by user. */ |
| 39 |
# ifndef IFF_CANTCHANGE |
| 40 |
# define IFF_CANTCHANGE 0 |
| 41 |
# endif/* IFF_CANTCHANGE */ |
| 42 |
|
| 43 |
/* Manually exclude flags that experience tell us be static. */ |
| 44 |
# define IU_IFF_CANTCHANGE \ |
| 45 |
(IFF_CANTCHANGE | IFF_LOOPBACK | IFF_RUNNING) |
| 46 |
|
| 47 |
/* Return the name corresponding to the interface flag FLAG. |
| 48 |
If FLAG is unknown, return NULL. |
| 49 |
AVOID contains a ':' surrounded and separated list of flag names |
| 50 |
that should be avoided if alternative names with the same flag value |
| 51 |
exists. The first unavoided match is returned, or the first avoided |
| 52 |
match if no better is available. */ |
| 53 |
const char *if_flagtoname (int flag, const char *avoid); |
| 54 |
|
| 55 |
/* Return the flag mask corresponding to flag name NAME. If no flag |
| 56 |
with this name is found, return 0. */ |
| 57 |
int if_nametoflag (const char *name, size_t len, int *prev); |
| 58 |
int if_nameztoflag (const char *name, int *prev); |
| 59 |
|
| 60 |
/* Print the flags in FLAGS, using AVOID as in if_flagtoname, and |
| 61 |
SEPARATOR between individual flags. Returns the number of |
| 62 |
characters printed. */ |
| 63 |
int print_if_flags (int flags, const char *avoid, char separator); |
| 64 |
|
| 65 |
char *if_list_flags (const char *prefix); |
| 66 |
|
| 67 |
/* Size of the buffer for the if_format_flags call */ |
| 68 |
# define IF_FORMAT_FLAGS_BUFSIZE 15 |
| 69 |
void if_format_flags (int flags, char *buf, size_t size); |
| 70 |
|
| 71 |
#endif |