diff options
| author | yangwei <[email protected]> | 2022-08-29 09:45:40 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2022-08-29 09:45:40 +0800 |
| commit | 7cff72ab78813a6636790bd2a4e392610a53c183 (patch) | |
| tree | 3f5e370a4e1f591874453a0f9db65e9e7bcc2b5e | |
| parent | e3ea4d0729a524df7206e6c0b2a324e67db19723 (diff) | |
📃 docs(packet io description)::Update the description of the main process
| -rw-r--r-- | readme.md | 48 |
1 files changed, 35 insertions, 13 deletions
@@ -1,6 +1,6 @@ # Stellar: A stateful network functions development platform -A stateful network function could be a firewall, a load balancer, or an IDS. +A stateful network function could be a firewall, a load balancer, or an IDS. ## Architecture @@ -10,26 +10,46 @@ The stellar components are: - **Session Manager** has a hash table for tracking sessions. The caller feeds packets to the session manager and may return triggered session events. - **Plugin Manager** loads C/Lua plugins and manages per-plugin, per-session context. When the caller feeds an event to the plugin manager, it invokes plugin callbacks. - **Protocol Decoders** are libraries that parse and extract information from the packet payload. -- **Active Queue Management** is queue management algorithm libraries that schedule packets by buffering, forwarding, marking, or dropping. A plugin creates a queue instance and enqueues packets as its needs. +- **Active Queue Management** is queue management algorithm libraries that schedule packets by buffering, forwarding, marking, or dropping. A plugin creates a queue instance and enqueues packets as its needs. - Question: Who consumes the dequeue events?  ## Packet IO Library -``` -struct stellar_packet; -packet_io_loop() +```cpp +struct packet; + +main() { - packet_io_device_rx(&rx_pkt) - //ingress processing: Tunnel decoding, IP defragmentation - session_manager(); - plugin_manager(); - //egress processing: AMQ - rl_group_id=pkt_get_group_id(rx_pkt); - void *raw_pkt=pkt_get_raw(rx_pkt); - AMQ_enqueue(group_id[], raw_pkt, pkt_sz); + pio = packet_io_create(mode); + dev = packet_io_open_device(pio, dev_name); + while(1) + work_base_loop(dev); +} + +worker_base_loop(dev) +{ + struct packet *rx_pkt; + + rx_pkt_num = packet_io_rx(dev, &rx_pkt, 1); + + if(rx_pkt_num > 0) + { + //ingress processing: Tunnel decoding, IP defragmentation, Protocol decoding, trigger build in session events + event = session_manager(rx_pkt); + + //event dispatch + plugin_manager(event); + + //egress processing: AMQ + rl_group_id[] =pkt_get_group_id(rx_pkt); + + if(rl_group_id[]) + AMQ_enqueue(rl_group_id[], rx_pkt); + packet_io_tx(&rx_pkt, 1); + } } ``` @@ -75,7 +95,9 @@ session_lock(session, plug_id); session_unlock(session, plug_id); ``` + Plugin Example + ``` plugin_entry(session, ctx) { |
