*/
#ifndef lint
-static char rcsid[] = "$Id: ipcp.c,v 1.39 1999/03/16 03:12:03 paulus Exp $";
+static char rcsid[] = "$Id: ipcp.c,v 1.44 1999/04/12 06:24:45 paulus Exp $";
#endif
/*
static int default_route_set[NUM_PPP]; /* Have set up a default route */
static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */
static bool usepeerdns; /* Ask peer for DNS addrs */
+static int ipcp_is_up; /* have called np_up() */
/*
* Callbacks for fsm code. (CI = Configuration Information)
NULL,
1,
"IPCP",
+ "IP",
ipcp_option_list,
ip_check_options,
ip_demand_conf,
neg = 0; \
}
-#define ADDCIDNS(opt, neg) \
+#define ADDCIDNS(opt, neg, addr) \
if (neg) { \
- int addrlen = CILEN_ADDR; \
- if (len >= addrlen) { \
+ if (len >= CILEN_ADDR) { \
u_int32_t l; \
PUTCHAR(opt, ucp); \
- PUTCHAR(addrlen, ucp); \
- l = ntohl(0); \
+ PUTCHAR(CILEN_ADDR, ucp); \
+ l = ntohl(addr); \
PUTLONG(l, ucp); \
- len -= addrlen; \
+ len -= CILEN_ADDR; \
} else \
neg = 0; \
}
ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj,
go->maxslotindex, go->cflag);
- ADDCIDNS(CI_MS_DNS1, go->req_dns1);
+ ADDCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]);
- ADDCIDNS(CI_MS_DNS2, go->req_dns2);
+ ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
*lenp -= len;
}
} \
}
+#define ACKCIDNS(opt, neg, addr) \
+ if (neg) { \
+ u_int32_t l; \
+ if ((len -= CILEN_ADDR) < 0) \
+ goto bad; \
+ GETCHAR(citype, p); \
+ GETCHAR(cilen, p); \
+ if (cilen != CILEN_ADDR || citype != opt) \
+ goto bad; \
+ GETLONG(l, p); \
+ cilong = htonl(l); \
+ if (addr != cilong) \
+ goto bad; \
+ }
+
ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
go->old_addrs, go->ouraddr, go->hisaddr);
ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj,
go->maxslotindex, go->cflag);
+ ACKCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]);
+
+ ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
+
/*
* If there are any remaining CIs, then this packet is bad.
*/
code \
}
-/*
- * Peer returns DNS address in a NAK packet
- */
#define NAKCIDNS(opt, neg, code) \
if (go->neg && \
((cilen = p[1]) == CILEN_ADDR) && \
NAKCIDNS(CI_MS_DNS1, req_dns1,
try.dnsaddr[0] = cidnsaddr;
- try.req_dns1 = 0;
);
NAKCIDNS(CI_MS_DNS2, req_dns2,
try.dnsaddr[1] = cidnsaddr;
- try.req_dns2 = 0;
);
/*
p = next;
}
- /* If there is still anything left, this packet is bad. */
- if (len != 0)
- goto bad;
-
/*
* OK, the Nak is good. Now we can update state.
+ * If there are any remaining options, we ignore them.
*/
if (f->state != OPENED)
*go = try;
#define REJCIDNS(opt, neg, dnsaddr) \
if (go->neg && \
- ((cilen = p[1]) == CI_MS_DNS1) && \
+ ((cilen = p[1]) == CILEN_ADDR) && \
len >= cilen && \
p[0] == opt) { \
u_int32_t l; \
}
np_up(f->unit, PPP_IP);
+ ipcp_is_up = 1;
/*
* Execute the ip-up script, like this:
fsm *f;
{
IPCPDEBUG(("ipcp: down"));
- np_down(f->unit, PPP_IP);
+ if (get_ppp_stats(f->unit, &link_stats))
+ link_stats_valid = 1;
+ if (ipcp_is_up) {
+ ipcp_is_up = 0;
+ np_down(f->unit, PPP_IP);
+ }
sifvjcomp(f->unit, 0, 0, 0);
/*