icredirect.c,v
资源名称:icmp.rar [点击查看]
上传用户:lywr2008
上传日期:2022-05-26
资源大小:9k
文件大小:1k
源码类别:
网络
开发平台:
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
- @/* icredirect.c - icredirect */
- #include <conf.h>
- #include <kernel.h>
- #include <network.h>
- struct route *rtget();
- /*------------------------------------------------------------------------
- * icredirect - handle an incoming ICMP redirect
- *------------------------------------------------------------------------
- */
- int icredirect(pep)
- struct ep *pep;
- {
- struct route *prt;
- struct ip *pip, *pip2;
- struct icmp *pic;
- IPaddr mask;
- pip = (struct ip *)pep->ep_data;
- pic = (struct icmp *)pip->ip_data;
- pip2 = (struct ip *)pic->ic_data;
- if (pic->ic_code == ICC_HOSTRD)
- mask = ip_maskall;
- else
- mask = netmask(pip2->ip_dst);
- prt = rtget(pip2->ip_dst, RTF_LOCAL);
- if (prt == 0) {
- freebuf(pep);
- return OK;
- }
- if (pip->ip_src == prt->rt_gw) {
- rtdel(pip2->ip_dst, mask);
- rtadd(pip2->ip_dst, mask, pic->ic_gw, prt->rt_metric,
- prt->rt_ifnum, IC_RDTTL);
- }
- rtfree(prt);
- freebuf(pep);
- return OK;
- }
- @