| module OPCAP_Types { |
| |
| /* OPCAP_Types, defining abstract TTCN-3 data types for the osmo-pcap protocol. |
| * |
| * OPCAP is a non-standard protocol used between osmo-pcap-client and osmo-pcap-server. |
| * |
| * (C) 2021 by Harald Welte <laforge@gnumonks.org> |
| * All rights reserved. |
| * |
| * Released under the terms of GNU General Public License, Version 2 or |
| * (at your option) any later version. |
| */ |
| |
| import from General_Types all; |
| import from Osmocom_Types all; |
| |
| type enumerated OpcapMsgType { |
| PKT_LINK_HDR (0), |
| PKT_LINK_DATA (1) |
| } with { variant "FIELDLENGTH(8)" }; |
| |
| type record OPCAP_PDU { |
| OpcapMsgType msg_type, |
| uint8_t spare, |
| uint16_t len, |
| OpcapBodyUnion u |
| } with { |
| variant (len) "LENGTHTO(u)" |
| variant (len) "BYTEORDER(last)" |
| variant (u) "CROSSTAG( |
| file, msg_type = PKT_LINK_HDR; |
| packet, msg_type = PKT_LINK_DATA; |
| )" |
| }; |
| |
| type union OpcapBodyUnion { |
| PcapFileHeader file, |
| OpcapPacket packet |
| }; |
| |
| /* header in front of a PKT_LINK_DATA */ |
| type record OpcapPacket { |
| uint32_t ts_sec, |
| uint32_t ts_usec, |
| uint32_t caplen, |
| uint32_t len, |
| octetstring payload |
| } with { |
| variant (caplen) "LENGTHTO(payload)" |
| }; |
| |
| /* below definitions are from pcap/pcap.h */ |
| const uint16_t PCAP_VERSION_MAJOR := 2; |
| const uint16_t PCAP_VERSION_MINOR := 4; |
| const uint32_t PCAP_MAGIC := 2712847316; //0xA1B2C3D4; |
| |
| type record PcapFileHeader { |
| uint32_t magic, |
| uint16_t version_major, |
| uint16_t version_minor, |
| uint32_t thiszone, |
| uint32_t sigfigs, |
| uint32_t snaplen, |
| uint32_t linktype |
| }; |
| |
| /* below definitions are from pcap/dlt.h */ |
| const uint32_t DLT_LINUX_SLL := 113; |
| const uint32_t DLT_EN10MB := 1; |
| |
| |
| external function enc_OPCAP_PDU(in OPCAP_PDU msg) return octetstring |
| with { extension "prototype(convert) encode(RAW)" }; |
| |
| external function dec_OPCAP_PDU(in octetstring msg) return OPCAP_PDU |
| with { extension "prototype(convert) decode(RAW)" }; |
| |
| } with { encode "RAW"; variant "FIELDORDER(msb)"; variant "BYTEORDER(first)" }; |