# jiabochao/udpi architecture

> Architecture diagram of the GitHub repository jiabochao/udpi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jiabochao/udpi
- Repository: https://github.com/jiabochao/udpi

## Overview

##### Project Type and Purpose
- This is a C-based plugin project (“udpi-plugin”) that extends the FD.io VPP (Vector Packet Processing) framework with a Universal Deep Packet Inspection engine.
- Its primary purpose is to integrate Hyperscan-powered regex matching into VPP, enabling high-performance DPI for IPS/IDS and web-firewall use cases.

##### File Structure Analysis
- Top-level build and config:
- CMakeLists.txt, Makefile, cmake/ (helper modules), scripts/ (build checks)
- Core source:
- src/ – C implementation of DPI API (dpi.c, dpi_api.c, dpi_node.c), CLI interface (dpi_cli.c), SSL protocol module (protocols/dpi_ssl.c), API headers (dpi.h, dpi.api), and documentation (dpi_plugin_doc.md).
- Packaging:
- INFO.yaml, RELEASE.md, patches under root for distribution packaging.

##### Key Components
a. Host Operating System
– Linux kernel with DPDK drivers (uio, vfio) and hugepages configured.
b. VPP Core Engine
– Runs as a process or service; provides packet I/O, DPDK device binding, plugin loader, and binary API framework.
c. udpi Plugin
– Implements VPP plugin interface (src/dpi*.c), registers DPI graph node(s) into VPP’s packet-processing graph, exposes CLI and binary API commands.
d. DPI Engine
– Hyperscan library for regex matching; linked by udpi plugin.
e. Configuration Interfaces
– VPP CLI / binary API (udpi <commands>)
f. External Dependencies
– Hyperscan, VPP core libraries (libvppinfra, vpp-dev), optionally DPDK NIC drivers.

##### Relationships and Data Flow
- Packet Ingress: Network NIC → DPDK → VPP Core
- VPP Graph: Core’s packet-processing graph invokes the udpi graph node
- DPI Node: udpi plugin calls Hyperscan API for pattern matching
- Results: DPI verdict (match/no-match) fed back into VPP graph for forwarding, dropping, or alerting
- Control Plane: User CLI or external controller → VPP CLI/API → udpi plugin configuration

##### Architectural Patterns and Design Principles
- Plugin Architecture: The DPI logic is a dynamically loaded plugin leveraging VPP’s plugin interface.
- Data-Plane / Control-Plane Separation: Packet processing is in the fast path (data plane); configuration via CLI/API is in the control plane.
- Modular Protocol Extensions: The project includes protocol-specific modules (e.g., SSL in src/protocols).
- Build-Time Abstraction: CMake and Makefile orchestrate building against installed VPP or source tree.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Plane" 
        HostOS["Host OS\n(DPDK & Hugepages)"]:::external
        DPDK["DPDK Drivers\n(uio, vfio)"]:::external
        VPPCore["VPP Core\n(packet graph engine,\nplugin loader)"]:::dataplane
    end

    subgraph "udpi Plugin"
        dpi_c["dpi.c"]:::dataplane
        dpi_api_c["dpi_api.c"]:::dataplane
        dpi_node_c["dpi_node.c"]:::dataplane
        dpi_h["dpi.h"]:::dataplane
        dpi_apifile["dpi.api"]:::dataplane
        dpi_doc["dpi_plugin_doc.md"]:::dataplane
        subgraph "SSL Module (optional)"
            ssl_c["dpi_ssl.c"]:::external
        end
    end

    subgraph "DPI Engine"
        Hyperscan["Hyperscan Library"]:::external
    end

    subgraph "Control Plane"
        VPPCLI["VPP CLI / Binary API"]:::controlplane
        cli_c["dpi_cli.c"]:::controlplane
        cli_hdr["dpi_app_match.h"]:::controlplane
    end

    subgraph "Build System & Plugin Loader"
        CMake["CMakeLists.txt"]:::external
        Makefile["Makefile"]:::external
        FindVPP["cmake/FindVPP.cmake"]:::external
        Packager["cmake/Packager.cmake"]:::external
        Checkstyle["scripts/checkstyle.sh"]:::external
    end

    subgraph "Packaging & Release"
        INFO["INFO.yaml"]:::external
        RELEASE["RELEASE.md"]:::external
        Patch["0001-build-package-for-hyperscan.patch"]:::external
    end

    %% Data-plane flow
    HostOS --> DPDK --> VPPCore --> dpi_node_c
    dpi_node_c -->|"regex_match()"| Hyperscan
    Hyperscan -->|"match/no-match"| dpi_node_c
    dpi_node_c -->|"verdict"| VPPCore

    %% Control-plane flow
    VPPCLI -->|"configure udpi"| cli_c
    cli_c -->|"update settings"| dpi_api_c

    %% Build integration
    CMake --> VPPCore
    Makefile --> VPPCore
    CMake --> dpi_c
    Makefile --> dpi_c

    %% Optional SSL
    dpi_node_c -->|"SSL inspection"| ssl_c

    %% Click Events
    click dpi_c "https://github.com/jiabochao/udpi/blob/master/src/dpi.c"
    click dpi_api_c "https://github.com/jiabochao/udpi/blob/master/src/dpi_api.c"
    click dpi_node_c "https://github.com/jiabochao/udpi/blob/master/src/dpi_node.c"
    click dpi_h "https://github.com/jiabochao/udpi/blob/master/src/dpi.h"
    click dpi_apifile "https://github.com/jiabochao/udpi/blob/master/src/dpi.api"
    click dpi_doc "https://github.com/jiabochao/udpi/blob/master/src/dpi_plugin_doc.md"
    click ssl_c "https://github.com/jiabochao/udpi/blob/master/src/protocols/dpi_ssl.c"
    click cli_c "https://github.com/jiabochao/udpi/blob/master/src/dpi_cli.c"
    click cli_hdr "https://github.com/jiabochao/udpi/blob/master/src/dpi_app_match.h"
    click CMake "https://github.com/jiabochao/udpi/blob/master/CMakeLists.txt"
    click Makefile "https://github.com/jiabochao/udpi/tree/master/Makefile"
    click FindVPP "https://github.com/jiabochao/udpi/blob/master/cmake/FindVPP.cmake"
    click Packager "https://github.com/jiabochao/udpi/blob/master/cmake/Packager.cmake"
    click Checkstyle "https://github.com/jiabochao/udpi/blob/master/scripts/checkstyle.sh"
    click INFO "https://github.com/jiabochao/udpi/blob/master/INFO.yaml"
    click RELEASE "https://github.com/jiabochao/udpi/blob/master/RELEASE.md"
    click Patch "https://github.com/jiabochao/udpi/blob/master/0001-build-package-for-hyperscan.patch"

    %% Styles
    classDef dataplane fill:#eaf2f8,stroke:#2e86c1,color:#1b2631
    classDef controlplane fill:#fdebd0,stroke:#d35400,color:#1b2631
    classDef external fill:#d5f5e3,stroke:#27ae60,color:#1b2631
```
