Filter Hook Example
Posted 2008/07/25 18:19|
|
|
댓글 하나가 운영자에겐 커다란 힘이 됩니다!
Filter Hook Example
The filter hook in this example is a simple filter hook that makes forward and drop decisions, based on certain packet properties. This example shows how the filter hook drops Transmission Control Protocol (TCP) packets and forwards packets from all other protocols.
예제의 filter hook은 올바른 패킷이라는 전제하에 단순히 특정 패킷을 구별한다. 이 예제는 protocol들 중에 TCP 패킷을 구별하는것을 보여준다.
If packets with specific IP addresses or TCP/UDP port numbers must be filtered, consider creating a user-mode application that uses the Packet Filtering API instead. The Packet Filtering API optimizes the system-supplied IP filter driver to process packets without the overhead that is associated with a filter-hook driver. For more information about the Packet Filtering API, see the Microsoft Windows SDK documentation.
특정 IP 주소나 TCP/UDP Port 번호를 걸러내야 한다면, Packet Filtering API를 사용하는 User 모드 응용프로그램을 고려해야한다. Packet Filtering API는 시스템이 제공하는 overhead가 적은 IP filter driver를 활용한다.
Packet Filtering API에 대한 자세한 정보는, Microsoft Windows SDK를 활용하라.
#define PROT_TCP 6
typedef struct IPHeader {
UCHAR iph_verlen; // Version and length
UCHAR iph_tos; // Type of service
USHORT iph_length; // Total datagram length
USHORT iph_id; // Identification
USHORT iph_offset; // Flags, fragment offset
UCHAR iph_ttl; // Time to live
UCHAR iph_protocol; // Protocol
USHORT iph_xsum; // Header checksum
ULONG iph_src; // Source address
ULONG iph_dest; // Destination address
} IPHeader;
// Drop all TCP packets
PF_FORWARD_ACTION
DropTcpPackets(
unsigned char *PacketHeader,
unsigned char *Packet,
unsigned int PacketLength,
unsigned int RecvInterfaceIndex,
unsigned int SendInterfaceIndex,
IPAddr RecvLinkNextHop,
IPAddr SendLinkNextHop
)
{
if (((IPHeader *)PacketHeader)->iph_protocol == PROT_TCP)
{
return PF_DROP;
}
return PF_FORWARD;
}
위의 정보가 도움이 되셨나요? 그렇다면 댓글 하나만 남겨주세요.
댓글 하나가 운영자에겐 커다란 힘이 됩니다!
- Filed under : 프로그래밍/Driver
- Tag : Filter Hook Example, network, packet
- Comment Trackback

