ip.c (31343) | ip.c (31962) |
---|---|
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.31 1997/11/18 14:52:04 brian Exp $ | 20 * $Id: ip.c,v 1.32 1997/11/22 03:37:33 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> --- 377 unchanged lines hidden (view full) --- 406 || iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 407 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 408 pfree(bp); 409 return; 410 } 411 IpcpAddInOctets(nb); 412 413 nb = ntohs(((struct ip *) tun.data)->ip_len); | 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> --- 377 unchanged lines hidden (view full) --- 406 || iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 407 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 408 pfree(bp); 409 return; 410 } 411 IpcpAddInOctets(nb); 412 413 nb = ntohs(((struct ip *) tun.data)->ip_len); |
414 nb += sizeof(tun)-sizeof(tun.data); | 414 nb += sizeof tun - sizeof tun.data; |
415 nw = write(tun_out, &tun, nb); 416 if (nw != nb) 417 if (nw == -1) 418 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 419 strerror(errno)); 420 else 421 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 422 423 if (iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 424 while ((fptr = VarPacketAliasGetFragment(tun.data)) != NULL) { 425 VarPacketAliasFragmentIn(tun.data, fptr); 426 nb = ntohs(((struct ip *) fptr)->ip_len); | 415 nw = write(tun_out, &tun, nb); 416 if (nw != nb) 417 if (nw == -1) 418 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 419 strerror(errno)); 420 else 421 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 422 423 if (iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) { 424 while ((fptr = VarPacketAliasGetFragment(tun.data)) != NULL) { 425 VarPacketAliasFragmentIn(tun.data, fptr); 426 nb = ntohs(((struct ip *) fptr)->ip_len); |
427 frag = (struct tun_data *)((char *)fptr-sizeof(tun)+sizeof(tun.data)); 428 nb += sizeof(tun)-sizeof(tun.data); | 427 frag = (struct tun_data *) 428 ((char *)fptr - sizeof tun + sizeof tun.data); 429 nb += sizeof tun - sizeof tun.data; |
429 nw = write(tun_out, frag, nb); 430 if (nw != nb) 431 if (nw == -1) 432 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 433 strerror(errno)); 434 else 435 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 436 free(frag); 437 } 438 } 439 } else if (iresult == PKT_ALIAS_UNRESOLVED_FRAGMENT) { 440 nb = ntohs(((struct ip *) tun.data)->ip_len); | 430 nw = write(tun_out, frag, nb); 431 if (nw != nb) 432 if (nw == -1) 433 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, 434 strerror(errno)); 435 else 436 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 437 free(frag); 438 } 439 } 440 } else if (iresult == PKT_ALIAS_UNRESOLVED_FRAGMENT) { 441 nb = ntohs(((struct ip *) tun.data)->ip_len); |
441 nb += sizeof(tun)-sizeof(tun.data); | 442 nb += sizeof tun - sizeof tun.data; |
442 frag = (struct tun_data *)malloc(nb); 443 if (frag == NULL) 444 LogPrintf(LogALERT, "IpInput: Cannot allocate memory for fragment\n"); 445 else { 446 tun_fill_header(*frag, AF_INET); | 443 frag = (struct tun_data *)malloc(nb); 444 if (frag == NULL) 445 LogPrintf(LogALERT, "IpInput: Cannot allocate memory for fragment\n"); 446 else { 447 tun_fill_header(*frag, AF_INET); |
447 memcpy(frag->data, tun.data, nb-sizeof(tun)+sizeof(tun.data)); | 448 memcpy(frag->data, tun.data, nb - sizeof tun + sizeof tun.data); |
448 VarPacketAliasSaveFragment(frag->data); 449 } 450 } 451 } else 452#endif /* #ifndef NOALIAS */ 453 { /* no aliasing */ 454 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 455 pfree(bp); 456 return; 457 } 458 IpcpAddInOctets(nb); | 449 VarPacketAliasSaveFragment(frag->data); 450 } 451 } 452 } else 453#endif /* #ifndef NOALIAS */ 454 { /* no aliasing */ 455 if (PacketCheck(tun.data, nb, FL_IN) < 0) { 456 pfree(bp); 457 return; 458 } 459 IpcpAddInOctets(nb); |
459 nb += sizeof(tun)-sizeof(tun.data); | 460 nb += sizeof tun - sizeof tun.data; |
460 nw = write(tun_out, &tun, nb); 461 if (nw != nb) 462 if (nw == -1) 463 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, strerror(errno)); 464 else 465 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 466 } 467 pfree(bp); --- 55 unchanged lines hidden --- | 461 nw = write(tun_out, &tun, nb); 462 if (nw != nb) 463 if (nw == -1) 464 LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, strerror(errno)); 465 else 466 LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw); 467 } 468 pfree(bp); --- 55 unchanged lines hidden --- |