Core Hydra Syntax
The core abstractions and syntax provided by Hydra are as follows:
/* Header files: Architecture header files provided by the programming framework */
#include "hydra_model.hdr"
#include "hydra_externs.hdr"
#include "hydra_builtin.hdr"
#include "hydra_headers.hdr"
/* Header data type: Describes the format of each header within network packets. */
struct headers {···}
/* Parser: Describes the permitted packet sequences and extracts headers from the packets. */
parser MyParser( packet in packet,
out headers hdr){
state start {···}
state parse_ethernet{···}
state parse_ipv6 {···}
}
/* Action: Describes the operations performed on packet header fields and may include data provided by the control plane at runtime. */
action ovs_action_mod fullnat(in headers hdr) {···}
/* Control: Describes the network packet processing workflow and implements actions—such as forward, modify, or drop—based on table matching results. */
control MyPrePipe(in headers hdr){
@main
table fullnat exact {
key ={···}
actions = {···}
size = 0x1000;
default_action = flexda_upcall;
aging_time = 50;
}
apply{}
}
control MyPostPipe(in headers hdr){
apply{}
}
/* Package: Assembles components such as the parser and control, and is the entry for each Hydra program. */
Switch(
TX_ovs(MyParser(),MyPrePipe(),MyPostPipe()),
RX_ovs(MyParser(),MyPrePipe()),MyPostPipe()
)main;
Parent topic: Syntax