ipcp.c (85602e5267f413a849370d3c6fe3d0a87cdd5b49) | ipcp.c (565e35e50e2cdac423588a3d18742544bde128b0) |
---|---|
1/* 2 * PPP IP Control Protocol (IPCP) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP IP Control Protocol (IPCP) Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: ipcp.c,v 1.50.2.33 1998/04/07 00:53:51 brian Exp $ | 20 * $Id: ipcp.c,v 1.50.2.34 1998/04/07 23:45:55 brian Exp $ |
21 * 22 * TODO: 23 * o More RFC1772 backwoard compatibility 24 */ 25#include <sys/param.h> 26#include <netinet/in_systm.h> 27#include <netinet/in.h> 28#include <netinet/ip.h> --- 285 unchanged lines hidden (view full) --- 314 u_long mask, addr; 315 struct ifaliasreq ifra; 316 317 /* If given addresses are alreay set, then ignore this request */ 318 if (bundle->ncp.ipcp.my_ifip.s_addr == myaddr.s_addr && 319 bundle->ncp.ipcp.peer_ifip.s_addr == hisaddr.s_addr) 320 return 0; 321 | 21 * 22 * TODO: 23 * o More RFC1772 backwoard compatibility 24 */ 25#include <sys/param.h> 26#include <netinet/in_systm.h> 27#include <netinet/in.h> 28#include <netinet/ip.h> --- 285 unchanged lines hidden (view full) --- 314 u_long mask, addr; 315 struct ifaliasreq ifra; 316 317 /* If given addresses are alreay set, then ignore this request */ 318 if (bundle->ncp.ipcp.my_ifip.s_addr == myaddr.s_addr && 319 bundle->ncp.ipcp.peer_ifip.s_addr == hisaddr.s_addr) 320 return 0; 321 |
322 IpcpCleanInterface(&bundle->ncp.ipcp.fsm); | 322 IpcpCleanInterface(&bundle->ncp.ipcp); |
323 324 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 325 if (s < 0) { 326 LogPrintf(LogERROR, "SetIpDevice: socket(): %s\n", strerror(errno)); 327 return (-1); 328 } 329 330 memset(&ifra, '\0', sizeof ifra); --- 125 unchanged lines hidden (view full) --- 456} 457 458static void 459IpcpLayerStart(struct fsm * fp) 460{ 461 /* We're about to start up ! */ 462 LogPrintf(LogIPCP, "IpcpLayerStart.\n"); 463 | 323 324 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 325 if (s < 0) { 326 LogPrintf(LogERROR, "SetIpDevice: socket(): %s\n", strerror(errno)); 327 return (-1); 328 } 329 330 memset(&ifra, '\0', sizeof ifra); --- 125 unchanged lines hidden (view full) --- 456} 457 458static void 459IpcpLayerStart(struct fsm * fp) 460{ 461 /* We're about to start up ! */ 462 LogPrintf(LogIPCP, "IpcpLayerStart.\n"); 463 |
464 /* This is where we should be setting up the interface in AUTO mode */ | 464 /* This is where we should be setting up the interface in DEMAND mode */ |
465} 466 467static void 468IpcpLayerFinish(struct fsm *fp) 469{ 470 /* We're now down */ 471 LogPrintf(LogIPCP, "IpcpLayerFinish.\n"); 472} 473 474void | 465} 466 467static void 468IpcpLayerFinish(struct fsm *fp) 469{ 470 /* We're now down */ 471 LogPrintf(LogIPCP, "IpcpLayerFinish.\n"); 472} 473 474void |
475IpcpCleanInterface(struct fsm *fp) | 475IpcpCleanInterface(struct ipcp *ipcp) |
476{ | 476{ |
477 struct ipcp *ipcp = fsm2ipcp(fp); | |
478 struct ifaliasreq ifra; 479 struct sockaddr_in *me, *peer; 480 int s; 481 482 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 483 if (s < 0) { 484 LogPrintf(LogERROR, "IpcpCleanInterface: socket: %s\n", strerror(errno)); 485 return; 486 } 487 488 if (Enabled(ConfProxy)) | 477 struct ifaliasreq ifra; 478 struct sockaddr_in *me, *peer; 479 int s; 480 481 s = ID0socket(AF_INET, SOCK_DGRAM, 0); 482 if (s < 0) { 483 LogPrintf(LogERROR, "IpcpCleanInterface: socket: %s\n", strerror(errno)); 484 return; 485 } 486 487 if (Enabled(ConfProxy)) |
489 cifproxyarp(fp->bundle, ipcp->peer_ifip, s); | 488 cifproxyarp(ipcp->fsm.bundle, ipcp->peer_ifip, s); |
490 491 if (ipcp->my_ifip.s_addr != INADDR_ANY || 492 ipcp->peer_ifip.s_addr != INADDR_ANY) { 493 memset(&ifra, '\0', sizeof ifra); | 489 490 if (ipcp->my_ifip.s_addr != INADDR_ANY || 491 ipcp->peer_ifip.s_addr != INADDR_ANY) { 492 memset(&ifra, '\0', sizeof ifra); |
494 strncpy(ifra.ifra_name, fp->bundle->ifname, sizeof ifra.ifra_name - 1); | 493 strncpy(ifra.ifra_name, ipcp->fsm.bundle->ifname, 494 sizeof ifra.ifra_name - 1); |
495 ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0'; 496 me = (struct sockaddr_in *)&ifra.ifra_addr; 497 peer = (struct sockaddr_in *)&ifra.ifra_broadaddr; 498 me->sin_family = peer->sin_family = AF_INET; 499 me->sin_len = peer->sin_len = sizeof(struct sockaddr_in); 500 me->sin_addr = ipcp->my_ifip; 501 peer->sin_addr = ipcp->peer_ifip; 502 if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { --- 25 unchanged lines hidden (view full) --- 528 */ 529 if (SelectSystem(fp->bundle, s, LINKDOWNFILE, NULL) < 0) 530 if (GetLabel()) { 531 if (SelectSystem(fp->bundle, GetLabel(), LINKDOWNFILE, NULL) < 0) 532 SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL); 533 } else 534 SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL); 535 | 495 ifra.ifra_name[sizeof ifra.ifra_name - 1] = '\0'; 496 me = (struct sockaddr_in *)&ifra.ifra_addr; 497 peer = (struct sockaddr_in *)&ifra.ifra_broadaddr; 498 me->sin_family = peer->sin_family = AF_INET; 499 me->sin_len = peer->sin_len = sizeof(struct sockaddr_in); 500 me->sin_addr = ipcp->my_ifip; 501 peer->sin_addr = ipcp->peer_ifip; 502 if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) { --- 25 unchanged lines hidden (view full) --- 528 */ 529 if (SelectSystem(fp->bundle, s, LINKDOWNFILE, NULL) < 0) 530 if (GetLabel()) { 531 if (SelectSystem(fp->bundle, GetLabel(), LINKDOWNFILE, NULL) < 0) 532 SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL); 533 } else 534 SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL); 535 |
536 if (!(mode & MODE_AUTO)) 537 IpcpCleanInterface(fp); | 536 if (ipcp->fsm.bundle->phys_type & PHYS_DEMAND) 537 IpcpCleanInterface(ipcp); |
538} 539 540static void 541IpcpLayerUp(struct fsm *fp) 542{ 543 /* We're now up */ 544 struct ipcp *ipcp = fsm2ipcp(fp); 545 char tbuff[100]; --- 83 unchanged lines hidden (view full) --- 629 iplist_ip2pos(&ipcp->cfg.peer_list, ipaddr) < 0 || 630 ipcp_SetIPaddress(fp->bundle, ipcp->cfg.my_range.ipaddr, 631 ipaddr, 1)) { 632 LogPrintf(LogIPCP, "%s: Address invalid or already in use\n", 633 inet_ntoa(ipaddr)); 634 if (iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->peer_ifip) >= 0) 635 /* 636 * If we've already got a valid address configured for the peer | 538} 539 540static void 541IpcpLayerUp(struct fsm *fp) 542{ 543 /* We're now up */ 544 struct ipcp *ipcp = fsm2ipcp(fp); 545 char tbuff[100]; --- 83 unchanged lines hidden (view full) --- 629 iplist_ip2pos(&ipcp->cfg.peer_list, ipaddr) < 0 || 630 ipcp_SetIPaddress(fp->bundle, ipcp->cfg.my_range.ipaddr, 631 ipaddr, 1)) { 632 LogPrintf(LogIPCP, "%s: Address invalid or already in use\n", 633 inet_ntoa(ipaddr)); 634 if (iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->peer_ifip) >= 0) 635 /* 636 * If we've already got a valid address configured for the peer |
637 * (in AUTO mode), try NAKing with that so that we don't | 637 * (in DEMAND mode), try NAKing with that so that we don't |
638 * have to upset things too much. 639 */ 640 ipcp->peer_ip = ipcp->peer_ifip; 641 else 642 /* Just pick an IP number from our list */ 643 ipcp->peer_ip = ChooseHisAddr 644 (fp->bundle, ipcp->cfg.my_range.ipaddr); 645 --- 289 unchanged lines hidden --- | 638 * have to upset things too much. 639 */ 640 ipcp->peer_ip = ipcp->peer_ifip; 641 else 642 /* Just pick an IP number from our list */ 643 ipcp->peer_ip = ChooseHisAddr 644 (fp->bundle, ipcp->cfg.my_range.ipaddr); 645 --- 289 unchanged lines hidden --- |