diff options
author | Bjorn Ketelaars <bket@cvs.openbsd.org> | 2021-11-17 18:00:25 +0000 |
---|---|---|
committer | Bjorn Ketelaars <bket@cvs.openbsd.org> | 2021-11-17 18:00:25 +0000 |
commit | 5a08e63c481796d71cd9db77f29c4619baae2c11 (patch) | |
tree | 02ab26ea0f161a1f20b8bacc8448b70e7b57004b | |
parent | 575e625eaf18fc2ccb81b4a2f7645fd757e7298c (diff) |
Display DNS information from sppp(4) in ifconfig(8)
Behaviour is similar to that of umb(4).
OK kn@
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 27 | ||||
-rw-r--r-- | sys/net/if_sppp.h | 13 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 19 |
3 files changed, 54 insertions, 5 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index e02c0550b4f..ae58b9e65c9 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.449 2021/11/11 09:39:16 claudio Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.450 2021/11/17 18:00:24 bket Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -718,6 +718,7 @@ u_int getwpacipher(const char *); void print_cipherset(u_int32_t); void spppauthinfo(struct sauthreq *, int); +void spppdnsinfo(struct sdnsreq *); /* Known address families */ const struct afswtch { @@ -5455,6 +5456,17 @@ spppauthinfo(struct sauthreq *spa, int d) } void +spppdnsinfo(struct sdnsreq *spd) +{ + memset(spd, 0, sizeof(*spd)); + + ifr.ifr_data = (caddr_t)spd; + spd->cmd = SPPPIOGDNS; + if (ioctl(sock, SIOCGSPPPPARAMS, &ifr) == -1) + err(1, "SIOCGSPPPPARAMS(SPPPIOGDNS)"); +} + +void setspppproto(const char *val, int d) { struct sauthreq spa; @@ -5588,6 +5600,9 @@ sppp_status(void) { struct spppreq spr; struct sauthreq spa; + struct sdnsreq spd; + char astr[INET_ADDRSTRLEN]; + int i, n; bzero(&spr, sizeof(spr)); @@ -5627,6 +5642,16 @@ sppp_status(void) if (spa.flags & AUTHFLAG_NORECHALLENGE) printf("norechallenge "); putchar('\n'); + + spppdnsinfo(&spd); + for (i = 0, n = 0; i < IPCP_MAX_DNSSRV; i++) { + if (spd.dns[i].s_addr == INADDR_ANY) + break; + printf("%s %s", n++ ? "" : "\tdns:", + inet_ntop(AF_INET, &spd.dns[i], astr, sizeof(astr))); + } + if (n) + printf("\n"); } void diff --git a/sys/net/if_sppp.h b/sys/net/if_sppp.h index 6b5e7d41a4a..40debe45138 100644 --- a/sys/net/if_sppp.h +++ b/sys/net/if_sppp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sppp.h,v 1.29 2021/11/10 15:04:26 bket Exp $ */ +/* $OpenBSD: if_sppp.h,v 1.30 2021/11/17 18:00:24 bket Exp $ */ /* $NetBSD: if_sppp.h,v 1.2.2.1 1999/04/04 06:57:39 explorer Exp $ */ /* @@ -82,12 +82,21 @@ struct spppreq { enum ppp_phase phase; /* phase we're currently in */ }; +#include <netinet/in.h> + +#define IPCP_MAX_DNSSRV 2 +struct sdnsreq { + int cmd; + struct in_addr dns[IPCP_MAX_DNSSRV]; +}; + #define SPPPIOGDEFS ((int)(('S' << 24) + (1 << 16) + sizeof(struct spppreq))) #define SPPPIOSDEFS ((int)(('S' << 24) + (2 << 16) + sizeof(struct spppreq))) #define SPPPIOGMAUTH ((int)(('S' << 24) + (3 << 16) + sizeof(struct sauthreq))) #define SPPPIOSMAUTH ((int)(('S' << 24) + (4 << 16) + sizeof(struct sauthreq))) #define SPPPIOGHAUTH ((int)(('S' << 24) + (5 << 16) + sizeof(struct sauthreq))) #define SPPPIOSHAUTH ((int)(('S' << 24) + (6 << 16) + sizeof(struct sauthreq))) +#define SPPPIOGDNS ((int)(('S' << 24) + (7 << 16) + sizeof(struct sdnsreq))) #ifdef _KERNEL @@ -96,7 +105,6 @@ struct spppreq { #include <sys/task.h> #ifdef INET6 -#include <netinet/in.h> #include <netinet6/in6_var.h> #endif @@ -132,7 +140,6 @@ struct sipcp { * original one here, in network byte order */ u_int32_t req_hisaddr; /* remote address requested (IPv4) */ u_int32_t req_myaddr; /* local address requested (IPv4) */ -#define IPCP_MAX_DNSSRV 2 struct in_addr dns[IPCP_MAX_DNSSRV]; /* IPv4 DNS servers (RFC 1877) */ #ifdef INET6 struct in6_aliasreq req_ifid; /* local ifid requested (IPv6) */ diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 759370e7be7..3982c29bbdc 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.189 2021/11/10 20:24:22 bket Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.190 2021/11/17 18:00:24 bket Exp $ */ /* * Synchronous PPP link level subroutines. * @@ -4561,6 +4561,23 @@ sppp_get_params(struct sppp *sp, struct ifreq *ifr) free(spa, M_DEVBUF, sizeof(*spa)); break; } + case SPPPIOGDNS: + { + struct sdnsreq *spd; + + spd = malloc(sizeof(*spd), M_DEVBUF, M_WAITOK); + + spd->cmd = cmd; + memcpy(spd->dns, sp->ipcp.dns, sizeof(spd->dns)); + + if (copyout(spd, (caddr_t)ifr->ifr_data, sizeof(*spd)) != 0) { + free(spd, M_DEVBUF, 0); + return EFAULT; + } + + free(spd, M_DEVBUF, sizeof(*spd)); + break; + } default: return EINVAL; } |