Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
icsetdata.c,v
Package: icmp.rar [view]
Upload User: lywr2008
Upload Date: 2022-05-26
Package Size: 9k
Code Size: 1k
Category:
Linux Network
Development Platform:
Unix_Linux
- head 1.1;
- access;
- symbols;
- locks
- dls:1.1; strict;
- comment @ * @;
- 1.1
- date 97.09.21.19.26.41; author dls; state Dist;
- branches;
- next ;
- desc
- @@
- 1.1
- log
- @pre-3e code
- @
- text
- @/* icsetdata.c - icsetdata */
- #include <conf.h>
- #include <kernel.h>
- #include <network.h>
- /* ECHOMAX must be an even number */
- #define ECHOMAX(pip) (MAXLRGBUF-IC_HLEN-IP_HLEN(pip)-EP_HLEN-EP_CRC)
- /*------------------------------------------------------------------------
- * icsetdata - set the data section. Return value is data length
- *------------------------------------------------------------------------
- */
- int icsetdata(type, pip, pa2)
- int type;
- struct ip *pip;
- void *pa2;
- {
- struct icmp *pic = (struct icmp *)pip->ip_data;
- int i, len;
- switch (type) {
- case ICT_ECHORP:
- len = pip->ip_len - IP_HLEN(pip) - IC_HLEN;
- if (isodd(len))
- pic->ic_data[len] = 0; /* so cksum works */
- return len;
- case ICT_DESTUR:
- case ICT_SRCQ:
- case ICT_TIMEX:
- pic->ic_mbz = 0; /* must be 0 */
- break;
- case ICT_REDIRECT:
- pic->ic_gw = (IPaddr)pa2;
- break;
- case ICT_PARAMP:
- pic->ic_ptr = (char) pa2;
- for (i=0; i<IC_PADLEN; ++i)
- pic->ic_pad[i] = 0;
- break;
- case ICT_MASKRP:
- blkcopy(pic->ic_data, &pa2, IP_ALEN);
- break;
- case ICT_ECHORQ:
- if ((unsigned)pa2 > ECHOMAX(pip))
- pa2 = (char *)ECHOMAX(pip);
- for (i=0; i<(int)pa2; ++i)
- pic->ic_data[i] = i;
- return (int)pa2;
- case ICT_MASKRQ:
- blkcopy(pic->ic_data, &ip_anyaddr, IP_ALEN);
- return IP_ALEN;
- }
- return 0;
- }
- @