- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
icredirect.c
资源名称:icmp.rar [点击查看]
上传用户:lywr2008
上传日期:2022-05-26
资源大小:9k
文件大小:1k
源码类别:
网络
开发平台:
Unix_Linux
- /* icredirect.c - icredirect */
- #include <conf.h>
- #include <kernel.h>
- #include <network.h>
- /*------------------------------------------------------------------------
- * icredirect - handle an incoming ICMP redirect
- *------------------------------------------------------------------------
- */
- int
- icredirect(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;
- }