Пример #1
0
    def test2(self, debug=1):

        program = """ layout vlan_tag { }"""
        try:
            p4 = simple_test(program, debug=debug)
        except GP4.GP4_Exceptions.SyntaxError, err:
            print "Syntax Error was expected"
Пример #2
0
    def test3(self, debug=1):

        program = """
parser we_are_done  { return P4_PARSING_DONE ; }
parser nxt_is_done  { return we_are_done ; }
parser prsr_switch  { return switch ( L2.DA ) { 1 : nxt_state ; } } 
parser prsr_switch2 { return switch ( L2.DA, L2.SA ) { 
                        12 : nxt_is_done; 
                        5, 9 : five_or_nine;
                        800 mask 22,99  : masked_state;
                        default : def_state;
                     } }
parser do_stuff { extract ( L2_hdr ) ;
                  extract ( vlan_id[3] );
                  extract ( ip_hdr[next] ); 
                  set_metadata ( hdr.f1, 666 );
                  return P4_PARSING_DONE ; 
                }

"""
        p4 = simple_test(program, debug=debug)
Пример #3
0
    def test1(self, debug=1):

        program = """

layout vlan_tag {
    fields {
        pcp : 3 signed, saturating;
        vid : 12;
        ethertype : 16; 
        vid2 : 9;
    }
    length (2+1) ; 
    max_length 33;
}

layout hdr2 {fields { a : 8 ; } }

vlan_tag metadata vlan_instance;
vlan_tag vlan_instance_stack [ 5 ]; 

"""
        p4 = simple_test(program, debug=debug)