46#ifndef PROTOCORE_FORWARD_H
47#define PROTOCORE_FORWARD_H
57enum class pc_if_kind : uint8_t
68enum class pc_fwd_action : uint8_t
75#define PC_FWD_IF_ANY 0xFF
81using pc_if_send_fn = bool (*)(uint8_t if_id,
const uint8_t *data, uint16_t len,
void *ctx);
84struct pc_forward_stats
89 uint32_t rate_dropped;
92 uint32_t policy_routed;
93 uint32_t inspect_dropped;
97void pc_forward_reset(
void);
104bool pc_forward_add_if(uint8_t if_id, pc_if_kind kind, pc_if_send_fn send,
void *ctx);
111bool pc_forward_add_rule(uint8_t src_if, uint8_t dst_if, pc_fwd_action action, uint16_t rate_cap_per_sec);
118void pc_forward_acl_set_default(pc_fwd_action action);
131bool pc_forward_acl_add(uint8_t src_if, uint16_t offset,
const uint8_t *pattern,
const uint8_t *mask, uint8_t patlen,
132 pc_fwd_action action);
148bool pc_forward_route_add(uint8_t src_if, uint16_t offset,
const uint8_t *pattern,
const uint8_t *mask, uint8_t patlen,
149 uint8_t egress_if, uint16_t rate_cap_per_sec);
153enum class pc_fwd_verdict : uint8_t
155 PC_FWD_INSPECT_PASS = 0,
156 PC_FWD_INSPECT_DROP = 1,
164using pc_fwd_inspect_fn = pc_fwd_verdict (*)(uint8_t src_if,
const uint8_t *data, uint16_t len,
void *ctx);
172void pc_forward_set_inspector(pc_fwd_inspect_fn fn,
void *ctx);
182uint8_t pc_forward_ingress(uint8_t src_if,
const uint8_t *data, uint16_t len);
185void pc_forward_get_stats(pc_forward_stats *out);
190void pc_forward_test_set_now(uint32_t ms);
User-facing configuration for ProtoCore.