|
Lines 42-48
Link Here
|
| 42 |
/* global vars */ |
42 |
/* global vars */ |
| 43 |
ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */ |
43 |
ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */ |
| 44 |
ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ |
44 |
ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ |
| 45 |
ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ |
45 |
ipcp_options ipcp_allowoptions[NUM_PPP];/* Options we allow peer to request */ |
| 46 |
ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ |
46 |
ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ |
| 47 |
|
47 |
|
| 48 |
/* local vars */ |
48 |
/* local vars */ |
|
Lines 100-105
Link Here
|
| 100 |
static void ip_check_options __P((void)); |
100 |
static void ip_check_options __P((void)); |
| 101 |
static int ip_demand_conf __P((int)); |
101 |
static int ip_demand_conf __P((int)); |
| 102 |
static int ip_active_pkt __P((u_char *, int)); |
102 |
static int ip_active_pkt __P((u_char *, int)); |
|
|
103 |
static void create_resolv __P((u_int32_t, u_int32_t)); |
| 103 |
|
104 |
|
| 104 |
struct protent ipcp_protent = { |
105 |
struct protent ipcp_protent = { |
| 105 |
PPP_IPCP, |
106 |
PPP_IPCP, |
|
Lines 301-307
Link Here
|
| 301 |
|
302 |
|
| 302 |
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) |
303 |
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) |
| 303 |
#define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) |
304 |
#define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) |
| 304 |
|
305 |
#define LENCIDNS(neg) (neg ? (CILEN_ADDR) : 0) |
| 305 |
/* |
306 |
/* |
| 306 |
* First see if we want to change our options to the old |
307 |
* First see if we want to change our options to the old |
| 307 |
* forms because we have received old forms from the peer. |
308 |
* forms because we have received old forms from the peer. |
|
Lines 327-333
Link Here
|
| 327 |
} |
328 |
} |
| 328 |
|
329 |
|
| 329 |
return (LENCIADDR(go->neg_addr, go->old_addrs) + |
330 |
return (LENCIADDR(go->neg_addr, go->old_addrs) + |
| 330 |
LENCIVJ(go->neg_vj, go->old_vj)); |
331 |
LENCIVJ(go->neg_vj, go->old_vj) + |
|
|
332 |
LENCIDNS(go->req_dns1) + |
| 333 |
LENCIDNS(go->req_dns2)) ; |
| 331 |
} |
334 |
} |
| 332 |
|
335 |
|
| 333 |
|
336 |
|
|
Lines 377-387
Link Here
|
| 377 |
neg = 0; \ |
380 |
neg = 0; \ |
| 378 |
} |
381 |
} |
| 379 |
|
382 |
|
|
|
383 |
#define ADDCIDNS(opt, neg, addr) \ |
| 384 |
if (neg) { \ |
| 385 |
if (len >= CILEN_ADDR) { \ |
| 386 |
u_int32_t l; \ |
| 387 |
PUTCHAR(opt, ucp); \ |
| 388 |
PUTCHAR(CILEN_ADDR, ucp); \ |
| 389 |
l = ntohl(addr);\ |
| 390 |
PUTLONG(l, ucp); \ |
| 391 |
len -= CILEN_ADDR; \ |
| 392 |
} else \ |
| 393 |
neg = 0; \ |
| 394 |
} |
| 395 |
|
| 380 |
ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, |
396 |
ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, |
| 381 |
go->old_addrs, go->ouraddr, go->hisaddr); |
397 |
go->old_addrs, go->ouraddr, go->hisaddr); |
| 382 |
|
398 |
|
| 383 |
ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, |
399 |
ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, |
| 384 |
go->maxslotindex, go->cflag); |
400 |
go->maxslotindex, go->cflag); |
|
|
401 |
|
| 402 |
ADDCIDNS(CI_MS_DNS1,go->req_dns1,go->dnsaddr[0]); |
| 403 |
|
| 404 |
ADDCIDNS(CI_MS_DNS2,go->req_dns2,go->dnsaddr[1]); |
| 385 |
|
405 |
|
| 386 |
*lenp -= len; |
406 |
*lenp -= len; |
| 387 |
} |
407 |
} |
|
Lines 457-467
Link Here
|
| 457 |
} \ |
477 |
} \ |
| 458 |
} |
478 |
} |
| 459 |
|
479 |
|
|
|
480 |
#define ACKCIDNS(opt, neg, addr) \ |
| 481 |
if (neg) { \ |
| 482 |
u_int32_t l; \ |
| 483 |
if ((len -= CILEN_ADDR) < 0) \ |
| 484 |
goto bad; \ |
| 485 |
GETCHAR(citype, p); \ |
| 486 |
GETCHAR(cilen, p); \ |
| 487 |
if (cilen != CILEN_ADDR || citype != opt) \ |
| 488 |
goto bad; \ |
| 489 |
GETLONG(l, p); \ |
| 490 |
cilong = htonl(l);\ |
| 491 |
if (addr != cilong) \ |
| 492 |
goto bad; \ |
| 493 |
} |
| 494 |
|
| 460 |
ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, |
495 |
ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, |
| 461 |
go->old_addrs, go->ouraddr, go->hisaddr); |
496 |
go->old_addrs, go->ouraddr, go->hisaddr); |
| 462 |
|
497 |
|
| 463 |
ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, |
498 |
ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, |
| 464 |
go->maxslotindex, go->cflag); |
499 |
go->maxslotindex, go->cflag); |
|
|
500 |
|
| 501 |
ACKCIDNS(CI_MS_DNS1,go->req_dns1,go->dnsaddr[0]); |
| 502 |
|
| 503 |
ACKCIDNS(CI_MS_DNS2,go->req_dns2,go->dnsaddr[1]); |
| 465 |
|
504 |
|
| 466 |
/* |
505 |
/* |
| 467 |
* If there are any remaining CIs, then this packet is bad. |
506 |
* If there are any remaining CIs, then this packet is bad. |
|
Lines 494-500
Link Here
|
| 494 |
u_char cimaxslotindex, cicflag; |
533 |
u_char cimaxslotindex, cicflag; |
| 495 |
u_char citype, cilen, *next; |
534 |
u_char citype, cilen, *next; |
| 496 |
u_short cishort; |
535 |
u_short cishort; |
| 497 |
u_int32_t ciaddr1, ciaddr2, l; |
536 |
u_int32_t ciaddr1, ciaddr2, l, cidnsaddr; |
| 498 |
ipcp_options no; /* options we've seen Naks for */ |
537 |
ipcp_options no; /* options we've seen Naks for */ |
| 499 |
ipcp_options try; /* options to request next time */ |
538 |
ipcp_options try; /* options to request next time */ |
| 500 |
|
539 |
|
|
Lines 537-542
Link Here
|
| 537 |
code \ |
576 |
code \ |
| 538 |
} |
577 |
} |
| 539 |
|
578 |
|
|
|
579 |
#define NAKCIDNS(opt, neg, code) \ |
| 580 |
if (go->neg && \ |
| 581 |
((cilen = p[1]) == CILEN_ADDR) && \ |
| 582 |
len >= cilen && \ |
| 583 |
p[0] == opt) { \ |
| 584 |
len -= cilen; \ |
| 585 |
INCPTR(2, p); \ |
| 586 |
GETLONG(l, p); \ |
| 587 |
cidnsaddr = htonl(l); \ |
| 588 |
no.neg = 1; \ |
| 589 |
code \ |
| 590 |
} |
| 591 |
|
| 540 |
/* |
592 |
/* |
| 541 |
* Accept the peer's idea of {our,his} address, if different |
593 |
* Accept the peer's idea of {our,his} address, if different |
| 542 |
* from our idea, only if the accept_{local,remote} flag is set. |
594 |
* from our idea, only if the accept_{local,remote} flag is set. |
|
Lines 583-588
Link Here
|
| 583 |
} |
635 |
} |
| 584 |
); |
636 |
); |
| 585 |
|
637 |
|
|
|
638 |
NAKCIDNS(CI_MS_DNS1, req_dns1, |
| 639 |
try.dnsaddr[0] = cidnsaddr; |
| 640 |
); |
| 641 |
|
| 642 |
NAKCIDNS(CI_MS_DNS2, req_dns2, |
| 643 |
try.dnsaddr[1] = cidnsaddr; |
| 644 |
); |
| 645 |
|
| 586 |
/* |
646 |
/* |
| 587 |
* There may be remaining CIs, if the peer is requesting negotiation |
647 |
* There may be remaining CIs, if the peer is requesting negotiation |
| 588 |
* on an option that we didn't include in our request packet. |
648 |
* on an option that we didn't include in our request packet. |
|
Lines 719-730
Link Here
|
| 719 |
try.neg = 0; \ |
779 |
try.neg = 0; \ |
| 720 |
} |
780 |
} |
| 721 |
|
781 |
|
|
|
782 |
#define REJCIDNS(opt, neg, dnsaddr) \ |
| 783 |
if(go->neg && \ |
| 784 |
((cilen = p[1]) == CILEN_ADDR) && \ |
| 785 |
len >= cilen && \ |
| 786 |
p[0] == opt) { \ |
| 787 |
u_int32_t l; \ |
| 788 |
len -= cilen; \ |
| 789 |
INCPTR(2, p); \ |
| 790 |
GETLONG(l, p); \ |
| 791 |
cilong = htonl(l); \ |
| 792 |
/* Check rejected value. */ \ |
| 793 |
if (cilong != dnsaddr) \ |
| 794 |
goto bad; \ |
| 795 |
try.neg = 0; \ |
| 796 |
} |
| 797 |
|
| 722 |
REJCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, |
798 |
REJCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, |
| 723 |
go->old_addrs, go->ouraddr, go->hisaddr); |
799 |
go->old_addrs, go->ouraddr, go->hisaddr); |
| 724 |
|
800 |
|
| 725 |
REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, |
801 |
REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, |
| 726 |
go->maxslotindex, go->cflag); |
802 |
go->maxslotindex, go->cflag); |
| 727 |
|
803 |
|
|
|
804 |
REJCIDNS(CI_MS_DNS1, req_dns1, go->dnsaddr[0]); |
| 805 |
|
| 806 |
REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]); |
| 807 |
|
| 728 |
/* |
808 |
/* |
| 729 |
* If there are any remaining CIs, then this packet is bad. |
809 |
* If there are any remaining CIs, then this packet is bad. |
| 730 |
*/ |
810 |
*/ |
|
Lines 1159-1164
Link Here
|
| 1159 |
} |
1239 |
} |
| 1160 |
script_setenv("IPLOCAL", ip_ntoa(go->ouraddr)); |
1240 |
script_setenv("IPLOCAL", ip_ntoa(go->ouraddr)); |
| 1161 |
script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr)); |
1241 |
script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr)); |
|
|
1242 |
|
| 1243 |
if (go->dnsaddr[0] || go->dnsaddr[1]) { |
| 1244 |
script_setenv("USEPEERDNS","1"); |
| 1245 |
if (go->dnsaddr[0]) |
| 1246 |
script_setenv("DNS1",ip_ntoa(go->dnsaddr[0])); |
| 1247 |
if (go->dnsaddr[1]) |
| 1248 |
if (go->dnsaddr[1] != go->dnsaddr[0]) /* if addresses are not same */ |
| 1249 |
script_setenv("DNS2",ip_ntoa(go->dnsaddr[1])); |
| 1250 |
if (update_resolv) |
| 1251 |
create_resolv(go->dnsaddr[0], go->dnsaddr[1]); |
| 1252 |
} |
| 1162 |
|
1253 |
|
| 1163 |
/* |
1254 |
/* |
| 1164 |
* Check that the peer is allowed to use the IP address it wants. |
1255 |
* Check that the peer is allowed to use the IP address it wants. |
|
Lines 1252-1257
Link Here
|
| 1252 |
|
1343 |
|
| 1253 |
syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(go->ouraddr)); |
1344 |
syslog(LOG_NOTICE, "local IP address %s", ip_ntoa(go->ouraddr)); |
| 1254 |
syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(ho->hisaddr)); |
1345 |
syslog(LOG_NOTICE, "remote IP address %s", ip_ntoa(ho->hisaddr)); |
|
|
1346 |
if (go->dnsaddr[0]) |
| 1347 |
syslog(LOG_NOTICE, "primary DNS address %s",ip_ntoa(go->dnsaddr[0])); |
| 1348 |
if (go->dnsaddr[1]) |
| 1349 |
if (go->dnsaddr[1] != go->dnsaddr[0]) |
| 1350 |
syslog(LOG_NOTICE, "secondary DNS address %s",ip_ntoa(go->dnsaddr[1])); |
| 1255 |
} |
1351 |
} |
| 1256 |
|
1352 |
|
| 1257 |
/* |
1353 |
/* |
|
Lines 1353-1358
Link Here
|
| 1353 |
argv[6] = ipparam; |
1449 |
argv[6] = ipparam; |
| 1354 |
argv[7] = NULL; |
1450 |
argv[7] = NULL; |
| 1355 |
run_program(script, argv, 0); |
1451 |
run_program(script, argv, 0); |
|
|
1452 |
} |
| 1453 |
|
| 1454 |
/* |
| 1455 |
* create_resolve - create the replacement resolv.conf file |
| 1456 |
*/ |
| 1457 |
static void |
| 1458 |
create_resolv(peerdns1, peerdns2) |
| 1459 |
u_int32_t peerdns1, peerdns2; |
| 1460 |
{ |
| 1461 |
FILE *f; |
| 1462 |
f = fopen(_PATH_RESOLV, "w"); |
| 1463 |
if (f == NULL) { |
| 1464 |
syslog(LOG_ERR, "Failed to create %s: %m", _PATH_RESOLV); |
| 1465 |
return; |
| 1466 |
} |
| 1467 |
|
| 1468 |
if (peerdns1) |
| 1469 |
fprintf(f, "\nnameserver %s\n", ip_ntoa(peerdns1)); |
| 1470 |
|
| 1471 |
if (peerdns2) |
| 1472 |
if (peerdns2 != peerdns1) /* if addresses are not same */ |
| 1473 |
fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2)); |
| 1474 |
|
| 1475 |
if (ferror(f)) |
| 1476 |
syslog(LOG_ERR, "Write failed to %s: %m", _PATH_RESOLV); |
| 1477 |
|
| 1478 |
fclose(f); |
| 1356 |
} |
1479 |
} |
| 1357 |
|
1480 |
|
| 1358 |
/* |
1481 |
/* |