Support client side DNS server negotiation, disabled

and denied by default (POLA).

o Remove ``enable'' msext.  Now, doing a ``set nbns'' will
  automatically enable a NBNS ACK/NAK rather than a REJ.
o Add accept|disable|deny|enable dns.  If we ``accept'',
  we'll tell the peer what our nameservers are (if he asks).
  The values in resolv.conf can be overridden with the
  ``set dns'' command.  If we ``enable'', we'll REQ using
  our resolv.conf entries, and any NAKs are written back to
  resolv.conf.
o Remove ``show msext'' and show the relevent IP numbers in
  ``show ipcp''.
This commit is contained in:
Brian Somers 1998-04-17 22:05:37 +00:00
parent 030e4ebba8
commit 3edeb0c69e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35255
8 changed files with 323 additions and 208 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.c,v 1.1.2.50 1998/04/16 23:06:53 brian Exp $
* $Id: bundle.c,v 1.1.2.51 1998/04/17 22:04:18 brian Exp $
*/
#include <sys/types.h>
@ -871,8 +871,6 @@ bundle_ShowStatus(struct cmdargs const *arg)
optval(arg->bundle, OPT_IDCHECK));
prompt_Printf(arg->prompt, " Loopback: %s\n",
optval(arg->bundle, OPT_LOOPBACK));
prompt_Printf(arg->prompt, " MS Ext: %s\n",
optval(arg->bundle, OPT_MSEXT));
prompt_Printf(arg->prompt, " PasswdAuth: %s\n",
optval(arg->bundle, OPT_PASSWDAUTH));
prompt_Printf(arg->prompt, " Proxy: %s\n",

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.h,v 1.1.2.29 1998/04/16 00:25:50 brian Exp $
* $Id: bundle.h,v 1.1.2.30 1998/04/17 22:04:22 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@ -35,11 +35,10 @@
/* cfg.opt bit settings */
#define OPT_IDCHECK 0x01
#define OPT_LOOPBACK 0x02
#define OPT_MSEXT 0x04
#define OPT_PASSWDAUTH 0x08
#define OPT_PROXY 0x10
#define OPT_THROUGHPUT 0x20
#define OPT_UTMP 0x40
#define OPT_PASSWDAUTH 0x04
#define OPT_PROXY 0x08
#define OPT_THROUGHPUT 0x10
#define OPT_UTMP 0x20
#define Enabled(b, o) ((b)->cfg.opt & (o))

View File

@ -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.131.2.61 1998/04/16 00:25:53 brian Exp $
* $Id: command.c,v 1.131.2.62 1998/04/16 18:30:50 brian Exp $
*
*/
#include <sys/types.h>
@ -101,6 +101,8 @@
#define VAR_PAPRETRY 17
#define VAR_CCPRETRY 18
#define VAR_IPCPRETRY 19
#define VAR_DNS 20
#define VAR_NBNS 21
/* ``accept|deny|disable|enable'' masks */
#define NEG_HISMASK (1)
@ -116,6 +118,7 @@
#define NEG_PRED1 46
#define NEG_PROTOCOMP 47
#define NEG_VJCOMP 48
#define NEG_DNS 49
static int ShowCommand(struct cmdargs const *);
static int TerminalCommand(struct cmdargs const *);
@ -497,7 +500,7 @@ static int
ShowVersion(struct cmdargs const *arg)
{
static char VarVersion[] = "PPP Version 2.0-beta";
static char VarLocalVersion[] = "$Date: 1998/04/16 00:25:53 $";
static char VarLocalVersion[] = "$Date: 1998/04/16 18:30:50 $";
prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
return 0;
@ -513,26 +516,6 @@ ShowProtocolStats(struct cmdargs const *arg)
return 0;
}
#ifndef NOMSEXT
static int
ShowMSExt(struct cmdargs const *arg)
{
prompt_Printf(arg->prompt, " MS PPP extention values \n");
prompt_Printf(arg->prompt, " Primary NS : %s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[0]));
prompt_Printf(arg->prompt, " Secondary NS : %s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[1]));
prompt_Printf(arg->prompt, " Primary NBNS : %s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.nbns_entries[0]));
prompt_Printf(arg->prompt, " Secondary NBNS : %s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.nbns_entries[1]));
return 0;
}
#endif
static struct cmdtab const ShowCommands[] = {
{"bundle", NULL, bundle_ShowStatus, LOCAL_AUTH,
"Show bundle details", "show bundle"},
@ -558,10 +541,6 @@ static struct cmdtab const ShowCommands[] = {
"Show memory map", "show mem"},
{"modem", NULL, modem_ShowStatus, LOCAL_AUTH | LOCAL_CX,
"Show modem setups", "show modem"},
#ifndef NOMSEXT
{"msext", NULL, ShowMSExt, LOCAL_AUTH,
"Show MS PPP extentions", "show msext"},
#endif
{"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT,
"Show protocol summary", "show proto"},
{"route", NULL, ShowRoute, LOCAL_AUTH,
@ -1030,54 +1009,6 @@ SetInterfaceAddr(struct cmdargs const *arg)
return 0;
}
#ifndef NOMSEXT
static void
SetMSEXT(struct ipcp *ipcp, struct in_addr * pri_addr,
struct in_addr * sec_addr, int argc, char const *const *argv)
{
int dummyint;
struct in_addr dummyaddr;
pri_addr->s_addr = sec_addr->s_addr = 0L;
if (argc > 0) {
ParseAddr(ipcp, argc, argv++, pri_addr, &dummyaddr, &dummyint);
if (--argc > 0)
ParseAddr(ipcp, argc, argv++, sec_addr, &dummyaddr, &dummyint);
else
sec_addr->s_addr = pri_addr->s_addr;
}
/*
* if the primary/secondary ns entries are 0.0.0.0 we should set them to
* either the localhost's ip, or the values in /etc/resolv.conf ??
*
* up to you if you want to implement this...
*/
}
static int
SetNS(struct cmdargs const *arg)
{
SetMSEXT(&arg->bundle->ncp.ipcp, &arg->bundle->ncp.ipcp.cfg.ns_entries[0],
&arg->bundle->ncp.ipcp.cfg.ns_entries[1], arg->argc - arg->argn,
arg->argv + arg->argn);
return 0;
}
static int
SetNBNS(struct cmdargs const *arg)
{
SetMSEXT(&arg->bundle->ncp.ipcp, &arg->bundle->ncp.ipcp.cfg.nbns_entries[0],
&arg->bundle->ncp.ipcp.cfg.nbns_entries[1], arg->argc - arg->argn,
arg->argv + arg->argn);
return 0;
}
#endif /* MS_EXT */
static int
SetVariable(struct cmdargs const *arg)
{
@ -1087,6 +1018,8 @@ SetVariable(struct cmdargs const *arg)
struct datalink *cx = arg->cx; /* AUTH_CX uses this */
const char *err = NULL;
struct link *l = ChooseLink(arg); /* AUTH_CX_OPT uses this */
int dummyint;
struct in_addr dummyaddr, *addr;
if (arg->argc > arg->argn)
argp = arg->argv[arg->argn];
@ -1268,6 +1201,28 @@ SetVariable(struct cmdargs const *arg)
} else
arg->bundle->ncp.ipcp.cfg.fsmretry = ulong_val;
break;
case VAR_NBNS:
case VAR_DNS:
if (param == VAR_DNS)
addr = arg->bundle->ncp.ipcp.cfg.ns.dns;
else
addr = arg->bundle->ncp.ipcp.cfg.ns.nbns;
addr[0].s_addr = addr[1].s_addr = INADDR_ANY;
if (arg->argc > arg->argn) {
ParseAddr(&arg->bundle->ncp.ipcp, 1, arg->argv + arg->argn,
addr, &dummyaddr, &dummyint);
if (arg->argc > arg->argn+1)
ParseAddr(&arg->bundle->ncp.ipcp, 1, arg->argv + arg->argn + 1,
addr + 1, &dummyaddr, &dummyint);
if (addr[1].s_addr == INADDR_ANY)
addr[1].s_addr = addr[0].s_addr;
if (addr[0].s_addr == INADDR_ANY)
addr[0].s_addr = addr[1].s_addr;
}
break;
}
return err ? 1 : 0;
@ -1309,6 +1264,8 @@ static struct cmdtab const SetCommands[] = {
(const void *) VAR_DEVICE},
{"dial", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
"Set dialing script", "set dial chat-script", (const void *) VAR_DIAL},
{"dns", NULL, SetVariable, LOCAL_AUTH, "Set Domain Name Server",
"set dns pri-addr [sec-addr]", (const void *)VAR_DNS},
{"encrypt", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
"Select CHAP encryption type", "set encrypt MSChap|MD5",
(const void *)VAR_ENC},
@ -1336,12 +1293,8 @@ static struct cmdtab const SetCommands[] = {
"Set MRU value", "set mru value", (const void *)VAR_MRU},
{"mtu", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT,
"Set MTU value", "set mtu value", (const void *)VAR_MTU},
#ifndef NOMSEXT
{"nbns", NULL, SetNBNS, LOCAL_AUTH,
"Set NetBIOS NameServer", "set nbns pri-addr [sec-addr]"},
{"ns", NULL, SetNS, LOCAL_AUTH,
"Set NameServer", "set ns pri-addr [sec-addr]"},
#endif
{"nbns", NULL, SetVariable, LOCAL_AUTH, "Set NetBIOS Name Server",
"set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS},
{"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set open mode",
"set openmode active|passive [secs]", (const void *)VAR_OPENMODE},
{"papretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
@ -1691,6 +1644,10 @@ NegotiateSet(struct cmdargs const *arg)
l->ccp.cfg.neg[CCP_NEG_DEFLATE] &= keep;
l->ccp.cfg.neg[CCP_NEG_DEFLATE] |= add;
break;
case NEG_DNS:
arg->bundle->ncp.ipcp.cfg.ns.dns_neg &= keep;
arg->bundle->ncp.ipcp.cfg.ns.dns_neg |= add;
break;
case NEG_LQR:
cx->physical->link.lcp.cfg.lqr &= keep;
cx->physical->link.lcp.cfg.lqr |= add;
@ -1721,12 +1678,10 @@ NegotiateSet(struct cmdargs const *arg)
}
static struct cmdtab const NegotiateCommands[] = {
{"idcheck", NULL, OptSet, LOCAL_AUTH, "Check reply FSM ids",
{"idcheck", NULL, OptSet, LOCAL_AUTH, "Check FSM reply ids",
"disable|enable", (const void *)OPT_IDCHECK},
{"loopback", NULL, OptSet, LOCAL_AUTH, "Loop packets for local iface",
"disable|enable", (const void *)OPT_LOOPBACK},
{"msext", NULL, OptSet, LOCAL_AUTH, "Send NS & NBNS values",
"disable|enable", (const void *)OPT_MSEXT},
{"passwdauth", NULL, OptSet, LOCAL_AUTH, "Use passwd file",
"disable|enable", (const void *)OPT_PASSWDAUTH},
{"proxy", NULL, OptSet, LOCAL_AUTH, "Create proxy ARP entry",
@ -1736,7 +1691,7 @@ static struct cmdtab const NegotiateCommands[] = {
{"utmp", NULL, OptSet, LOCAL_AUTH, "Log connections in utmp",
"disable|enable", (const void *)OPT_UTMP},
#define OPT_MAX 7 /* accept/deny allowed below and not above */
#define OPT_MAX 6 /* accept/deny allowed below and not above */
{"acfcomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
"Address & Control field compression", "accept|deny|disable|enable",
@ -1747,15 +1702,17 @@ static struct cmdtab const NegotiateCommands[] = {
{"deflate", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
"Deflate compression", "accept|deny|disable|enable",
(const void *)NEG_DEFLATE},
{"deflate24", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
"Deflate (type 24) compression", "accept|deny|disable|enable",
(const void *)NEG_PPPDDEFLATE},
{"dns", NULL, NegotiateSet, LOCAL_AUTH,
"DNS specification", "accept|deny|disable|enable", (const void *)NEG_DNS},
{"lqr", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
"Link Quality Reports", "accept|deny|disable|enable",
(const void *)NEG_LQR},
{"pap", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
"Password Authentication protocol", "accept|deny|disable|enable",
(const void *)NEG_PAP},
{"deflate24", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
"Deflate (type 24) compression", "accept|deny|disable|enable",
(const void *)NEG_PPPDDEFLATE},
{"pred1", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT,
"Predictor 1 compression", "accept|deny|disable|enable",
(const void *)NEG_PRED1},
@ -1789,8 +1746,8 @@ NegotiateCommand(struct cmdargs const *arg)
0 : OPT_MAX), 2, 1, argv, arg->prompt, arg->cx);
}
} else if (arg->prompt)
prompt_Printf(arg->prompt, "Use `%s ?' to get a list or `%s ? <var>' for"
" syntax help.\n", arg->argv[arg->argn], arg->argv[arg->argn] );
prompt_Printf(arg->prompt, "Use `%s ?' to get a list.\n",
arg->argv[arg->argn-1]);
else
LogPrintf(LogWARN, "%s command must have arguments\n",
arg->argv[arg->argn] );

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: id.c,v 1.6.4.3 1998/04/06 09:12:28 brian Exp $
* $Id: id.c,v 1.6.4.4 1998/04/07 00:53:45 brian Exp $
*/
#include <sys/types.h>
@ -31,6 +31,7 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
@ -128,14 +129,17 @@ ID0fopen(const char *path, const char *mode)
}
int
ID0open(const char *path, int flags)
ID0open(const char *path, int flags, ...)
{
int ret;
va_list ap;
va_start(ap, flags);
ID0set0();
ret = open(path, flags);
ret = open(path, flags, va_arg(ap, int));
LogPrintf(LogID0, "%d = open(\"%s\", %d)\n", ret, path, flags);
ID0setuser();
va_end(ap);
return ret;
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: id.h,v 1.3 1997/12/27 19:23:13 brian Exp $
* $Id: id.h,v 1.3.4.1 1998/02/19 02:08:47 brian Exp $
*/
struct utmp;
@ -34,7 +34,7 @@ extern int ID0ioctl(int, unsigned long, void *);
extern int ID0unlink(const char *);
extern int ID0socket(int, int, int);
extern FILE *ID0fopen(const char *, const char *);
extern int ID0open(const char *, int);
extern int ID0open(const char *, int, ...);
extern int ID0write(int, const void *, size_t);
extern int ID0uu_lock(const char *);
extern int ID0uu_unlock(const char *);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.c,v 1.50.2.36 1998/04/14 23:17:07 brian Exp $
* $Id: ipcp.c,v 1.50.2.37 1998/04/16 00:26:00 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
@ -32,6 +32,8 @@
#include <net/if.h>
#include <sys/sockio.h>
#include <fcntl.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -70,6 +72,8 @@
#undef REJECTED
#define REJECTED(p, x) ((p)->peer_reject & (1<<(x)))
#define issep(ch) ((ch) == ' ' || (ch) == '\t')
#define isip(ch) (((ch) >= '0' && (ch) <= '9') || (ch) == '.')
struct compreq {
u_short proto;
@ -135,6 +139,118 @@ ipcp_AddOutOctets(struct ipcp *ipcp, int n)
throughput_addout(&ipcp->throughput, n);
}
static void
getdns(struct ipcp *ipcp, struct in_addr addr[2])
{
FILE *fp;
addr[0].s_addr = addr[1].s_addr = INADDR_ANY;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
char buf[LINE_LEN], *cp, *end;
int n;
n = 0;
buf[sizeof buf - 1] = '\0';
while (fgets(buf, sizeof buf - 1, fp)) {
if (!strncmp(buf, "nameserver", 10) && issep(buf[10])) {
for (cp = buf + 11; issep(*cp); cp++)
;
for (end = cp; isip(*end); end++)
;
*end = '\0';
if (inet_aton(cp, addr+n) && ++n == 2)
break;
}
}
if (n == 1)
addr[1] = addr[0];
fclose(fp);
}
}
static int
setdns(struct ipcp *ipcp, struct in_addr addr[2])
{
FILE *fp;
char wbuf[LINE_LEN + 54];
int wlen;
if (addr[0].s_addr == INADDR_ANY || addr[1].s_addr == INADDR_ANY) {
struct in_addr old[2];
getdns(ipcp, old);
if (addr[0].s_addr == INADDR_ANY)
addr[0] = old[0];
if (addr[1].s_addr == INADDR_ANY)
addr[1] = old[1];
}
if (addr[0].s_addr == INADDR_ANY && addr[1].s_addr == INADDR_ANY) {
LogPrintf(LogWARN, "%s not modified: All nameservers NAKd\n",
_PATH_RESCONF);
return 0;
}
wlen = 0;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
char buf[LINE_LEN];
int len;
buf[sizeof buf - 1] = '\0';
while (fgets(buf, sizeof buf - 1, fp)) {
if (strncmp(buf, "nameserver", 10) || !issep(buf[10])) {
len = strlen(buf);
if (len > sizeof wbuf - wlen) {
LogPrintf(LogWARN, "%s: Can only cope with max file size %d\n",
_PATH_RESCONF, LINE_LEN);
fclose(fp);
return 0;
}
memcpy(wbuf + wlen, buf, len);
wlen += len;
}
}
fclose(fp);
}
if (addr[0].s_addr != INADDR_ANY) {
snprintf(wbuf + wlen, sizeof wbuf - wlen, "nameserver %s\n",
inet_ntoa(addr[0]));
LogPrintf(LogIPCP, "Primary nameserver set to %s", wbuf + wlen + 11);
wlen += strlen(wbuf + wlen);
}
if (addr[1].s_addr != INADDR_ANY && addr[1].s_addr != addr[0].s_addr) {
snprintf(wbuf + wlen, sizeof wbuf - wlen, "nameserver %s\n",
inet_ntoa(addr[1]));
LogPrintf(LogIPCP, "Secondary nameserver set to %s", wbuf + wlen + 11);
wlen += strlen(wbuf + wlen);
}
if (wlen) {
int fd;
if ((fd = ID0open(_PATH_RESCONF, O_WRONLY|O_CREAT, 0644)) != -1) {
if (write(fd, wbuf, wlen) != wlen) {
LogPrintf(LogERROR, "setdns: write(): %s\n", strerror(errno));
close(fd);
return 0;
}
if (ftruncate(fd, wlen) == -1) {
LogPrintf(LogERROR, "setdns: truncate(): %s\n", strerror(errno));
close(fd);
return 0;
}
close(fd);
} else {
LogPrintf(LogERROR, "setdns: open(): %s\n", strerror(errno));
return 0;
}
}
return 1;
}
int
ReportIpcpStatus(struct cmdargs const *arg)
{
@ -151,15 +267,23 @@ ReportIpcpStatus(struct cmdargs const *arg)
prompt_Printf(arg->prompt, "\nDefaults:\n");
prompt_Printf(arg->prompt, " My Address: %s/%d\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.my_range.ipaddr),
arg->bundle->ncp.ipcp.cfg.my_range.width);
inet_ntoa(arg->bundle->ncp.ipcp.cfg.my_range.ipaddr),
arg->bundle->ncp.ipcp.cfg.my_range.width);
if (iplist_isvalid(&arg->bundle->ncp.ipcp.cfg.peer_list))
prompt_Printf(arg->prompt, " His Address: %s\n",
arg->bundle->ncp.ipcp.cfg.peer_list.src);
arg->bundle->ncp.ipcp.cfg.peer_list.src);
else
prompt_Printf(arg->prompt, " His Address: %s/%d\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.peer_range.ipaddr),
arg->bundle->ncp.ipcp.cfg.peer_range.width);
inet_ntoa(arg->bundle->ncp.ipcp.cfg.peer_range.ipaddr),
arg->bundle->ncp.ipcp.cfg.peer_range.width);
prompt_Printf(arg->prompt, " DNS: %s, ",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns.dns[0]));
prompt_Printf(arg->prompt, "%s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns.dns[1]));
prompt_Printf(arg->prompt, " NetBIOS NS: %s, ",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns.nbns[0]));
prompt_Printf(arg->prompt, "%s\n",
inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns.nbns[1]));
prompt_Printf(arg->prompt, "\nNegotiation:\n");
if (arg->bundle->ncp.ipcp.cfg.HaveTriggerAddress)
@ -168,11 +292,13 @@ ReportIpcpStatus(struct cmdargs const *arg)
else
prompt_Printf(arg->prompt, " Trigger Address: MYADDR\n");
prompt_Printf(arg->prompt, " VJ compression: %s (%d slots %s slot compression)\n",
prompt_Printf(arg->prompt, " DNS: %s\n",
command_ShowNegval(arg->bundle->ncp.ipcp.cfg.ns.dns_neg));
prompt_Printf(arg->prompt, " VJ compression: %s (%d slots %s slot "
"compression)\n",
command_ShowNegval(arg->bundle->ncp.ipcp.cfg.vj.neg),
arg->bundle->ncp.ipcp.cfg.vj.slots,
arg->bundle->ncp.ipcp.cfg.vj.slotcomp ? "with" : "without"
);
arg->bundle->ncp.ipcp.cfg.vj.slotcomp ? "with" : "without");
prompt_Printf(arg->prompt, "\n");
throughput_disp(&arg->bundle->ncp.ipcp.throughput, arg->prompt);
@ -233,12 +359,11 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l,
iplist_setsrc(&ipcp->cfg.peer_list, "");
ipcp->cfg.HaveTriggerAddress = 0;
#ifndef NOMSEXT
ipcp->cfg.ns_entries[0].s_addr = INADDR_ANY;
ipcp->cfg.ns_entries[1].s_addr = INADDR_ANY;
ipcp->cfg.nbns_entries[0].s_addr = INADDR_ANY;
ipcp->cfg.nbns_entries[1].s_addr = INADDR_ANY;
#endif
ipcp->cfg.ns.dns[0].s_addr = INADDR_ANY;
ipcp->cfg.ns.dns[1].s_addr = INADDR_ANY;
ipcp->cfg.ns.dns_neg = 0;
ipcp->cfg.ns.nbns[0].s_addr = INADDR_ANY;
ipcp->cfg.ns.nbns[1].s_addr = INADDR_ANY;
ipcp->cfg.fsmretry = DEF_FSMRETRY;
ipcp->cfg.vj.neg = NEG_ENABLED|NEG_ACCEPTED;
@ -424,7 +549,7 @@ IpcpSendConfigReq(struct fsm *fp)
/* Send config REQ please */
struct physical *p = link2physical(fp->link);
struct ipcp *ipcp = fsm2ipcp(fp);
u_char buff[12];
u_char buff[24];
struct lcp_opt *o;
o = (struct lcp_opt *)buff;
@ -443,6 +568,17 @@ IpcpSendConfigReq(struct fsm *fp)
INC_LCP_OPT(TY_COMPPROTO, 6, o);
}
if (IsEnabled(ipcp->cfg.ns.dns_neg) &&
!REJECTED(ipcp, TY_PRIMARY_DNS - TY_ADJUST_NS) &&
!REJECTED(ipcp, TY_SECONDARY_DNS - TY_ADJUST_NS)) {
struct in_addr dns[2];
getdns(ipcp, dns);
*(u_int32_t *)o->data = dns[0].s_addr;
INC_LCP_OPT(TY_PRIMARY_DNS, 6, o);
*(u_int32_t *)o->data = dns[1].s_addr;
INC_LCP_OPT(TY_SECONDARY_DNS, 6, o);
}
FsmOutput(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff);
}
@ -608,8 +744,13 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
int type, length;
u_long *lp, compproto;
struct compreq *pcomp;
struct in_addr ipaddr, dstipaddr, dnsstuff, ms_info_req;
struct in_addr ipaddr, dstipaddr, have_ip, dns[2], dnsnak[2];
char tbuff[100], tbuff2[100];
int gotdns, gotdnsnak;
gotdns = 0;
gotdnsnak = 0;
dnsnak[0].s_addr = dnsnak[1].s_addr = INADDR_ANY;
while (plen >= sizeof(struct fsmconfig)) {
type = *cp;
@ -785,85 +926,84 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
}
break;
/*
* MS extensions for MS's PPP
*/
#ifndef NOMSEXT
case TY_PRIMARY_DNS: /* MS PPP DNS negotiation hack */
case TY_PRIMARY_DNS: /* DNS negotiation (rfc1877) */
case TY_SECONDARY_DNS:
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
switch (mode_type) {
case MODE_REQ:
if (Enabled(ipcp->fsm.bundle, OPT_MSEXT)) {
LogPrintf(LogIPCP, "MS NS req - rejected - msext disabled\n");
ipcp->my_reject |= (1 << type);
if (!IsAccepted(ipcp->cfg.ns.dns_neg)) {
ipcp->my_reject |= (1 << (type - TY_ADJUST_NS));
memcpy(dec->rejend, cp, length);
dec->rejend += length;
break;
}
lp = (u_long *) (cp + 2);
dnsstuff.s_addr = *lp;
ms_info_req.s_addr = ipcp->cfg.ns_entries
[(type - TY_PRIMARY_DNS) ? 1 : 0].s_addr;
if (dnsstuff.s_addr != ms_info_req.s_addr) {
if (!gotdns) {
dns[0] = ipcp->cfg.ns.dns[0];
dns[1] = ipcp->cfg.ns.dns[1];
if (dns[0].s_addr == INADDR_ANY && dns[1].s_addr == INADDR_ANY)
getdns(ipcp, dns);
gotdns = 1;
}
have_ip = dns[type == TY_PRIMARY_DNS ? 0 : 1];
if (ipaddr.s_addr != have_ip.s_addr) {
/*
* So the client has got the DNS stuff wrong (first request) so
* The client has got the DNS stuff wrong (first request) so
* we'll tell 'em how it is
*/
memcpy(dec->nakend, cp, 2); /* copy first two (type/length) */
LogPrintf(LogIPCP, "MS NS req %d:%s->%s - nak\n",
type, inet_ntoa(dnsstuff), inet_ntoa(ms_info_req));
memcpy(dec->nakend+2, &ms_info_req, length);
memcpy(dec->nakend + 2, &have_ip.s_addr, length - 2);
dec->nakend += length;
break;
}
/*
* Otherwise they have it right (this time) so we send a ack packet
* back confirming it... end of story
*/
LogPrintf(LogIPCP, "MS NS req %d:%s ok - ack\n",
type, inet_ntoa(ms_info_req));
memcpy(dec->ackend, cp, length);
dec->ackend += length;
} else {
/*
* Otherwise they have it right (this time) so we send a ack packet
* back confirming it... end of story
*/
memcpy(dec->ackend, cp, length);
dec->ackend += length;
}
break;
case MODE_NAK: /* what does this mean?? */
LogPrintf(LogIPCP, "MS NS req %d - NAK??\n", type);
if (IsEnabled(ipcp->cfg.ns.dns_neg)) {
gotdnsnak = 1;
dnsnak[type == TY_PRIMARY_DNS ? 0 : 1].s_addr =
*(u_int32_t *)(cp + 2);
}
break;
case MODE_REJ: /* confused?? me to :) */
LogPrintf(LogIPCP, "MS NS req %d - REJ??\n", type);
case MODE_REJ: /* Can't do much, stop asking */
ipcp->peer_reject |= (1 << (type - TY_ADJUST_NS));
break;
}
break;
case TY_PRIMARY_NBNS: /* MS PPP NetBIOS nameserver hack */
case TY_PRIMARY_NBNS: /* M$ NetBIOS nameserver hack (rfc1877) */
case TY_SECONDARY_NBNS:
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
switch (mode_type) {
case MODE_REQ:
if (!Enabled(ipcp->fsm.bundle, OPT_MSEXT)) {
LogPrintf(LogIPCP, "MS NBNS req - rejected - msext disabled\n");
ipcp->my_reject |= (1 << type);
have_ip.s_addr =
ipcp->cfg.ns.nbns[type == TY_PRIMARY_NBNS ? 0 : 1].s_addr;
if (have_ip.s_addr == INADDR_ANY) {
LogPrintf(LogIPCP, "NBNS REQ - rejected - nbns not set\n");
ipcp->my_reject |= (1 << (type - TY_ADJUST_NS));
memcpy(dec->rejend, cp, length);
dec->rejend += length;
break;
}
lp = (u_long *) (cp + 2);
dnsstuff.s_addr = *lp;
ms_info_req.s_addr = ipcp->cfg.nbns_entries
[(type - TY_PRIMARY_NBNS) ? 1 : 0].s_addr;
if (dnsstuff.s_addr != ms_info_req.s_addr) {
if (ipaddr.s_addr != have_ip.s_addr) {
memcpy(dec->nakend, cp, 2);
memcpy(dec->nakend+2, &ms_info_req.s_addr, length);
LogPrintf(LogIPCP, "MS NBNS req %d:%s->%s - nak\n",
type, inet_ntoa(dnsstuff), inet_ntoa(ms_info_req));
memcpy(dec->nakend+2, &have_ip.s_addr, length);
dec->nakend += length;
break;
}
LogPrintf(LogIPCP, "MS NBNS req %d:%s ok - ack\n",
type, inet_ntoa(ms_info_req));
memcpy(dec->ackend, cp, length);
dec->ackend += length;
} else {
memcpy(dec->ackend, cp, length);
dec->ackend += length;
}
break;
case MODE_NAK:
LogPrintf(LogIPCP, "MS NBNS req %d - NAK??\n", type);
@ -874,8 +1014,6 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
}
break;
#endif
default:
if (mode_type != MODE_NOP) {
ipcp->my_reject |= (1 << type);
@ -888,6 +1026,12 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
cp += length;
}
if (gotdnsnak)
if (!setdns(ipcp, dnsnak)) {
ipcp->peer_reject |= (1 << (TY_PRIMARY_DNS - TY_ADJUST_NS));
ipcp->peer_reject |= (1 << (TY_SECONDARY_DNS - TY_ADJUST_NS));
}
if (mode_type != MODE_NOP)
if (dec->rejend != dec->rej) {
/* rejects are preferred */

View File

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: ipcp.h,v 1.18.2.21 1998/04/10 13:19:09 brian Exp $
* $Id: ipcp.h,v 1.18.2.22 1998/04/16 00:26:05 brian Exp $
*
* TODO:
*/
@ -32,6 +32,7 @@
#define TY_PRIMARY_NBNS 130
#define TY_SECONDARY_DNS 131
#define TY_SECONDARY_NBNS 132
#define TY_ADJUST_NS 119 /* subtract from NS val for REJECT bit */
struct in_range {
struct in_addr ipaddr;
@ -57,10 +58,12 @@ struct ipcp {
struct in_addr TriggerAddress; /* Address to suggest in REQ */
unsigned HaveTriggerAddress : 1; /* Trigger address specified */
#ifndef NOMSEXT
struct in_addr ns_entries[2]; /* DNS addresses offered */
struct in_addr nbns_entries[2]; /* NetBIOS NS addresses offered */
#endif
struct {
struct in_addr dns[2]; /* DNS addresses offered */
unsigned dns_neg : 2; /* dns negotiation */
struct in_addr nbns[2]; /* NetBIOS NS addresses offered */
} ns;
u_int fsmretry; /* FSM retry frequency */
} cfg;

View File

@ -1,4 +1,4 @@
.\" $Id: ppp.8,v 1.97.2.16 1998/04/16 00:26:15 brian Exp $
.\" $Id: ppp.8,v 1.97.2.17 1998/04/16 18:30:54 brian Exp $
.Dd 20 September 1995
.Os FreeBSD
.Dt PPP 8
@ -753,16 +753,12 @@ and
.Xr vipw 8
for details.
.It
Optional support for Microsoft's IPCP Name Server and NetBIOS
Name Server negotiation can be enabled use
.Dq enable msext
and
.Dq set ns Ar pri-addr [sec-addr]
along with
.Dq set nbns Ar pri-addr [sec-addr]
in your
.Pa /etc/ppp/ppp.conf
file.
Support for IPCP Domain Name Server and NetBIOS Name Server negotiation
can be enabled using the
.Dq enable dns
and
.Dq set nbns
commands. Refer to their descriptions below.
.El
.Pp
.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 2)
@ -1740,6 +1736,27 @@ program. Refer to the
.Ar deflate
section above for details. It is disabled by default as it violates
.Pa rfc1975 .
.It dns
Default: Enabled and Denied. This option allows DNS negotiation.
.Pp
If
.Dq enable Ns No d,
.Nm
will request that the peer confirms the entries in
.Pa /etc/resolv.conf .
If the peer NAKs our request (suggesting new IP numbers),
.Pa /etc/resolv.conf
is updated and another request is sent to confirm the new entries.
.Pp
If
.Dq accept Ns No ed,
.Nm
will answer any DNS queries requested by the peer rather than rejecting
them. The answer is taken from
.Pa /etc/resolv.conf
unless the
.Dq set dns
command is used as an override.
.It lqr
Default: Disabled and Accepted. This option decides if Link Quality
Requests will be sent or accepted. LQR is a protocol that allows
@ -1835,14 +1852,6 @@ will send the packet, probably resulting in an ICMP redirect from
the other end. It is convenient to have this option enabled when
the interface is also the default route as it avoids the necessity
of a loopback route.
.It msext
Default: Disabled. This option allows the use of Microsoft's
.Em PPP
extensions, supporting the negotiation of the DNS and the NetBIOS NS.
Enabling this allows us to pass back the values given in
.Dq set ns
and
.Dq set nbns .
.It passwdauth
Default: Disabled. Enabling this option will tell the PAP authentication
code to use the password file (see
@ -2235,6 +2244,14 @@ is specified,
.Nm
will insist that this window size is used and will not accept any other
values from the peer.
.It set dns Op Ar primary Op Ar secondary
This command specifies DNS overrides for the
.Dq accept dns
command. Refer to the
.Dq accept
command description above for details. This command does not affect the
IP numbers requested using
.Dq enable dns .
.It set device|line Ar value[,value...]
This sets the device(s) to which
.Nm
@ -2567,16 +2584,11 @@ The default MTU is 1500. This may be increased by the MRU specified
by the peer. It may only be subsequently decreased by this option.
Increasing it is not valid as the peer is not necessarily able to
receive the increased packet size.
.It set nbns Ar x.x.x.x Op Ar y.y.y.y
This option allows the setting of the Microsoft NetBIOS DNS servers that
will be negotiated. It is only available in
.Fl direct
mode.
.It set ns Ar x.x.x.x Op Ar y.y.y.y
This option allows the setting of the Microsoft DNS servers that
will be negotiated. It is only used in
.Fl direct
mode.
.It set nbns Op Ar x.x.x.x Op Ar y.y.y.y
This option allows the setting of the Microsoft NetBIOS name server
values to be returned at the peers request. If no values are given,
.Nm
will reject any such requests.
.It set openmode active|passive Op Ar delay
By default,
.Ar openmode
@ -2779,8 +2791,6 @@ Show the current log values.
Show current memory statistics.
.It show modem
Show current modem statistics.
.It show msext
Show the current Microsoft extension values.
.It show proto
Show current protocol totals.
.It show route