Harald Welte | 4fb2075 | 2010-03-02 23:17:33 +0100 | [diff] [blame^] | 1 | /* GSM Mobile Radio Interface Layer 3 messages |
| 2 | * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */ |
| 3 | |
| 4 | /* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <stdint.h> |
| 26 | #include <stdio.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include <osmocore/utils.h> |
| 30 | #include <osmocore/tlv.h> |
| 31 | #include <osmocore/gsm48.h> |
| 32 | |
| 33 | #include <osmocore/protocol/gsm_04_08.h> |
| 34 | |
| 35 | const struct tlv_definition gsm48_att_tlvdef = { |
| 36 | .def = { |
| 37 | [GSM48_IE_MOBILE_ID] = { TLV_TYPE_TLV }, |
| 38 | [GSM48_IE_NAME_LONG] = { TLV_TYPE_TLV }, |
| 39 | [GSM48_IE_NAME_SHORT] = { TLV_TYPE_TLV }, |
| 40 | [GSM48_IE_UTC] = { TLV_TYPE_TV }, |
| 41 | [GSM48_IE_NET_TIME_TZ] = { TLV_TYPE_FIXED, 7 }, |
| 42 | [GSM48_IE_LSA_IDENT] = { TLV_TYPE_TLV }, |
| 43 | |
| 44 | [GSM48_IE_BEARER_CAP] = { TLV_TYPE_TLV }, |
| 45 | [GSM48_IE_CAUSE] = { TLV_TYPE_TLV }, |
| 46 | [GSM48_IE_CC_CAP] = { TLV_TYPE_TLV }, |
| 47 | [GSM48_IE_ALERT] = { TLV_TYPE_TLV }, |
| 48 | [GSM48_IE_FACILITY] = { TLV_TYPE_TLV }, |
| 49 | [GSM48_IE_PROGR_IND] = { TLV_TYPE_TLV }, |
| 50 | [GSM48_IE_AUX_STATUS] = { TLV_TYPE_TLV }, |
| 51 | [GSM48_IE_NOTIFY] = { TLV_TYPE_TV }, |
| 52 | [GSM48_IE_KPD_FACILITY] = { TLV_TYPE_TV }, |
| 53 | [GSM48_IE_SIGNAL] = { TLV_TYPE_TV }, |
| 54 | [GSM48_IE_CONN_BCD] = { TLV_TYPE_TLV }, |
| 55 | [GSM48_IE_CONN_SUB] = { TLV_TYPE_TLV }, |
| 56 | [GSM48_IE_CALLING_BCD] = { TLV_TYPE_TLV }, |
| 57 | [GSM48_IE_CALLING_SUB] = { TLV_TYPE_TLV }, |
| 58 | [GSM48_IE_CALLED_BCD] = { TLV_TYPE_TLV }, |
| 59 | [GSM48_IE_CALLED_SUB] = { TLV_TYPE_TLV }, |
| 60 | [GSM48_IE_REDIR_BCD] = { TLV_TYPE_TLV }, |
| 61 | [GSM48_IE_REDIR_SUB] = { TLV_TYPE_TLV }, |
| 62 | [GSM48_IE_LOWL_COMPAT] = { TLV_TYPE_TLV }, |
| 63 | [GSM48_IE_HIGHL_COMPAT] = { TLV_TYPE_TLV }, |
| 64 | [GSM48_IE_USER_USER] = { TLV_TYPE_TLV }, |
| 65 | [GSM48_IE_SS_VERS] = { TLV_TYPE_TLV }, |
| 66 | [GSM48_IE_MORE_DATA] = { TLV_TYPE_T }, |
| 67 | [GSM48_IE_CLIR_SUPP] = { TLV_TYPE_T }, |
| 68 | [GSM48_IE_CLIR_INVOC] = { TLV_TYPE_T }, |
| 69 | [GSM48_IE_REV_C_SETUP] = { TLV_TYPE_T }, |
| 70 | [GSM48_IE_REPEAT_CIR] = { TLV_TYPE_T }, |
| 71 | [GSM48_IE_REPEAT_SEQ] = { TLV_TYPE_T }, |
| 72 | /* FIXME: more elements */ |
| 73 | }, |
| 74 | }; |
| 75 | |
| 76 | static const char *rr_cause_names[] = { |
| 77 | [GSM48_RR_CAUSE_NORMAL] = "Normal event", |
| 78 | [GSM48_RR_CAUSE_ABNORMAL_UNSPEC] = "Abnormal release, unspecified", |
| 79 | [GSM48_RR_CAUSE_ABNORMAL_UNACCT] = "Abnormal release, channel unacceptable", |
| 80 | [GSM48_RR_CAUSE_ABNORMAL_TIMER] = "Abnormal release, timer expired", |
| 81 | [GSM48_RR_CAUSE_ABNORMAL_NOACT] = "Abnormal release, no activity on radio path", |
| 82 | [GSM48_RR_CAUSE_PREMPTIVE_REL] = "Preemptive release", |
| 83 | [GSM48_RR_CAUSE_HNDOVER_IMP] = "Handover impossible, timing advance out of range", |
| 84 | [GSM48_RR_CAUSE_CHAN_MODE_UNACCT] = "Channel mode unacceptable", |
| 85 | [GSM48_RR_CAUSE_FREQ_NOT_IMPL] = "Frequency not implemented", |
| 86 | [GSM48_RR_CAUSE_CALL_CLEARED] = "Call already cleared", |
| 87 | [GSM48_RR_CAUSE_SEMANT_INCORR] = "Semantically incorrect message", |
| 88 | [GSM48_RR_CAUSE_INVALID_MAND_INF] = "Invalid mandatory information", |
| 89 | [GSM48_RR_CAUSE_MSG_TYPE_N] = "Message type non-existant or not implemented", |
| 90 | [GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT] = "Message type not compatible with protocol state", |
| 91 | [GSM48_RR_CAUSE_COND_IE_ERROR] = "Conditional IE error", |
| 92 | [GSM48_RR_CAUSE_NO_CELL_ALLOC_A] = "No cell allocation available", |
| 93 | [GSM48_RR_CAUSE_PROT_ERROR_UNSPC] = "Protocol error unspecified", |
| 94 | }; |
| 95 | |
| 96 | const char *cc_state_names[] = { |
| 97 | "NULL", |
| 98 | "INITIATED", |
| 99 | "illegal state 2", |
| 100 | "MO_CALL_PROC", |
| 101 | "CALL_DELIVERED", |
| 102 | "illegal state 5", |
| 103 | "CALL_PRESENT", |
| 104 | "CALL_RECEIVED", |
| 105 | "CONNECT_REQUEST", |
| 106 | "MO_TERM_CALL_CONF", |
| 107 | "ACTIVE", |
| 108 | "DISCONNECT_REQ", |
| 109 | "DISCONNECT_IND", |
| 110 | "illegal state 13", |
| 111 | "illegal state 14", |
| 112 | "illegal state 15", |
| 113 | "illegal state 16", |
| 114 | "illegal state 17", |
| 115 | "illegal state 18", |
| 116 | "RELEASE_REQ", |
| 117 | "illegal state 20", |
| 118 | "illegal state 21", |
| 119 | "illegal state 22", |
| 120 | "illegal state 23", |
| 121 | "illegal state 24", |
| 122 | "illegal state 25", |
| 123 | "MO_ORIG_MODIFY", |
| 124 | "MO_TERM_MODIFY", |
| 125 | "CONNECT_IND", |
| 126 | "illegal state 29", |
| 127 | "illegal state 30", |
| 128 | "illegal state 31", |
| 129 | }; |
| 130 | |
| 131 | static char strbuf[64]; |
| 132 | |
| 133 | const char *rr_cause_name(uint8_t cause) |
| 134 | { |
| 135 | if (cause < ARRAY_SIZE(rr_cause_names) && |
| 136 | rr_cause_names[cause]) |
| 137 | return rr_cause_names[cause]; |
| 138 | |
| 139 | snprintf(strbuf, sizeof(strbuf), "0x%02x", cause); |
| 140 | return strbuf; |
| 141 | } |
| 142 | |
| 143 | |