diff options
author | rzalamena <rzalamena@openbsd.org> | 2016-12-16 18:38:39 +0000 |
---|---|---|
committer | rzalamena <rzalamena@openbsd.org> | 2016-12-16 18:38:39 +0000 |
commit | c4c35e14af8ef182d875e0171e08f0bf66abdfb2 (patch) | |
tree | 12e421adea020aea9b53279951908f20efbb7a41 /usr.sbin/dhcrelay | |
parent | Move declaration of an 'i' inside the scope of its use. Which in (diff) | |
download | wireguard-openbsd-c4c35e14af8ef182d875e0171e08f0bf66abdfb2.tar.xz wireguard-openbsd-c4c35e14af8ef182d875e0171e08f0bf66abdfb2.zip |
Add dhcrelay(8) command-line option for replacing Relay Agent Information
on the incoming packets.
Man page tweaks from jmc@
ok reyk@
Diffstat (limited to 'usr.sbin/dhcrelay')
-rw-r--r-- | usr.sbin/dhcrelay/dhcrelay.8 | 8 | ||||
-rw-r--r-- | usr.sbin/dhcrelay/dhcrelay.c | 18 |
2 files changed, 18 insertions, 8 deletions
diff --git a/usr.sbin/dhcrelay/dhcrelay.8 b/usr.sbin/dhcrelay/dhcrelay.8 index 049981e439d..97c774b39e8 100644 --- a/usr.sbin/dhcrelay/dhcrelay.8 +++ b/usr.sbin/dhcrelay/dhcrelay.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: dhcrelay.8,v 1.14 2016/12/13 06:55:32 jmc Exp $ +.\" $OpenBSD: dhcrelay.8,v 1.15 2016/12/16 18:38:39 rzalamena Exp $ .\" .\" Copyright (c) 1997 The Internet Software Consortium. .\" All rights reserved. @@ -36,7 +36,7 @@ .\" see ``http://www.isc.org/isc''. To learn more about Vixie .\" Enterprises, see ``http://www.vix.com''. .\" -.Dd $Mdocdate: December 13 2016 $ +.Dd $Mdocdate: December 16 2016 $ .Dt DHCRELAY 8 .Os .Sh NAME @@ -44,7 +44,7 @@ .Nd Dynamic Host Configuration Protocol relay agent .Sh SYNOPSIS .Nm -.Op Fl do +.Op Fl dor .Op Fl C Ar circuit-id .Op Fl R Ar remote-id .Fl i Ar interface @@ -118,6 +118,8 @@ relay agent information sub-option value that .Nm should append on relayed packets. If this option is not specified it will use the destination address by default. +.It Fl r +Replace incoming Relay Agent Information with the one configured. .El .Sh SEE ALSO .Xr dhclient 8 , diff --git a/usr.sbin/dhcrelay/dhcrelay.c b/usr.sbin/dhcrelay/dhcrelay.c index edf372b97e7..1072d219c1c 100644 --- a/usr.sbin/dhcrelay/dhcrelay.c +++ b/usr.sbin/dhcrelay/dhcrelay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcrelay.c,v 1.54 2016/12/13 17:40:41 rzalamena Exp $ */ +/* $OpenBSD: dhcrelay.c,v 1.55 2016/12/16 18:38:39 rzalamena Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org> @@ -94,6 +94,7 @@ int oflag; enum dhcp_relay_mode drm = DRM_UNKNOWN; const char *rai_circuit = NULL; const char *rai_remote = NULL; +int rai_replace = 0; struct server_list { struct interface_info *intf; @@ -118,7 +119,7 @@ main(int argc, char *argv[]) openlog(__progname, LOG_NDELAY, DHCPD_LOG_FACILITY); setlogmask(LOG_UPTO(LOG_INFO)); - while ((ch = getopt(argc, argv, "aC:di:oR:")) != -1) { + while ((ch = getopt(argc, argv, "aC:di:oR:r")) != -1) { switch (ch) { case 'C': rai_circuit = optarg; @@ -141,6 +142,9 @@ main(int argc, char *argv[]) case 'R': rai_remote = optarg; break; + case 'r': + rai_replace = 1; + break; default: usage(); @@ -444,7 +448,7 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-do] [-C circuit-id] [-R remote-id] " + fprintf(stderr, "usage: %s [-dor] [-C circuit-id] [-R remote-id] " "-i interface\n\tdestination ...\n", __progname); exit(1); @@ -675,8 +679,12 @@ relay_agentinfo_append(struct packet_ctx *pc, struct dhcp_packet *dp, } if (*p == DHO_RELAY_AGENT_INFORMATION) { - hasinfo = 1; - continue; + if (rai_replace) { + memmove(p, p + optlen, opttotal - i); + opttotal -= optlen; + optlen = 0; + } else + hasinfo = 1; } p += optlen; |