ip.c (6735) | ip.c (7001) |
---|---|
1/* 2 * PPP IP Protocol Interface 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. 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 Protocol Interface 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. 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:$ | 20 * $Id: ip.c,v 1.2 1995/02/26 12:17:33 amurai Exp $ |
21 * 22 * TODO: 23 * o Return ICMP message for filterd packet 24 * and optionaly record it into log. 25 */ 26#include "fsm.h" 27#include "lcpproto.h" 28#include "hdlc.h" --- 41 unchanged lines hidden (view full) --- 70 71/* 72 * If any IP layer traffic is detected, refresh IdleTimer. 73 */ 74static void 75RestartIdleTimer() 76{ 77 if (!(mode & MODE_DEDICATED) && ipKeepAlive ) { | 21 * 22 * TODO: 23 * o Return ICMP message for filterd packet 24 * and optionaly record it into log. 25 */ 26#include "fsm.h" 27#include "lcpproto.h" 28#include "hdlc.h" --- 41 unchanged lines hidden (view full) --- 70 71/* 72 * If any IP layer traffic is detected, refresh IdleTimer. 73 */ 74static void 75RestartIdleTimer() 76{ 77 if (!(mode & MODE_DEDICATED) && ipKeepAlive ) { |
78/* StopTimer(&IdleTimer); */ | |
79 StartTimer(&IdleTimer); 80 ipIdleSecs = 0; 81 } 82} 83 84static u_short interactive_ports[8] = { 85 0, 513, 0, 0, 0, 21, 0, 23, 86}; --- 209 unchanged lines hidden (view full) --- 296 pri = FilterCheck(pip, direction); 297 if (pri & A_DENY) { 298#ifdef DEBUG 299 logprintf("blocked.\n"); 300#endif 301 if (direction == 0) IcmpError(pip, pri); 302 return(-1); 303 } else { | 78 StartTimer(&IdleTimer); 79 ipIdleSecs = 0; 80 } 81} 82 83static u_short interactive_ports[8] = { 84 0, 513, 0, 0, 0, 21, 0, 23, 85}; --- 209 unchanged lines hidden (view full) --- 295 pri = FilterCheck(pip, direction); 296 if (pri & A_DENY) { 297#ifdef DEBUG 298 logprintf("blocked.\n"); 299#endif 300 if (direction == 0) IcmpError(pip, pri); 301 return(-1); 302 } else { |
304 if ( FilterCheck(pip, 3) & A_DENY ) { /* Check Keep Alive filter */ | 303 if ( FilterCheck(pip, FL_KEEP ) & A_DENY ) { /* Check Keep Alive filter */ |
305 ipKeepAlive = FALSE; 306 } else { 307 ipKeepAlive = TRUE; 308 } 309 return(pri); 310 } 311} 312 --- 9 unchanged lines hidden (view full) --- 322 cp = tunbuff; 323 nb = 0; 324 for (wp = bp; wp; wp = wp->next) { /* Copy to continuois region */ 325 bcopy(MBUF_CTOP(wp), cp, wp->cnt); 326 cp += wp->cnt; 327 nb += wp->cnt; 328 } 329 | 304 ipKeepAlive = FALSE; 305 } else { 306 ipKeepAlive = TRUE; 307 } 308 return(pri); 309 } 310} 311 --- 9 unchanged lines hidden (view full) --- 321 cp = tunbuff; 322 nb = 0; 323 for (wp = bp; wp; wp = wp->next) { /* Copy to continuois region */ 324 bcopy(MBUF_CTOP(wp), cp, wp->cnt); 325 cp += wp->cnt; 326 nb += wp->cnt; 327 } 328 |
330 if (PacketCheck(tunbuff, nb, 0) < 0) { | 329 if ( PacketCheck(tunbuff, nb, FL_IN ) < 0) { |
331 pfree(bp); 332 return; 333 } 334 335 ipInOctets += nb; 336 /* 337 * Pass it to tunnel device 338 */ --- 11 unchanged lines hidden (view full) --- 350int cnt; /* IN: Length of packet */ 351{ 352 struct mbuf *bp; 353 int pri; 354 355 if (IpcpFsm.state != ST_OPENED) 356 return; 357 | 330 pfree(bp); 331 return; 332 } 333 334 ipInOctets += nb; 335 /* 336 * Pass it to tunnel device 337 */ --- 11 unchanged lines hidden (view full) --- 349int cnt; /* IN: Length of packet */ 350{ 351 struct mbuf *bp; 352 int pri; 353 354 if (IpcpFsm.state != ST_OPENED) 355 return; 356 |
358 pri = PacketCheck(ptr, cnt, 1); | 357 pri = PacketCheck(ptr, cnt, FL_OUT); |
359 if (pri >= 0) { 360 bp = mballoc(cnt, MB_IPIN); 361 bcopy(ptr, MBUF_CTOP(bp), cnt); 362 SendPppFrame(pri, bp); 363 RestartIdleTimer(); 364 ipOutOctets += cnt; 365 } 366} --- 8 unchanged lines hidden (view full) --- 375{ 376 struct mbuf *bp; 377 378 bp = mballoc(count, MB_IPQ); 379 bcopy(ptr, MBUF_CTOP(bp), count); 380 Enqueue(&IpOutputQueues[pri], bp); 381} 382 | 358 if (pri >= 0) { 359 bp = mballoc(cnt, MB_IPIN); 360 bcopy(ptr, MBUF_CTOP(bp), cnt); 361 SendPppFrame(pri, bp); 362 RestartIdleTimer(); 363 ipOutOctets += cnt; 364 } 365} --- 8 unchanged lines hidden (view full) --- 374{ 375 struct mbuf *bp; 376 377 bp = mballoc(count, MB_IPQ); 378 bcopy(ptr, MBUF_CTOP(bp), count); 379 Enqueue(&IpOutputQueues[pri], bp); 380} 381 |
382int 383IsIpEnqueued() 384{ 385 struct mqueue *queue; 386 int exist = FALSE; 387 for (queue = &IpOutputQueues[PRI_URGENT]; queue >= IpOutputQueues; queue--) { 388 if ( queue->qlen > 0 ) { 389 exist = TRUE; 390 break; 391 } 392 } 393 return( exist ); 394} 395 |
|
383void 384IpStartOutput() 385{ 386 struct mqueue *queue; 387 struct mbuf *bp; 388 int pri, cnt; 389 390 if (IpcpFsm.state != ST_OPENED) --- 15 unchanged lines hidden --- | 396void 397IpStartOutput() 398{ 399 struct mqueue *queue; 400 struct mbuf *bp; 401 int pri, cnt; 402 403 if (IpcpFsm.state != ST_OPENED) --- 15 unchanged lines hidden --- |