⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipfilterlib.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
字号:
/* ipFilterLib.c - ip filter hooks library *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01a,17apr97,vin  written*//*DESCRIPTIONThis library provides utilities that give direct access to IP packets.Incoming raw IP packets can be examined or processed using the hooksipFilterHookAdd(). The input hook can be used to receive raw IP packets thatare a part of IP (Internet Protocol) protocols.The filter hook can also be used to build IP traffic monitoring and testingtools.Normally, the network should be accessed through the higher-level socketinterface provided in sockLib.  The routines in ipFilterLib should rarely,if ever, be necessary for applications..LPThe ipFilterLibInit() routine links the ip filtering facility into the VxWorkssystem.  This is performed automatically if INCLUDE_IP_FILTER is definedin configAll.h.SEE ALSO:.pG "Network"*//* includes */#include "vxWorks.h"/* externs */IMPORT FUNCPTR  _ipFilterHook; 	/* ip filter hook defined in netLib.c *//******************************************************************************** ipFilterLibInit - initialize ip filter facility** This routine links the ip filter facility into the VxWorks system.* These routines are included automatically if INCLUDE_IP_FILTER* is defined in configAll.h.** RETURNS: N/A*/void ipFilterLibInit (void)    {    }/********************************************************************************* ipFilterHookAdd - add a routine to receive all internet protocol packets** This routine adds a hook routine that will be called for every IP* packet that is received.** The calling sequence of the filter hook routine is:* .CS*     BOOL ipFilterHook*          (*          struct ifnet *pIf,        /@ interface packet was received on @/*          struct mbuf **pPtrMbuf,   /@ pointer to pointer to an mbuf chain @/*	   struct ip   **pPtrIpHdr,  /@ pointer to pointer to ip header @/ *          int		ipHdrLen,    /@ ip packet header length @/*          )* .CE* The hook routine should return TRUE if it has handled the input packet and* no further action should be taken with it.  If returning TRUE the* ipFilterHook is responsible for freeing the mbuf chain by calling* m_freem(*pPtrMbuf). It should return FALSE if it has not handled the* ipFilterHook and normal processing (e.g., Internet) should take place.** The packet is in a mbuf chain of which a pointer to a pointer is passed as* one of the arguments. The pointer to the mbuf should be accessed by* dereferencing the pointer to pointer, pPtrMbuf. * This mbuf chain will be reused upon return from the hook.  If the hook* routine needs to retain the input packet, it should copy it elsewhere.* by using the macro copy_from_mbufs (buffer, *pPtrMbuf, len).* copy_from_mbufs is defined "net/mbuf.h"** pPtrIpHdr is a pointer to a pointer to a IP header. The pointer to the* ip header is obtained by dereferencing pPtrIpHdr. The ip header is used* to examine and process the fields in the ip header. The fields ip_len,* ip_id and ip_offset in the ip header are converted to the host byte order* from the network byte order before a packet is handed to the filter hook.** The pPtrMbuf and pPtrIpHdr are reused upon return from the hook if it* is returning FALSE.** Normally you will not be needing to modify pPtrMbuf or the pPtrIpHdr.** RETURNS: OK, always.*/STATUS ipFilterHookAdd    (    FUNCPTR ipFilterHook   	/* routine to receive raw ip packets */    )    {    _ipFilterHook = ipFilterHook;     return (OK);    }/********************************************************************************* ipFilterHookDelete - delete a ip filter hook routine** This routine deletes an ip filter hook.** RETURNS: N/A*/void ipFilterHookDelete (void)    {    _ipFilterHook = NULL;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -