Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 1 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org> */ |
| 2 | |
| 3 | module IPA_Types { |
| 4 | |
| 5 | import from Osmocom_Types all; |
| 6 | |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 7 | type enumerated IpaStreamId { |
Harald Welte | da9d36c | 2017-12-07 17:57:17 +0100 | [diff] [blame] | 8 | IPAC_PROTO_RSL_TRX0 (0), |
| 9 | IPAC_PROTO_RSL_TRX1 (1), |
| 10 | IPAC_PROTO_RSL_TRX2 (2), |
| 11 | IPAC_PROTO_RSL_TRX3 (3), |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 12 | IPAC_PROTO_OSMO (238), |
| 13 | IPAC_PROTO_MGCP_OLD (252), |
| 14 | IPAC_PROTO_SCCP (253), |
| 15 | IPAC_PROTO_CCM (254), |
| 16 | IPAC_PROTO_OML (255) |
| 17 | } with { variant "FIELDLENGTH(8)" } |
| 18 | |
| 19 | type enumerated IpaExtStreamId { |
| 20 | IPAC_PROTO_EXT_CTRL ('00'H), |
| 21 | IPAC_PROTO_EXT_MGCP ('01'H), |
| 22 | IPAC_PROTO_EXT_LAC ('02'H), |
| 23 | IPAC_PROTO_EXT_SMSC ('03'H), |
| 24 | IPAC_PROTO_EXT_ORC ('04'H), |
| 25 | IPAC_PROTO_EXT_GSUP ('05'H), |
| 26 | IPAC_PROTO_EXT_OAP ('06'H) |
| 27 | } with { variant "FIELDLENGTH(8)" } |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 28 | |
| 29 | external function enc_PDU_IPA(in PDU_IPA pdu) return octetstring |
| 30 | with { extension "prototype(convert)" |
| 31 | extension "encode(RAW)" |
| 32 | } |
| 33 | |
| 34 | external function dec_PDU_IPA(in octetstring stream) return PDU_IPA |
| 35 | with { extension "prototype(convert)" |
| 36 | extension "decode(RAW)" |
| 37 | } |
| 38 | |
| 39 | type record PDU_IPA |
| 40 | { |
| 41 | uint16_t lengthInd, |
| 42 | IpaStreamId streamId, |
Harald Welte | 2a8f847 | 2017-11-23 21:11:34 +0100 | [diff] [blame] | 43 | IpaExtStreamId streamIdExt optional, |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 44 | octetstring payloadData |
| 45 | } with { |
Harald Welte | 19ad52b | 2017-11-24 19:54:55 +0100 | [diff] [blame] | 46 | variant (lengthInd) "LENGTHTO(streamIdExt,payloadData)"; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 47 | variant (lengthInd) "FIELDLENGTH(16)"; |
| 48 | variant (lengthInd) "BYTEORDER(last)"; |
Harald Welte | 2a8f847 | 2017-11-23 21:11:34 +0100 | [diff] [blame] | 49 | variant (streamIdExt) "PRESENCE(streamId=IPAC_PROTO_OSMO)"; |
Harald Welte | 00566f5 | 2017-11-21 16:43:49 +0100 | [diff] [blame] | 50 | } |
| 51 | |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 52 | |
| 53 | type enumerated IpaCcmMsgtype { |
| 54 | IPAC_MSGT_PING ('00'H), |
| 55 | IPAC_MSGT_PONG ('01'H), |
| 56 | IPAC_MSGT_ID_GET ('04'H), |
| 57 | IPAC_MSGT_ID_RESP ('05'H), |
| 58 | IPAC_MSGT_ID_ACK ('06'H) |
| 59 | } with { variant "FIELDLENGTH(8)" } |
| 60 | |
| 61 | type enumerated IpaCcmIdTag { |
| 62 | IPAC_IDTAG_SERNR ('00'H), |
| 63 | IPAC_IDTAG_UNITNAME ('01'H), |
| 64 | IPAC_IDTAG_LOCATION1 ('02'H), |
| 65 | IPAC_IDTAG_LOCATION2 ('03'H), |
| 66 | IPAC_IDTAG_EQUIPVERS ('04'H), |
| 67 | IPAC_IDTAG_SWVERSION ('05'H), |
| 68 | IPAC_IDTAG_IPADDR ('06'H), |
| 69 | IPAC_IDTAG_MACADDR ('07'H), |
Harald Welte | 92e9816 | 2017-11-29 11:09:13 +0100 | [diff] [blame] | 70 | IPAC_IDTAG_UNIT ('08'H), |
| 71 | IPAC_IDTAG_OSMO_RAND ('23'H) |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 72 | } with { variant "FIELDLENGTH(8)" } |
| 73 | |
| 74 | |
| 75 | type record IpaCcmGetPart { |
Harald Welte | 92e9816 | 2017-11-29 11:09:13 +0100 | [diff] [blame] | 76 | uint8_t len, |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 77 | IpaCcmIdTag tag |
Harald Welte | 92e9816 | 2017-11-29 11:09:13 +0100 | [diff] [blame] | 78 | } with { variant (len) "LENGTHTO(tag)" } |
| 79 | |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 80 | type set of IpaCcmGetPart IpaCcmIdGet; |
| 81 | |
| 82 | type record IpaCcmRespPart { |
| 83 | uint16_t len, |
| 84 | IpaCcmIdTag tag, |
| 85 | charstring data |
| 86 | } with { variant (len) "LENGTHTO(data,tag)" } |
| 87 | type set of IpaCcmRespPart IpaCcmIdResp; |
| 88 | |
| 89 | type union IpaCcmUnion { |
| 90 | IpaCcmIdGet get, |
| 91 | IpaCcmIdResp resp, |
| 92 | octetstring other |
| 93 | } |
| 94 | |
| 95 | type record PDU_IPA_CCM { |
| 96 | IpaCcmMsgtype msg_type, |
| 97 | IpaCcmUnion u optional |
Harald Welte | a1f0cbc | 2017-11-29 11:04:40 +0100 | [diff] [blame] | 98 | } with { variant (u) "CROSSTAG( |
| 99 | get, msg_type = IPAC_MSGT_ID_GET; |
| 100 | resp, msg_type = IPAC_MSGT_ID_RESP; |
| 101 | other, OTHERWISE; |
| 102 | )" }; |
Harald Welte | d86cdc6 | 2017-11-22 00:45:07 +0100 | [diff] [blame] | 103 | |
| 104 | |
| 105 | external function enc_PDU_IPA_CCM(in PDU_IPA_CCM pdu) return octetstring |
| 106 | with { extension "prototype(convert)" |
| 107 | extension "encode(RAW)" |
| 108 | } |
| 109 | |
| 110 | external function dec_PDU_IPA_CCM(in octetstring stream) return PDU_IPA_CCM |
| 111 | with { extension "prototype(convert)" |
| 112 | extension "decode(RAW)" |
| 113 | } |
| 114 | |
| 115 | |
| 116 | } with { encode "RAW" } |