mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
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 :-)
This commit is contained in:
parent
91fc7145dc
commit
de451c685c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28536
@ -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>
|
||||
@ -184,6 +184,17 @@ char **argv;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user