From bf51af5874864dda5356bf252933c8824532f23f Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Wed, 17 Feb 2016 20:13:15 +0100 Subject: [PATCH] Make a string available that indicates the supported networking options. dpni20 and dpimp print it on error or when -debug is given. enaddr prints it with -v, but this does not reflect TUN since it doesn't use it. --- src/dpimp.c | 6 ++++-- src/dpni20.c | 6 ++++-- src/enaddr.c | 2 ++ src/osdnet.c | 26 +++++++++++++++++++++++++- src/osdnet.h | 4 +++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/dpimp.c b/src/dpimp.c index 19a6f0f..8f98db2 100644 --- a/src/dpimp.c +++ b/src/dpimp.c @@ -428,8 +428,10 @@ main(int argc, char **argv) } } } - if (initdebug) - dbprint("Starting"); + if (initdebug) { + dbprintln("Starting"); + dbprintln("Supported ifmeth=%s", osn_networking); + } /* Right off the bat attempt to get the highest scheduling priority ** we can, since a slow response will cause the 10 monitor to declare diff --git a/src/dpni20.c b/src/dpni20.c index 92dfc78..ab5759b 100644 --- a/src/dpni20.c +++ b/src/dpni20.c @@ -308,8 +308,10 @@ main(int argc, char **argv) } } } - if (initdebug) - dbprint("Starting"); + if (initdebug) { + dbprintln("Starting"); + dbprintln("Supported ifmeth=%s", osn_networking); + } /* Right off the bat attempt to get the highest scheduling priority ** we can. It's important that the NI respond as quickly as possible diff --git a/src/enaddr.c b/src/enaddr.c index db03d2f..c8809e8 100644 --- a/src/enaddr.c +++ b/src/enaddr.c @@ -313,6 +313,8 @@ main(int argc, char **argv) } } + printf("Supported network interface methods:%s\n", osn_networking); + /* First, show interface info if desired */ osn_iftab_init(); diff --git a/src/osdnet.c b/src/osdnet.c index 9dbcef6..89c45bc 100644 --- a/src/osdnet.c +++ b/src/osdnet.c @@ -81,6 +81,29 @@ static ssize_t osn_pfwrite_vde(struct pfdata *pfdata, const void *buf, size_t nb static void osn_virt_ether(struct pfdata *pfdata, struct osnpf *osnpf); #endif /* TUN || TAP || VDE */ +/* + * Put together a string that shows which network interface methods + * are supported. + */ +char osn_networking[] = + "" +#if KLH10_NET_PCAP + " pcap" +#endif +#if KLH10_NET_TUN + " tun" +#endif +#if KLH10_NET_TAP + " tap" +#endif +#if KLH10_NET_TAP && KLH10_NET_BRIDGE + " tap+bridge" +#endif +#if KLH10_NET_VDE + " vde" +#endif + ; + /* Get a socket descriptor suitable for general net interface examination and manipulation; this is not necessarily suitable for use as a packetfilter. @@ -1379,7 +1402,8 @@ osn_pfinit(struct pfdata *pfdata, struct osnpf *osnpf, void *pfarg) } #endif /* KLH10_NET_VDE */ - esfatal(1, "Interface method \"%s\" not supported", method); + esfatal(1, "Interface method \"%s\" not supported (only%s)", + method, osn_networking); } ssize_t diff --git a/src/osdnet.h b/src/osdnet.h index 3ae6089..d69070e 100644 --- a/src/osdnet.h +++ b/src/osdnet.h @@ -60,7 +60,7 @@ # define ossock_t int /* No typedef until code revised */ #endif /* CENV_SYS_UNIX */ -#if HAVE_NET_IF_TUN_H +#if HAVE_NET_IF_TUN_H && OSN_USE_IPONLY # include # define KLH10_NET_TUN 1 #endif @@ -363,4 +363,6 @@ void osn_pfdeinit(struct pfdata *, struct osnpf *); ssize_t osn_pfread(struct pfdata *pfdata, void *buf, size_t nbytes); int osn_pfwrite(struct pfdata *pfdata, const void *buf, size_t nbytes); +extern char osn_networking[]; + #endif /* ifndef OSDNET_INCLUDED */