+------------------------------+
| Incoming Network Packet |
+------------------------------+
+------------------------------+
| Netfilter (iptables NFQUEUE) |
+------------------------------+
+------------------------------+
| NFQUEUE Sends Packet to |
| Firewall Program (C Code) |
+------------------------------+
+------------------------------+
| Extract Packet Information |
| (IP, Port, Protocol) |
+------------------------------+
+------------------------------+
| Compare Against Firewall |
| Rules (Loop) |
+------------------------------+
+--------------------+--------------------+
| |
▼ ▼
+--------------------+ +--------------------+
| Rule Matches (Block) | | Rule Doesn't Match |
| -> NF_DROP | | -> NF_ACCEPT |
+--------------------+ +--------------------+
| |
▼ ▼
+--------------------+ +--------------------+
| Drop Packet (BLOCK)| | Allow Packet (PASS) |
| Print "BLOCK" Msg | | Print "ALLOW" Msg |
+--------------------+ +--------------------+
+------------------------------+
| Forward Packet to |
| Destination (if ALLOWED) |
+------------------------------+ +------------------------------+
| Incoming Network Packet |
+------------------------------+
+------------------------------+
| Netfilter (iptables NFQUEUE) |
+------------------------------+
+------------------------------+
| NFQUEUE Sends Packet to |
| Firewall Program (C Code) |
+------------------------------+
+------------------------------+
| Extract Packet Information |
| (IP, Port, Protocol) |
+------------------------------+
+------------------------------+
| Compare Against Firewall |
| Rules (Loop) |
+------------------------------+
+--------------------+--------------------+
| |
▼ ▼
+--------------------+ +--------------------+
| Rule Matches (Block) | | Rule Doesn't Match |
| -> NF_DROP | | -> NF_ACCEPT |
+--------------------+ +--------------------+
| |
▼ ▼
+--------------------+ +--------------------+
| Drop Packet (BLOCK)| | Allow Packet (PASS) |
| Print "BLOCK" Msg | | Print "ALLOW" Msg |
+--------------------+ +--------------------+
+------------------------------+
| Forward Packet to |
| Destination (if ALLOWED) |
+------------------------------+