ipcp.c (15738) | ipcp.c (18752) |
---|---|
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.7 1996/01/11 17:48:50 phk Exp $ | 20 * $Id: ipcp.c,v 1.8 1996/05/11 20:48:26 phk Exp $ |
21 * 22 * TODO: 23 * o More RFC1772 backwoard compatibility 24 */ 25#include "fsm.h" 26#include "lcpproto.h" 27#include "lcp.h" 28#include "ipcp.h" --- 9 unchanged lines hidden (view full) --- 38 39extern void PutConfValue(); 40extern void Prompt(); 41extern struct in_addr ifnetmask; 42 43struct ipcpstate IpcpInfo; 44struct in_range DefMyAddress, DefHisAddress, DefTriggerAddress; 45 | 21 * 22 * TODO: 23 * o More RFC1772 backwoard compatibility 24 */ 25#include "fsm.h" 26#include "lcpproto.h" 27#include "lcp.h" 28#include "ipcp.h" --- 9 unchanged lines hidden (view full) --- 38 39extern void PutConfValue(); 40extern void Prompt(); 41extern struct in_addr ifnetmask; 42 43struct ipcpstate IpcpInfo; 44struct in_range DefMyAddress, DefHisAddress, DefTriggerAddress; 45 |
46#ifdef MSEXT 47struct in_addr ns_entries[2], nbns_entries[2]; 48#endif /* MSEXT */ 49 |
|
46static void IpcpSendConfigReq __P((struct fsm *)); 47static void IpcpSendTerminateAck __P((struct fsm *)); 48static void IpcpSendTerminateReq __P((struct fsm *)); 49static void IpcpDecodeConfig __P((u_char *, int, int)); 50static void IpcpLayerStart __P((struct fsm *)); 51static void IpcpLayerFinish __P((struct fsm *)); 52static void IpcpLayerUp __P((struct fsm *)); 53static void IpcpLayerDown __P((struct fsm *)); --- 251 unchanged lines hidden (view full) --- 305IpcpDecodeConfig(cp, plen, mode) 306u_char *cp; 307int plen; 308int mode; 309{ 310 int type, length; 311 u_long *lp, compproto; 312 struct compreq *pcomp; | 50static void IpcpSendConfigReq __P((struct fsm *)); 51static void IpcpSendTerminateAck __P((struct fsm *)); 52static void IpcpSendTerminateReq __P((struct fsm *)); 53static void IpcpDecodeConfig __P((u_char *, int, int)); 54static void IpcpLayerStart __P((struct fsm *)); 55static void IpcpLayerFinish __P((struct fsm *)); 56static void IpcpLayerUp __P((struct fsm *)); 57static void IpcpLayerDown __P((struct fsm *)); --- 251 unchanged lines hidden (view full) --- 309IpcpDecodeConfig(cp, plen, mode) 310u_char *cp; 311int plen; 312int mode; 313{ 314 int type, length; 315 u_long *lp, compproto; 316 struct compreq *pcomp; |
313 struct in_addr ipaddr, dstipaddr; | 317 struct in_addr ipaddr, dstipaddr, dnsstuff, ms_info_req; |
314 char tbuff[100]; 315 316 ackp = AckBuff; 317 nakp = NakBuff; 318 rejp = RejBuff; 319 320 while (plen >= sizeof(struct fsmconfig)) { 321 if (plen < 0) --- 125 unchanged lines hidden (view full) --- 447 IpcpInfo.want_ipaddr = ipaddr; 448 IpcpInfo.his_ipaddr = dstipaddr; 449 break; 450 case MODE_REJ: 451 IpcpInfo.his_reject |= (1 << type); 452 break; 453 } 454 break; | 318 char tbuff[100]; 319 320 ackp = AckBuff; 321 nakp = NakBuff; 322 rejp = RejBuff; 323 324 while (plen >= sizeof(struct fsmconfig)) { 325 if (plen < 0) --- 125 unchanged lines hidden (view full) --- 451 IpcpInfo.want_ipaddr = ipaddr; 452 IpcpInfo.his_ipaddr = dstipaddr; 453 break; 454 case MODE_REJ: 455 IpcpInfo.his_reject |= (1 << type); 456 break; 457 } 458 break; |
459 460 /* 461 * MS extensions for MS's PPP 462 */ 463 464#ifdef MSEXT 465 case TY_PRIMARY_DNS: /* MS PPP DNS negotiation hack */ 466 case TY_SECONDARY_DNS: 467 if( !Enabled( ConfMSExt ) ) { 468 LogPrintf( LOG_LCP, "MS NS req - rejected - msext disabled\n" ); 469 IpcpInfo.my_reject |= ( 1 << type ); 470 bcopy(cp, rejp, length); 471 rejp += length; 472 break; 473 } 474 switch( mode ){ 475 case MODE_REQ: 476 lp = (u_long *)(cp + 2); 477 dnsstuff.s_addr = *lp; 478 ms_info_req.s_addr = ns_entries[((type - TY_PRIMARY_DNS)?1:0)].s_addr; 479 if( dnsstuff.s_addr != ms_info_req.s_addr ) 480 { 481 /* 482 So the client has got the DNS stuff wrong (first request) 483 so well tell 'em how it is 484 */ 485 bcopy( cp, nakp, 2 ); /* copy first two (type/length) */ 486 LogPrintf( LOG_LCP, "MS NS req %d:%s->%s - nak\n", 487 type, 488 inet_ntoa( dnsstuff ), 489 inet_ntoa( ms_info_req )); 490 bcopy( &ms_info_req, nakp+2, length ); 491 nakp += length; 492 break; 493 } 494 /* 495 Otherwise they have it right (this time) so we send 496 a ack packet back confirming it... end of story 497 */ 498 LogPrintf( LOG_LCP, "MS NS req %d:%s ok - ack\n", 499 type, 500 inet_ntoa( ms_info_req )); 501 bcopy( cp, ackp, length ); 502 ackp += length; 503 break; 504 case MODE_NAK: /* what does this mean?? */ 505 LogPrintf(LOG_LCP, "MS NS req %d - NAK??\n", type ); 506 break; 507 case MODE_REJ: /* confused?? me to :) */ 508 LogPrintf(LOG_LCP, "MS NS req %d - REJ??\n", type ); 509 break; 510 } 511 break; 512 513 case TY_PRIMARY_NBNS: /* MS PPP NetBIOS nameserver hack */ 514 case TY_SECONDARY_NBNS: 515 if( !Enabled( ConfMSExt ) ) { 516 LogPrintf( LOG_LCP, "MS NBNS req - rejected - msext disabled\n" ); 517 IpcpInfo.my_reject |= ( 1 << type ); 518 bcopy( cp, rejp, length ); 519 rejp += length; 520 break; 521 } 522 switch( mode ){ 523 case MODE_REQ: 524 lp = (u_long *)(cp + 2); 525 dnsstuff.s_addr = *lp; 526 ms_info_req.s_addr = nbns_entries[((type - TY_PRIMARY_NBNS)?1:0)].s_addr; 527 if( dnsstuff.s_addr != ms_info_req.s_addr ) 528 { 529 bcopy( cp, nakp, 2 ); 530 bcopy( &ms_info_req.s_addr , nakp+2, length ); 531 LogPrintf( LOG_LCP, "MS NBNS req %d:%s->%s - nak\n", 532 type, 533 inet_ntoa( dnsstuff ), 534 inet_ntoa( ms_info_req )); 535 nakp += length; 536 break; 537 } 538 LogPrintf( LOG_LCP, "MS NBNS req %d:%s ok - ack\n", 539 type, 540 inet_ntoa( ms_info_req )); 541 bcopy( cp, ackp, length ); 542 ackp += length; 543 break; 544 case MODE_NAK: 545 LogPrintf( LOG_LCP, "MS NBNS req %d - NAK??\n", type ); 546 break; 547 case MODE_REJ: 548 LogPrintf( LOG_LCP, "MS NBNS req %d - REJ??\n", type ); 549 break; 550 } 551 break; 552 553#endif /* MSEXT */ 554 |
|
455 default: 456 IpcpInfo.my_reject |= (1 << type); 457 bcopy(cp, rejp, length); 458 rejp += length; 459 break; 460 } 461 plen -= length; 462 cp += length; 463 } 464} 465 466void 467IpcpInput(struct mbuf *bp) 468{ 469 FsmInput(&IpcpFsm, bp); 470} | 555 default: 556 IpcpInfo.my_reject |= (1 << type); 557 bcopy(cp, rejp, length); 558 rejp += length; 559 break; 560 } 561 plen -= length; 562 cp += length; 563 } 564} 565 566void 567IpcpInput(struct mbuf *bp) 568{ 569 FsmInput(&IpcpFsm, bp); 570} |