;; -*- tab-width: 4; -*- ---------------------------------------- DEF Eth := dst_mac := octets(6) format eth_addr src_mac := octets(6) format eth_addr ethtype := uint16 byteorder MSB format hex DEF Eth := -- 802.1q dst_mac := octets(6) format eth_addr src_mac := octets(6) format eth_addr tpid := uint16 byteorder MSB format hex eq 8100 tci := uint16 byteorder MSB is vid := uint:12 cfi := uint:1 pcp := uint:3; ethtype := uint16 byteorder MSB format hex DEF IPoEth := Eth(ethtype eq 0800) IP_hdr DEF IP_hdr (size = ihl*4) := octet is ihl := uint:4 ver := uint:4 eq 4; tos := uint8; total := uint16 byteorder msb id := uint16 byteorder msb uint16 byteorder msb is frag_offset := uint:13 flags := uint:3 is mf := uint:1 df := uint:1 ttl := uint8 proto := uint8 hdr_csum := uint16 byteorder msb ip_src := octets(4) format ipv4 ip_dst := octets(4) format ipv4 options := fill IP_options DEF IP_frag (size = total) := IP_hdr IP_data := fill octets(..) DEF IP := FLOW(FORWARD(proto, ip_src, ip_dst), REVERSE(proto, ip_dst, ip_src)) SEQ of IP_frag (id, proto, ip_src, ip_dst) => STREAM IP_data := | mf eq 0, frag_offset eq 0 := IP_data | mf eq 1, frag_offset eq 0 [ offset = total ]; REPEAT (mf eq 1, frag_offset eq offset/8 [offset = offset + total]) ; mf eq 0, frag_offset eq offset/8 := SEQ IP_data DEF UDPoIP := IP(proto eq 17) UDP DEF UDP := FLOW( REPLACE(IP), FORWARD(ip_src, ip_dst, sport, dport), REVERSE(ip_dst, ip_src, dport, sport)) sport := uint16 byteorder msb dport := uint16 byteorder msb len := uint16 byteorder msb udpcsum := uint16 byteorder msb format hex UDP_data := fill octets(..) DEF SIP_hdr := UDP(dport def 5060) FLOW( REPLACE(UDP), FORWARD(ip_src, ip_dst, sport, dport, @SIP_headers{"Call-ID"}) REVERSE(ip_dst, ip_src, dport, sport, @SIP_headers{"Call-ID"}) ) REGEXP SIP_method (?\S+) SIP/2.0\n REPEAT SIP_headers{SIP_header => SIP_value} (REGEXP (?\S+): (?.+)\n) "\n" DEF SIP_method := SIP_method | "INVITE" DEF SIP_SDP := SIP_hdr(@SIP_headers{"Content-Type"} eq "application/sdp") REPEAT SDP_DESCR DEF SDP_DESCR := FLOW( SUBORDINATE, ID(SDP_opts{"o"}), FORWARD(ip_src eq ?, ip_dst eq SDP_opts{"c"}(IP), sport eq ?, dport eq SDP_opts{"m"}(port), proto udp)) REGEXP v=\d+\n REPEAT SDP_opts{SDP_opt => SDP_val} (REGEXP (?\S)=(?.+)\n) DEF SDP_opts("c") := REGEXP IN IP4 (?.+) DEF SDP_opts("m") := REGEXP (?\S+) (?\d+) (?\S+) .+