summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-08-21 16:21:39 +0000
committerbrian <brian@FreeBSD.org>1997-08-21 16:21:39 +0000
commit263a0e79cc4756de756f7812ae9239dfee01b6f5 (patch)
tree470b83e0d1dde5c3880dc714326a9154a6f12207 /usr.sbin
parent4d5bf5e7506b847a254ed4a60c60cf849b36fb59 (diff)
downloadFreeBSD-src-263a0e79cc4756de756f7812ae9239dfee01b6f5.zip
FreeBSD-src-263a0e79cc4756de756f7812ae9239dfee01b6f5.tar.gz
Add "set loopback on|off", defaulting to "on".
This tells ppp to loopback packets addressed to the ppp interface IP coming *from* the tun device. This means that you can ping the tun interface IP from inside :-)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/command.c26
-rw-r--r--usr.sbin/ppp/main.c24
-rw-r--r--usr.sbin/ppp/ppp.818
-rw-r--r--usr.sbin/ppp/ppp.8.m418
-rw-r--r--usr.sbin/ppp/vars.c6
-rw-r--r--usr.sbin/ppp/vars.h4
6 files changed, 88 insertions, 8 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 27237fa..c2eaf7a 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.71 1997/08/20 23:47:41 brian Exp $
+ * $Id: command.c,v 1.72 1997/08/21 16:18:07 brian Exp $
*
*/
#include <sys/types.h>
@@ -185,6 +185,17 @@ char **argv;
}
static int
+SetLoopback(struct cmdtab *cmdlist, int argc, char **argv)
+{
+ if (argc == 1)
+ if (!strcasecmp(*argv, "on"))
+ VarLoopback = 1;
+ else if (!strcasecmp(*argv, "off"))
+ VarLoopback = 0;
+ return -1;
+}
+
+static int
BgShellCommand(struct cmdtab *cmdlist, int argc, char **argv)
{
if (argc == 0)
@@ -368,6 +379,15 @@ extern int ShowModemStatus();
extern int ReportHdlcStatus();
extern int ShowMemMap();
+static int
+ShowLoopback()
+{
+ if (VarTerm)
+ fprintf(VarTerm, "Local loopback is %s\n", VarLoopback ? "on" : "off");
+
+ return 0;
+}
+
static int ShowLogLevel()
{
int i;
@@ -554,6 +574,8 @@ struct cmdtab const ShowCommands[] = {
"Show IPCP status", "show ipcp"},
{ "lcp", NULL, ReportLcpStatus, LOCAL_AUTH,
"Show LCP status", "show lcp"},
+ { "loopback", NULL, ShowLoopback, LOCAL_AUTH,
+ "Show current loopback setting", "show loopback"},
{ "log", NULL, ShowLogLevel, LOCAL_AUTH,
"Show current log level", "show log"},
{ "mem", NULL, ShowMemMap, LOCAL_AUTH,
@@ -1352,6 +1374,8 @@ struct cmdtab const SetCommands[] = {
"Set destination address", "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"},
{ "ifilter", NULL, SetIfilter, LOCAL_AUTH,
"Set input filter", "set ifilter ..."},
+ { "loopback", NULL, SetLoopback, LOCAL_AUTH,
+ "Set loopback facility", "set loopback on|off"},
{ "log", NULL, SetLogLevel, LOCAL_AUTH,
"Set log level", "set log [+|-]value..."},
{ "login", NULL, SetVariable, LOCAL_AUTH,
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 75ad657..694e6f8 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.68 1997/06/29 13:54:31 brian Exp $
+ * $Id: main.c,v 1.69 1997/07/01 21:31:23 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -51,6 +51,7 @@
#include "ip.h"
#include "sig.h"
#include "server.h"
+#include "lcpproto.h"
#define LAUTH_M1 "Warning: No password entry for this host in ppp.secret\n"
#define LAUTH_M2 "Warning: Manipulation is allowed by anyone\n"
@@ -1013,6 +1014,27 @@ DoLoop()
LogPrintf(LogERROR, "read from tun: %s", strerror(errno));
continue;
}
+
+ if (((struct ip *)rbuff)->ip_dst.s_addr == IpcpInfo.want_ipaddr.s_addr) {
+ /* we've been asked to send something addressed *to* us :( */
+ if (VarLoopback) {
+ pri = PacketCheck(rbuff, n, FL_IN);
+ if (pri >= 0) {
+ struct mbuf *bp;
+ if (mode & MODE_ALIAS) {
+ VarPacketAliasIn(rbuff, sizeof rbuff);
+ n = ntohs(((struct ip *)rbuff)->ip_len);
+ }
+ bp = mballoc(n, MB_IPIN);
+ bcopy(rbuff, MBUF_CTOP(bp), n);
+ IpInput(bp);
+ LogPrintf(LogDEBUG, "Looped back packet addressed to myself\n");
+ }
+ continue;
+ } else
+ LogPrintf(LogDEBUG, "Oops - forwarding packet addressed to myself\n");
+ }
+
/*
* Process on-demand dialup. Output packets are queued within tunnel
* device until IPCP is opened.
diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8
index f88e905..60e9384 100644
--- a/usr.sbin/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.53 1997/08/19 11:27:00 danny Exp $
+.\" $Id: ppp.8,v 1.54 1997/08/20 23:47:51 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -1644,6 +1644,19 @@ in the initial IPCP negotiation. However, only an address in the
.Dq myaddr
range will be accepted.
+.It set loopback on|off
+When set to
+.Dq on
+(the default),
+.Nm
+will automatically loop back packets being sent
+out with a destination address equal to that of the ppp interface.
+If set to
+.Dq off ,
+.Nm
+will send the packet, probably resulting in an ICMP redirect from
+the other end.
+
.It set log [+|-]value...
This command allows the adjustment of the current log level. Please
refer to the Logging Facility section for further details.
@@ -1822,6 +1835,9 @@ Show the current IPCP statistics.
.It show lcp
Show the current LCP statistics.
+.It show loopback
+Show the current loopback status.
+
.It show log
Show the current log values.
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
index f88e905..60e9384 100644
--- a/usr.sbin/ppp/ppp.8.m4
+++ b/usr.sbin/ppp/ppp.8.m4
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.53 1997/08/19 11:27:00 danny Exp $
+.\" $Id: ppp.8,v 1.54 1997/08/20 23:47:51 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@@ -1644,6 +1644,19 @@ in the initial IPCP negotiation. However, only an address in the
.Dq myaddr
range will be accepted.
+.It set loopback on|off
+When set to
+.Dq on
+(the default),
+.Nm
+will automatically loop back packets being sent
+out with a destination address equal to that of the ppp interface.
+If set to
+.Dq off ,
+.Nm
+will send the packet, probably resulting in an ICMP redirect from
+the other end.
+
.It set log [+|-]value...
This command allows the adjustment of the current log level. Please
refer to the Logging Facility section for further details.
@@ -1822,6 +1835,9 @@ Show the current IPCP statistics.
.It show lcp
Show the current LCP statistics.
+.It show loopback
+Show the current loopback status.
+
.It show log
Show the current log values.
diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c
index 4b0b375..95434fd 100644
--- a/usr.sbin/ppp/vars.c
+++ b/usr.sbin/ppp/vars.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.c,v 1.21 1997/08/17 20:45:49 brian Exp $
+ * $Id: vars.c,v 1.22 1997/08/20 23:47:52 brian Exp $
*
*/
#include "fsm.h"
@@ -30,7 +30,7 @@
#include "defs.h"
char VarVersion[] = "PPP Version 1.00";
-char VarLocalVersion[] = "$Date: 1997/08/17 20:45:49 $";
+char VarLocalVersion[] = "$Date: 1997/08/20 23:47:52 $";
/*
* Order of conf option is important. See vars.h.
@@ -52,7 +52,7 @@ struct confdesc pppConfs[] = {
struct pppvars pppVars = {
DEF_MRU, DEF_MTU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3,
RECONNECT_TIMER, RECONNECT_TRIES, REDIAL_PERIOD,
- NEXT_REDIAL_PERIOD, 1, MODEM_DEV, BASE_MODEM_DEV,
+ NEXT_REDIAL_PERIOD, 1, 1, MODEM_DEV, BASE_MODEM_DEV,
OPEN_ACTIVE, LOCAL_NO_AUTH,0
};
diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h
index ae12495..4583a2a 100644
--- a/usr.sbin/ppp/vars.h
+++ b/usr.sbin/ppp/vars.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vars.h,v 1.22 1997/08/17 20:45:50 brian Exp $
+ * $Id: vars.h,v 1.23 1997/08/20 23:47:53 brian Exp $
*
* TODO:
*/
@@ -68,6 +68,7 @@ struct pppvars {
int redial_timeout; /* Redial timeout value */
int redial_next_timeout; /* Redial next timeout value */
int dial_tries; /* Dial attempts before giving up, 0 == inf */
+ int loopback; /* Turn around packets addressed to me */
char modem_dev[40]; /* Name of device / host:port */
char *base_modem_dev; /* Pointer to base of modem_dev */
int open_mode; /* LCP open mode */
@@ -118,6 +119,7 @@ struct pppvars {
#define VarRedialTimeout pppVars.redial_timeout
#define VarRedialNextTimeout pppVars.redial_next_timeout
#define VarDialTries pppVars.dial_tries
+#define VarLoopback pppVars.loopback
#define VarTerm pppVars.termfp
#define VarAliasHandlers pppVars.handler
OpenPOWER on IntegriCloud