#include header ethernet_t { bit<48> dst_addr; bit<48> src_addr; bit<16> eth_type; } header H { bit<8> a; } struct Headers { ethernet_t eth_hdr; } parser p(packet_in pkt, out Headers hdr) { state start { transition parse_hdrs; } state parse_hdrs { pkt.extract(hdr.eth_hdr); transition accept; } } control ingress(inout Headers h) { apply { h.eth_hdr = h.eth_hdr.eth_type == 1 ? {48w1, 48w1, 16w1} : {48w2, 48w2, 16w2}; } } parser Parser(packet_in b, out Headers hdr); control Ingress(inout Headers hdr); package top(Parser p, Ingress ig); top(p(), ingress()) main;