ip.c (31195) | ip.c (31272) |
---|---|
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: ip.c,v 1.29 1997/11/12 21:04:21 brian Exp $ | 20 * $Id: ip.c,v 1.30 1997/11/16 22:15:03 brian Exp $ |
21 * 22 * TODO: 23 * o Return ICMP message for filterd packet 24 * and optionaly record it into log. 25 */ 26#include <sys/param.h> 27#include <sys/time.h> 28#include <sys/select.h> --- 217 unchanged lines hidden (view full) --- 246#ifdef notdef 247 struct mbuf *bp; 248 249 if (pip->ip_p != IPPROTO_ICMP) { 250 bp = mballoc(cnt, MB_IPIN); 251 memcpy(MBUF_CTOP(bp), ptr, cnt); 252 SendPppFrame(bp); 253 RestartIdleTimer(); | 21 * 22 * TODO: 23 * o Return ICMP message for filterd packet 24 * and optionaly record it into log. 25 */ 26#include <sys/param.h> 27#include <sys/time.h> 28#include <sys/select.h> --- 217 unchanged lines hidden (view full) --- 246#ifdef notdef 247 struct mbuf *bp; 248 249 if (pip->ip_p != IPPROTO_ICMP) { 250 bp = mballoc(cnt, MB_IPIN); 251 memcpy(MBUF_CTOP(bp), ptr, cnt); 252 SendPppFrame(bp); 253 RestartIdleTimer(); |
254 ipOutOctets += cnt; | 254 IpcpAddOutOctets(cnt); |
255 } 256#endif 257} 258 259/* 260 * For debugging aid. 261 */ 262int --- 137 unchanged lines hidden (view full) --- 400 return; 401 } 402 if (iresult == PKT_ALIAS_OK 403 || iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 404 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 405 pfree(bp); 406 return; 407 } | 255 } 256#endif 257} 258 259/* 260 * For debugging aid. 261 */ 262int --- 137 unchanged lines hidden (view full) --- 400 return; 401 } 402 if (iresult == PKT_ALIAS_OK 403 || iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 404 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 405 pfree(bp); 406 return; 407 } |
408 ipInOctets += nb; | 408 IpcpAddInOctets(nb); |
409 410 nb = ntohs(((struct ip *) tun.data)->ip_len); 411 nb += sizeof(tun)-sizeof(tun.data); 412 nw = write(tun_out, &tun, nb); 413 if (nw != nb) 414 if (nw == -1) 415 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 416 strerror(errno)); --- 28 unchanged lines hidden (view full) --- 445 VarPacketAliasSaveFragment(frag->data); 446 } 447 } 448 } else { /* no aliasing */ 449 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 450 pfree(bp); 451 return; 452 } | 409 410 nb = ntohs(((struct ip *) tun.data)->ip_len); 411 nb += sizeof(tun)-sizeof(tun.data); 412 nw = write(tun_out, &tun, nb); 413 if (nw != nb) 414 if (nw == -1) 415 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 416 strerror(errno)); --- 28 unchanged lines hidden (view full) --- 445 VarPacketAliasSaveFragment(frag->data); 446 } 447 } 448 } else { /* no aliasing */ 449 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 450 pfree(bp); 451 return; 452 } |
453 ipInOctets += nb; | 453 IpcpAddInOctets(nb); |
454 nb += sizeof(tun)-sizeof(tun.data); 455 nw = write(tun_out, &tun, nb); 456 if (nw != nb) 457 if (nw == -1) 458 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, strerror(errno)); 459 else 460 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 461 } --- 42 unchanged lines hidden (view full) --- 504 return; 505 for (queue = &IpOutputQueues[PRI_FAST]; queue >= IpOutputQueues; queue--) { 506 if (queue->top) { 507 bp = Dequeue(queue); 508 if (bp) { 509 cnt = plength(bp); 510 SendPppFrame(bp); 511 RestartIdleTimer(); | 454 nb += sizeof(tun)-sizeof(tun.data); 455 nw = write(tun_out, &tun, nb); 456 if (nw != nb) 457 if (nw == -1) 458 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, strerror(errno)); 459 else 460 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 461 } --- 42 unchanged lines hidden (view full) --- 504 return; 505 for (queue = &IpOutputQueues[PRI_FAST]; queue >= IpOutputQueues; queue--) { 506 if (queue->top) { 507 bp = Dequeue(queue); 508 if (bp) { 509 cnt = plength(bp); 510 SendPppFrame(bp); 511 RestartIdleTimer(); |
512 ipOutOctets += cnt; | 512 IpcpAddOutOctets(cnt); |
513 break; 514 } 515 } 516 } 517} | 513 break; 514 } 515 } 516 } 517} |