2008-05-06 08:33:42 +04:00
|
|
|
#ifndef _IFCONFIG_UTIL_H
|
|
|
|
#define _IFCONFIG_UTIL_H
|
|
|
|
|
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.
(In principle, ifconfig could load virtually all of its syntax from
shared objects.)
Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.
Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.
Sprinkle static. Change some int's to bool's. Constify.
Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.
Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.
Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
2008-07-02 11:44:13 +04:00
|
|
|
#include <netinet/in.h>
|
Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.
In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.
Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.
In support of the changes above,
1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().
2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.
3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
2009-09-12 02:06:29 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <ifaddrs.h>
|
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.
(In principle, ifconfig could load virtually all of its syntax from
shared objects.)
Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.
Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.
Sprinkle static. Change some int's to bool's. Constify.
Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.
Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.
Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
2008-07-02 11:44:13 +04:00
|
|
|
|
2008-05-06 08:33:42 +04:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
struct afswtch {
|
|
|
|
const char *af_name;
|
|
|
|
short af_af;
|
2008-05-06 20:15:17 +04:00
|
|
|
void (*af_status)(prop_dictionary_t, prop_dictionary_t, bool);
|
2008-05-06 21:29:04 +04:00
|
|
|
void (*af_addr_commit)(prop_dictionary_t, prop_dictionary_t);
|
2015-04-22 20:42:22 +03:00
|
|
|
bool (*af_addr_tentative)(struct ifaddrs *);
|
2016-01-07 14:32:21 +03:00
|
|
|
bool (*af_addr_tentative_or_detached)(struct ifaddrs *);
|
Let us add/remove features from ifconfig, such as support for
various address families (inet, inet6, iso, atalk) and protocols
(802.11, 802.3ad, CARP), simply by trimming the list of sources in
the Makefile. This helps one customize ifconfig for an embedded
device or for install media, and it eliminates a lot of grotty
#ifdef'age. Now, the ifconfig syntax and semantics are finalized
at run-time using the constructor routines in each address-family/protocol
module.
(In principle, ifconfig could load virtually all of its syntax from
shared objects.)
Extract a lot of common code into subroutines, in order to shrink
the ifconfig binary a bit. Make all of the address families share
code for address addition/replacement/removal, and delete "legacy"
code for manipulating addresses. That may have broken atalk and
iso, despite my best efforts.
Extract an include file, Makefile.inc, containing the make-fu that
both ifconfig and x_ifconfig share.
Sprinkle static. Change some int's to bool's. Constify.
Add RCS Ids to carp.c and env.c. Move media code to a new file,
media.c. Delete several unneeded header files.
Set, reset, and display the IEEE 802.11 attribute, 'dot11RTSThreshold'.
Bug fix: do not require both a interface address and a destination
address for point-to-point interfaces, but accept a interface
address by itself.
2008-07-02 11:44:13 +04:00
|
|
|
SIMPLEQ_ENTRY(afswtch) af_next;
|
2008-05-06 08:33:42 +04:00
|
|
|
};
|
|
|
|
|
2009-04-22 02:46:39 +04:00
|
|
|
void print_link_addresses(prop_dictionary_t, bool);
|
2010-07-01 20:44:05 +04:00
|
|
|
const char *get_string(const char *, const char *, u_int8_t *, int *, bool);
|
2008-05-06 08:33:42 +04:00
|
|
|
const struct afswtch *lookup_af_byname(const char *);
|
|
|
|
const struct afswtch *lookup_af_bynum(int);
|
|
|
|
void print_string(const u_int8_t *, int);
|
|
|
|
int getsock(int);
|
|
|
|
struct paddr_prefix *prefixlen_to_mask(int, int);
|
2008-05-08 03:55:06 +04:00
|
|
|
int direct_ioctl(prop_dictionary_t, unsigned long, void *);
|
|
|
|
int indirect_ioctl(prop_dictionary_t, unsigned long, void *);
|
Make ifconfig(8) set and display preference numbers for IPv6
addresses. Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.
In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr. Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.
Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.
In support of the changes above,
1 Add a method to struct domain for "externalizing" a sockaddr, and
provide an implementation for IPv6. Expect more work in this area: it
may be more proper to say that the IPv6 implementation "internalizes"
a sockaddr. Add sockaddr_externalize().
2 Add a subroutine, sofamily(), that returns a struct socket's address
family or AF_UNSPEC.
3 Make a lot of IPv4-specific code generic, and move it from
sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
ifconfig(8).
2009-09-12 02:06:29 +04:00
|
|
|
bool ifa_any_preferences(const char *, struct ifaddrs *, int);
|
|
|
|
void ifa_print_preference(const char *, const struct sockaddr *);
|
|
|
|
int16_t ifa_get_preference(const char *, const struct sockaddr *);
|
2008-05-06 08:33:42 +04:00
|
|
|
|
|
|
|
#endif /* _IFCONFIG_UTIL_H */
|