Chuyên đề Hệ điều hành Linux - Bài 14: Thư viện lập trình - Lê Hà Minh

The development library for iptables userspace
packet queuing.
§ Netfilter provides a mechanism for passing
packets out of the stack for queueing to
userspace, then receiving these packets back
into the kernel with a verdict specifying what to
do with the packets (such as ACCEPT or DROP).
These packets may also be modified in
userspace prior to reinjection back into the
kernel. 
pdf 15 trang xuanthi 30/12/2022 600
Bạn đang xem tài liệu "Chuyên đề Hệ điều hành Linux - Bài 14: Thư viện lập trình - Lê Hà Minh", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • pdfchuyen_de_he_dieu_hanh_linux_bai_14_thu_vien_lap_trinh_le_ha.pdf

Nội dung text: Chuyên đề Hệ điều hành Linux - Bài 14: Thư viện lập trình - Lê Hà Minh

  1. Contents n Libipq n Libnet n Libcap
  2. Libipq £ For each supported protocol, a kernel module called a queue handler may register with Netfilter to perform the mechanics of passing packets to and from userspace. £ The standard queue handler for IPv4 is ip_queue. It is provided as an experimental module with 2.4 kernels, and uses a Netlink socket for kernel/userspace communication. 4 £ Once ip_queue is loaded, IP packets may be selected with iptables and queued for userspace processing via the QUEUE target
  3. Libipq £ ipq_create_handle(3) Initialise library, return context handle. £ ipq_set_mode(3) Set the queue mode, to copy either packet metadata, or payloads as well as metadata to userspace. £ ipq_read(3) Wait for a queue message to arrive from ip_queue and read it into a buffer. £ ipq_message_type(3) Determine message type in the buffer. 6 £ ipq_get_packet(3) Retrieve a packet message from the buffer.
  4. Libipq 8
  5. Libipq £ Install Yum install iptables-devel p Load modules p Compile: gcc -o yourapp yourapp.c –lipq p Run: ./yourapp p Reference: pq_by_example 10
  6. Libnet £ Install £ Read libnet-primer for more details. 12
  7. Libpcap £ Read other documents for more details 14