Skip to content

Commit

Permalink
Detect compile protocols
Browse files Browse the repository at this point in the history
AF_UNIX <- HAVE_AFUNIX.
AF_INET <- HAVE_AFINET.
AF_INET6 <- HAVE_AFINET6.
AF_IPX <- HAVE_AFIPX.
AF_APPLETALK <- HAVE_AFATALK.
AF_NETROM <- HAVE_AFNETROM.
AF_AX25 <- HAVE_AFAX25.
AF_ROSE <- HAVE_AFROSE.
AF_X25 <- HAVE_AFX25.
AF_ECONET <- HAVE_AFECONET.
AF_ASH <- HAVE_AFASH.
  • Loading branch information
skrab-sah authored and ecki committed Aug 29, 2024
1 parent a54a5d7 commit 80ba5be
Show file tree
Hide file tree
Showing 35 changed files with 181 additions and 190 deletions.
11 changes: 0 additions & 11 deletions config.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,7 @@ bool 'Does your system support GNU gettext?' I18N n
*
* Protocol Families.
*
bool 'UNIX protocol family' HAVE_AFUNIX y
bool 'INET (TCP/IP) protocol family' HAVE_AFINET y
bool 'INET6 (IPv6) protocol family' HAVE_AFINET6 y
bool 'Novell IPX/SPX protocol family' HAVE_AFIPX y
bool 'Appletalk DDP protocol family' HAVE_AFATALK y
bool 'AX25 (packet radio) protocol family' HAVE_AFAX25 y
bool 'NET/ROM (packet radio) protocol family' HAVE_AFNETROM y
bool 'Rose (packet radio) protocol family' HAVE_AFROSE y
bool 'X.25 (CCITT) protocol family' HAVE_AFX25 y
bool 'Econet protocol family' HAVE_AFECONET n
bool 'DECnet protocol family' HAVE_AFDECnet n
bool 'Ash protocol family' HAVE_AFASH y
bool 'Bluetooth protocol family' HAVE_AFBLUETOOTH n
*
*
Expand Down
6 changes: 3 additions & 3 deletions hostname.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "net-support.h"
#include "../intl.h"

#if HAVE_AFINET6
#if AF_INET6
#include <sys/socket.h> /* for PF_INET6 */
#include <sys/types.h> /* for inet_ntop */
#endif
Expand Down Expand Up @@ -133,7 +133,7 @@ static void showhname(const char *hname, int c)
{
struct hostent *hp;
char *p, **alias;
#if HAVE_AFINET6
#if AF_INET6
char addr[INET6_ADDRSTRLEN + 1];
#else
char addr[INET_ADDRSTRLEN + 1];
Expand All @@ -149,7 +149,7 @@ static void showhname(const char *hname, int c)
if (opt_v)
fprintf(stderr, _("Resolving `%s' ...\n"), hname);
if (
#if HAVE_AFINET6
#if AF_INET6
!(hp = gethostbyname2(hname, PF_INET6)) &&
#endif
!(hp = gethostbyname(hname))) {
Expand Down
30 changes: 15 additions & 15 deletions ifconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <linux/if_slip.h>
#endif

#if HAVE_AFINET6
#if AF_INET6

#ifndef _LINUX_IN6_H
/*
Expand All @@ -68,9 +68,9 @@ struct in6_ifreq {

#endif

#endif /* HAVE_AFINET6 */
#endif /* AF_INET6 */

#if HAVE_AFIPX
#if AF_IPX
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
#include <netipx/ipx.h>
#else
Expand Down Expand Up @@ -202,7 +202,7 @@ static void usage(int rc)
{
FILE *fp = rc ? stderr : stdout;
fprintf(fp, _("Usage:\n ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]\n"));
#if HAVE_AFINET
#if AF_INET
fprintf(fp, _(" [add <address>[/<prefixlen>]]\n"));
fprintf(fp, _(" [del <address>[/<prefixlen>]]\n"));
fprintf(fp, _(" [[-]broadcast [<address>]] [[-]pointopoint [<address>]]\n"));
Expand Down Expand Up @@ -267,14 +267,14 @@ int main(int argc, char **argv)
int goterr = 0, didnetmask = 0, neednetmask=0;
char **spp;
int fd;
#if HAVE_AFINET6
#if AF_INET6
extern struct aftype inet6_aftype;
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&_sa;
struct in6_ifreq ifr6;
unsigned long prefix_len;
char *cp;
#endif
#if HAVE_AFINET
#if AF_INET
extern struct aftype inet_aftype;
#endif

Expand Down Expand Up @@ -726,11 +726,11 @@ int main(int argc, char **argv)
spp++;
continue;
}
#if HAVE_AFINET || HAVE_AFINET6
#if AF_INET || AF_INET6
if (!strcmp(*spp, "add")) {
if (*++spp == NULL)
usage(E_OPTERR);
#if HAVE_AFINET6
#if AF_INET6
if (strchr(*spp, ':')) {
/* INET6 */
if ((cp = strchr(*spp, '/'))) {
Expand Down Expand Up @@ -777,7 +777,7 @@ int main(int argc, char **argv)
continue;
}
#endif
#if HAVE_AFINET
#if AF_INET
{ /* ipv4 address a.b.c.d */
in_addr_t ip, nm, bc;
safe_strncpy(host, *spp, (sizeof host));
Expand Down Expand Up @@ -816,13 +816,13 @@ int main(int argc, char **argv)
}
#endif

#if HAVE_AFINET || HAVE_AFINET6
#if AF_INET || AF_INET6
if (!strcmp(*spp, "del")) {
if (*++spp == NULL)
usage(E_OPTERR);

#ifdef SIOCDIFADDR
#if HAVE_AFINET6
#if AF_INET6
if (strchr(*spp, ':')) { /* INET6 */
if ((cp = strchr(*spp, '/'))) {
prefix_len = atol(cp + 1);
Expand Down Expand Up @@ -869,7 +869,7 @@ int main(int argc, char **argv)
continue;
}
#endif
#if HAVE_AFINET
#if AF_INET
{
/* ipv4 address a.b.c.d */
in_addr_t ip, nm, bc;
Expand Down Expand Up @@ -911,7 +911,7 @@ int main(int argc, char **argv)
#endif
}
#endif
#if HAVE_AFINET6
#if AF_INET6
if (!strcmp(*spp, "tunnel")) {
if (*++spp == NULL)
usage(E_OPTERR);
Expand Down Expand Up @@ -993,7 +993,7 @@ int main(int argc, char **argv)
{
int r = 0; /* to shut gcc up */
switch (ap->af) {
#if HAVE_AFINET
#if AF_INET
case AF_INET:
fd = get_socket_for_af(AF_INET);
if (fd < 0) {
Expand All @@ -1003,7 +1003,7 @@ int main(int argc, char **argv)
r = ioctl(fd, SIOCSIFADDR, &ifr);
break;
#endif
#if HAVE_AFECONET
#if AF_ECONET
case AF_ECONET:
fd = get_socket_for_af(AF_ECONET);
if (fd < 0) {
Expand Down
44 changes: 22 additions & 22 deletions lib/af.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,37 @@ static short sVafinit = 0;

struct aftype * const aftypes[] =
{
#if HAVE_AFUNIX
#if AF_UNIX
&unix_aftype,
#endif
#if HAVE_AFINET
#if AF_INET
&inet_aftype,
#endif
#if HAVE_AFINET6
#if AF_INET6
&inet6_aftype,
#endif
#if HAVE_AFAX25
#if AF_AX25
&ax25_aftype,
#endif
#if HAVE_AFNETROM
#if AF_NETROM
&netrom_aftype,
#endif
#if HAVE_AFROSE
#if AF_ROSE
&rose_aftype,
#endif
#if HAVE_AFIPX
#if AF_IPX
&ipx_aftype,
#endif
#if HAVE_AFATALK
#if AF_APPLETALK
&ddp_aftype,
#endif
#if HAVE_AFECONET
#if AF_ECONET
&ec_aftype,
#endif
#if HAVE_AFASH
#if AF_ASH
&ash_aftype,
#endif
#if HAVE_AFX25
#if AF_X25
&x25_aftype,
#endif
&unspec_aftype,
Expand All @@ -159,37 +159,37 @@ struct aftype * const aftypes[] =
static void afinit(void)
{
unspec_aftype.title = _("UNSPEC");
#if HAVE_AFUNIX
#if AF_UNIX
unix_aftype.title = _("UNIX Domain");
#endif
#if HAVE_AFINET
#if AF_INET
inet_aftype.title = _("DARPA Internet");
#endif
#if HAVE_AFINET6
#if AF_INET6
inet6_aftype.title = _("IPv6");
#endif
#if HAVE_AFAX25
#if AF_AX25
ax25_aftype.title = _("AMPR AX.25");
#endif
#if HAVE_AFNETROM
#if AF_NETROM
netrom_aftype.title = _("AMPR NET/ROM");
#endif
#if HAVE_AFIPX
#if AF_IPX
ipx_aftype.title = _("Novell IPX");
#endif
#if HAVE_AFATALK
#if AF_APPLETALK
ddp_aftype.title = _("Appletalk DDP");
#endif
#if HAVE_AFECONET
#if AF_ECONET
ec_aftype.title = _("Econet");
#endif
#if HAVE_AFX25
#if AF_X25
x25_aftype.title = _("CCITT X.25");
#endif
#if HAVE_AFROSE
#if AF_ROSE
rose_aftype.title = _("AMPR ROSE");
#endif
#if HAVE_AFASH
#if AF_ASH
ash_aftype.title = _("Ash");
#endif
sVafinit = 1;
Expand Down
8 changes: 4 additions & 4 deletions lib/ash.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "config.h"

#if HAVE_HWASH || HAVE_AFASH
#if HAVE_HWASH || AF_ASH

#include <sys/types.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -100,7 +100,7 @@ struct hwtype ash_hwtype =

#endif /* HAVE_HWASH */

#if HAVE_AFASH
#if AF_ASH

/* Display an Ash socket address. */
static const char *
Expand All @@ -123,6 +123,6 @@ struct aftype ash_aftype =
"/proc/sys/net/ash"
};

#endif /* HAVE_AFASH */
#endif /* AF_ASH */

#endif /* HAVE_AFASH || HAVE_HWASH */
#endif /* AF_ASH || HAVE_HWASH */
2 changes: 1 addition & 1 deletion lib/ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
#include "config.h"

#if HAVE_AFAX25 || HAVE_HWAX25
#if AF_AX25 || HAVE_HWAX25
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
Expand Down
6 changes: 3 additions & 3 deletions lib/ax25_gr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
#include "config.h"

#if HAVE_AFAX25
#include <sys/socket.h>
#if AF_AX25
#if 0
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/ax25.h>
#include <linux/if_arp.h> /* ARPHRD_AX25 */
#include <ctype.h>
Expand Down Expand Up @@ -62,4 +62,4 @@ int AX25_rprint(int options)
return 0;
}

#endif /* HAVE_AFAX25 */
#endif /* AF_AX25 */
4 changes: 2 additions & 2 deletions lib/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
*/
#include "config.h"

#if HAVE_AFATALK
#include <sys/socket.h>
#if AF_APPLETALK
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/atalk.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions lib/ddp_gr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

#include "config.h"

#if HAVE_AFATALK
#include <sys/socket.h>
#if AF_APPLETALK
#include <asm/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/atalk.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
7 changes: 4 additions & 3 deletions lib/econet.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

#include "config.h"

#if HAVE_AFECONET
#include <sys/socket.h>

#if AF_ECONET

#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <neteconet/ec.h>

Expand Down Expand Up @@ -83,4 +84,4 @@ struct aftype ec_aftype =
"/proc/sys/net/econet"
};

#endif /* HAVE_AFECONET */
#endif /* AF_ECONET */
Loading

0 comments on commit 80ba5be

Please sign in to comment.