Harald Welte | 55d724a | 2017-10-16 18:25:45 +0200 | [diff] [blame] | 1 | /* Point-to-Point (PP) Short Message Service (SMS). |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 2 | * Support on Mobile Radio Interface |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 3 | * 3GPP TS 04.11 version 7.1.0 Release 1998 / ETSI TS 100 942 V7.1.0. */ |
| 4 | /* |
| 5 | * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 6 | * (C) 2009 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 4d7e49b | 2013-05-02 22:37:16 +0200 | [diff] [blame] | 7 | * (C) 2010-2013 by Holger Hans Peter Freyther <zecke@selfish.org> |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 8 | * (C) 2010 by On-Waves |
| 9 | * (C) 2011 by Andreas Eversberg <jolly@eversberg.eu> |
| 10 | * |
| 11 | * All Rights Reserved |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 388fb03 | 2014-10-26 20:42:49 +0100 | [diff] [blame] | 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Harald Welte | 388fb03 | 2014-10-26 20:42:49 +0100 | [diff] [blame] | 21 | * GNU General Public License for more details. |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 22 | * |
Harald Welte | 388fb03 | 2014-10-26 20:42:49 +0100 | [diff] [blame] | 23 | * You should have received a copy of the GNU General Public License |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 24 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 25 | * |
| 26 | */ |
| 27 | |
Harald Welte | 7c8e2cc | 2012-08-29 16:47:30 +0200 | [diff] [blame] | 28 | #include "../../config.h" |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 29 | |
| 30 | #include <time.h> |
| 31 | #include <string.h> |
| 32 | #include <osmocom/core/msgb.h> |
| 33 | #include <osmocom/core/logging.h> |
| 34 | |
| 35 | #include <osmocom/gsm/gsm48.h> |
Max | 2f0b0c9 | 2017-01-12 16:47:13 +0100 | [diff] [blame] | 36 | #include <osmocom/gsm/gsm0480.h> |
Holger Hans Peter Freyther | 4d7e49b | 2013-05-02 22:37:16 +0200 | [diff] [blame] | 37 | #include <osmocom/gsm/gsm_utils.h> |
| 38 | #include <osmocom/gsm/protocol/gsm_03_40.h> |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 39 | #include <osmocom/gsm/protocol/gsm_04_11.h> |
| 40 | |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 41 | /*! \addtogroup sms |
| 42 | * @{ |
Harald Welte | 55d724a | 2017-10-16 18:25:45 +0200 | [diff] [blame] | 43 | * \file gsm0411_utils.c |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 44 | */ |
| 45 | |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 46 | #define GSM411_ALLOC_SIZE 1024 |
| 47 | #define GSM411_ALLOC_HEADROOM 128 |
| 48 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 49 | /*! Allocate a message buffer for use as TS 04.11 message |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 50 | * \returns allocated message buffer */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 51 | struct msgb *gsm411_msgb_alloc(void) |
| 52 | { |
| 53 | return msgb_alloc_headroom(GSM411_ALLOC_SIZE, GSM411_ALLOC_HEADROOM, |
| 54 | "GSM 04.11"); |
| 55 | } |
| 56 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 57 | /*! Turn int into semi-octet representation: 98 => 0x89 |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 58 | * \param[in] integer value representing decimal number 0..99 |
| 59 | * \returns BSC encoded as nibbles, swapped */ |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 60 | uint8_t gsm411_bcdify(uint8_t value) |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 61 | { |
| 62 | uint8_t ret; |
| 63 | |
| 64 | ret = value / 10; |
| 65 | ret |= (value % 10) << 4; |
| 66 | |
| 67 | return ret; |
| 68 | } |
| 69 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 70 | /*! Turn semi-octet representation into int: 0x89 => 98 |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 71 | * \param[in] value byte containing two BCD nibbles in revere order |
| 72 | * \returns integer representing decoded, re-ordered nibbles */ |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 73 | uint8_t gsm411_unbcdify(uint8_t value) |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 74 | { |
| 75 | uint8_t ret; |
| 76 | |
| 77 | if ((value & 0x0F) > 9 || (value >> 4) > 9) |
| 78 | LOGP(DLSMS, LOGL_ERROR, |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 79 | "gsm411_unbcdify got too big nibble: 0x%02X\n", value); |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 80 | |
| 81 | ret = (value&0x0F)*10; |
| 82 | ret += value>>4; |
| 83 | |
| 84 | return ret; |
| 85 | } |
| 86 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 87 | /*! Generate 03.40 TP-SCTS |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 88 | * \param[out] scts Caller-provided buffer to store SCTS (7 octets) |
| 89 | * \param[in] time to encode */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 90 | void gsm340_gen_scts(uint8_t *scts, time_t time) |
| 91 | { |
Keith | 733810c | 2017-08-17 21:37:47 +0200 | [diff] [blame] | 92 | struct tm *tm = localtime(&time); |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 93 | |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 94 | *scts++ = gsm411_bcdify(tm->tm_year % 100); |
| 95 | *scts++ = gsm411_bcdify(tm->tm_mon + 1); |
| 96 | *scts++ = gsm411_bcdify(tm->tm_mday); |
| 97 | *scts++ = gsm411_bcdify(tm->tm_hour); |
| 98 | *scts++ = gsm411_bcdify(tm->tm_min); |
| 99 | *scts++ = gsm411_bcdify(tm->tm_sec); |
Harald Welte | 7c8e2cc | 2012-08-29 16:47:30 +0200 | [diff] [blame] | 100 | #ifdef HAVE_TM_GMTOFF_IN_TM |
| 101 | *scts++ = gsm411_bcdify(tm->tm_gmtoff/(60*15)); |
| 102 | #else |
Pau Espin Pedrol | 29b7d53 | 2017-06-18 14:15:16 +0200 | [diff] [blame] | 103 | #pragma message ("find a portable way to obtain timezone offset") |
Harald Welte | 7c8e2cc | 2012-08-29 16:47:30 +0200 | [diff] [blame] | 104 | *scts++ = 0; |
| 105 | #endif |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 106 | } |
| 107 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 108 | /*! Decode 03.40 TP-SCTS (into utc/gmt timestamp) |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 109 | * \param[in] scts SMS Center Time Stamp |
| 110 | * \return time in UTC time_t format */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 111 | time_t gsm340_scts(uint8_t *scts) |
| 112 | { |
| 113 | struct tm tm; |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 114 | uint8_t yr = gsm411_unbcdify(*scts++); |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 115 | int ofs; |
| 116 | |
| 117 | memset(&tm, 0x00, sizeof(struct tm)); |
| 118 | |
| 119 | if (yr <= 80) |
| 120 | tm.tm_year = 100 + yr; |
| 121 | else |
| 122 | tm.tm_year = yr; |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 123 | tm.tm_mon = gsm411_unbcdify(*scts++) - 1; |
| 124 | tm.tm_mday = gsm411_unbcdify(*scts++); |
| 125 | tm.tm_hour = gsm411_unbcdify(*scts++); |
| 126 | tm.tm_min = gsm411_unbcdify(*scts++); |
| 127 | tm.tm_sec = gsm411_unbcdify(*scts++); |
Harald Welte | 7c8e2cc | 2012-08-29 16:47:30 +0200 | [diff] [blame] | 128 | #ifdef HAVE_TM_GMTOFF_IN_TM |
| 129 | tm.tm_gmtoff = gsm411_unbcdify(*scts++) * 15*60; |
| 130 | #endif |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 131 | |
| 132 | /* according to gsm 03.40 time zone is |
| 133 | "expressed in quarters of an hour" */ |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 134 | ofs = gsm411_unbcdify(*scts++) * 15*60; |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 135 | |
| 136 | return mktime(&tm) - ofs; |
| 137 | } |
| 138 | |
| 139 | /* Return the default validity period in minutes */ |
| 140 | static unsigned long gsm340_vp_default(void) |
| 141 | { |
| 142 | unsigned long minutes; |
| 143 | /* Default validity: two days */ |
| 144 | minutes = 24 * 60 * 2; |
| 145 | return minutes; |
| 146 | } |
| 147 | |
| 148 | /* Decode validity period format 'relative' */ |
| 149 | static unsigned long gsm340_vp_relative(uint8_t *sms_vp) |
| 150 | { |
| 151 | /* Chapter 9.2.3.12.1 */ |
| 152 | uint8_t vp; |
| 153 | unsigned long minutes; |
| 154 | |
| 155 | vp = *(sms_vp); |
| 156 | if (vp <= 143) |
Alexander Chemeris | cc0645b | 2014-03-07 21:00:19 +0100 | [diff] [blame] | 157 | minutes = (vp + 1) * 5; |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 158 | else if (vp <= 167) |
| 159 | minutes = 12*60 + (vp-143) * 30; |
| 160 | else if (vp <= 196) |
Alexander Chemeris | cc0645b | 2014-03-07 21:00:19 +0100 | [diff] [blame] | 161 | minutes = (vp-166) * 60 * 24; |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 162 | else |
Alexander Chemeris | cc0645b | 2014-03-07 21:00:19 +0100 | [diff] [blame] | 163 | minutes = (vp-192) * 60 * 24 * 7; |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 164 | return minutes; |
| 165 | } |
| 166 | |
| 167 | /* Decode validity period format 'absolute' */ |
| 168 | static unsigned long gsm340_vp_absolute(uint8_t *sms_vp) |
| 169 | { |
| 170 | /* Chapter 9.2.3.12.2 */ |
| 171 | time_t expires, now; |
| 172 | unsigned long minutes; |
| 173 | |
| 174 | expires = gsm340_scts(sms_vp); |
| 175 | now = time(NULL); |
| 176 | if (expires <= now) |
| 177 | minutes = 0; |
| 178 | else |
| 179 | minutes = (expires-now)/60; |
| 180 | return minutes; |
| 181 | } |
| 182 | |
| 183 | /* Decode validity period format 'relative in integer representation' */ |
| 184 | static unsigned long gsm340_vp_relative_integer(uint8_t *sms_vp) |
| 185 | { |
| 186 | uint8_t vp; |
| 187 | unsigned long minutes; |
| 188 | vp = *(sms_vp); |
| 189 | if (vp == 0) { |
| 190 | LOGP(DLSMS, LOGL_ERROR, |
| 191 | "reserved relative_integer validity period\n"); |
| 192 | return gsm340_vp_default(); |
| 193 | } |
| 194 | minutes = vp/60; |
| 195 | return minutes; |
| 196 | } |
| 197 | |
| 198 | /* Decode validity period format 'relative in semi-octet representation' */ |
| 199 | static unsigned long gsm340_vp_relative_semioctet(uint8_t *sms_vp) |
| 200 | { |
| 201 | unsigned long minutes; |
Harald Welte | ad633b0 | 2011-12-01 21:08:19 +0100 | [diff] [blame] | 202 | minutes = gsm411_unbcdify(*sms_vp++)*60; /* hours */ |
| 203 | minutes += gsm411_unbcdify(*sms_vp++); /* minutes */ |
| 204 | minutes += gsm411_unbcdify(*sms_vp++)/60; /* seconds */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 205 | return minutes; |
| 206 | } |
| 207 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 208 | /*! decode validity period. return minutes |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 209 | * \param[in] sms_vpf Validity Period Format in 03.40 encoding |
| 210 | * \param[in] sms_vp Validity Period Information Element |
| 211 | * \returns validity period in minutes */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 212 | unsigned long gsm340_validity_period(uint8_t sms_vpf, uint8_t *sms_vp) |
| 213 | { |
| 214 | uint8_t fi; /* functionality indicator */ |
| 215 | |
| 216 | switch (sms_vpf) { |
| 217 | case GSM340_TP_VPF_RELATIVE: |
| 218 | return gsm340_vp_relative(sms_vp); |
| 219 | case GSM340_TP_VPF_ABSOLUTE: |
| 220 | return gsm340_vp_absolute(sms_vp); |
| 221 | case GSM340_TP_VPF_ENHANCED: |
| 222 | /* Chapter 9.2.3.12.3 */ |
| 223 | fi = *sms_vp++; |
| 224 | /* ignore additional fi */ |
| 225 | if (fi & (1<<7)) sms_vp++; |
| 226 | /* read validity period format */ |
| 227 | switch (fi & 0x7) { |
| 228 | case 0x0: |
| 229 | return gsm340_vp_default(); /* no vpf specified */ |
| 230 | case 0x1: |
| 231 | return gsm340_vp_relative(sms_vp); |
| 232 | case 0x2: |
| 233 | return gsm340_vp_relative_integer(sms_vp); |
| 234 | case 0x3: |
| 235 | return gsm340_vp_relative_semioctet(sms_vp); |
| 236 | default: |
| 237 | /* The GSM spec says that the SC should reject any |
| 238 | unsupported and/or undefined values. FIXME */ |
| 239 | LOGP(DLSMS, LOGL_ERROR, |
| 240 | "Reserved enhanced validity period format\n"); |
| 241 | return gsm340_vp_default(); |
| 242 | } |
| 243 | case GSM340_TP_VPF_NONE: |
| 244 | default: |
| 245 | return gsm340_vp_default(); |
| 246 | } |
| 247 | } |
| 248 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 249 | /*! determine coding alphabet dependent on GSM 03.38 Section 4 DCS |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 250 | * \param[in] dcs Data Coding Scheme in 03.38 encoding |
| 251 | * \returns libosmogsm internal enum \ref sms_alphabet */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 252 | enum sms_alphabet gsm338_get_sms_alphabet(uint8_t dcs) |
| 253 | { |
| 254 | uint8_t cgbits = dcs >> 4; |
| 255 | enum sms_alphabet alpha = DCS_NONE; |
| 256 | |
| 257 | if ((cgbits & 0xc) == 0) { |
| 258 | if (cgbits & 2) { |
| 259 | LOGP(DLSMS, LOGL_NOTICE, |
| 260 | "Compressed SMS not supported yet\n"); |
Pau Espin Pedrol | 29b7d53 | 2017-06-18 14:15:16 +0200 | [diff] [blame] | 261 | return -1; |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | switch ((dcs >> 2)&0x03) { |
| 265 | case 0: |
| 266 | alpha = DCS_7BIT_DEFAULT; |
| 267 | break; |
| 268 | case 1: |
| 269 | alpha = DCS_8BIT_DATA; |
| 270 | break; |
| 271 | case 2: |
| 272 | alpha = DCS_UCS2; |
| 273 | break; |
| 274 | } |
| 275 | } else if (cgbits == 0xc || cgbits == 0xd) |
| 276 | alpha = DCS_7BIT_DEFAULT; |
| 277 | else if (cgbits == 0xe) |
| 278 | alpha = DCS_UCS2; |
| 279 | else if (cgbits == 0xf) { |
| 280 | if (dcs & 4) |
| 281 | alpha = DCS_8BIT_DATA; |
| 282 | else |
| 283 | alpha = DCS_7BIT_DEFAULT; |
| 284 | } |
| 285 | |
| 286 | return alpha; |
| 287 | } |
| 288 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 289 | /*! generate a TPDU address field compliant with 03.40 sec. 9.1.2.5 |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 290 | * \param[out] oa caller-provided output buffer |
| 291 | * \param[in] oa_len caller-specified length of \a oa in bytes |
| 292 | * \param[in] type GSM340_TYPE_* |
| 293 | * \param[in] plan Numbering Plan |
| 294 | * \param[in] number string containing number |
| 295 | * \reurns number of bytes of \a oa that have been used */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 296 | int gsm340_gen_oa(uint8_t *oa, unsigned int oa_len, uint8_t type, |
| 297 | uint8_t plan, const char *number) |
| 298 | { |
| 299 | int len_in_bytes; |
| 300 | |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 301 | oa[1] = 0x80 | (type << 4) | plan; |
| 302 | |
Holger Hans Peter Freyther | 4d7e49b | 2013-05-02 22:37:16 +0200 | [diff] [blame] | 303 | if (type == GSM340_TYPE_ALPHA_NUMERIC) { |
| 304 | /* |
| 305 | * TODO/FIXME: what is the 'useful semi-octets' excluding any |
| 306 | * semi octet containing only fill bits. |
| 307 | * The current code picks the number of bytes written by the |
| 308 | * 7bit encoding routines and multiplies it by two. |
| 309 | */ |
| 310 | gsm_7bit_encode_n(&oa[2], oa_len - 2, number, &len_in_bytes); |
| 311 | oa[0] = len_in_bytes * 2; |
| 312 | len_in_bytes += 2; |
| 313 | } else { |
| 314 | /* prevent buffer overflows */ |
| 315 | if (strlen(number) > 20) |
| 316 | number = ""; |
| 317 | len_in_bytes = gsm48_encode_bcd_number(oa, oa_len, 1, number); |
| 318 | /* GSM 03.40 tells us the length is in 'useful semi-octets' */ |
| 319 | oa[0] = strlen(number) & 0xff; |
| 320 | } |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 321 | |
| 322 | return len_in_bytes; |
| 323 | } |
| 324 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 325 | /*! Prefix \ref msgb with a RP header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 326 | * \param msg Message Buffer containing message |
| 327 | * \param[in] rp_msg_type RP Message Type |
| 328 | * \param[in] rp_msg_ref RP Message Reference |
| 329 | * \returns 0 */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 330 | int gsm411_push_rp_header(struct msgb *msg, uint8_t rp_msg_type, |
| 331 | uint8_t rp_msg_ref) |
| 332 | { |
| 333 | struct gsm411_rp_hdr *rp; |
| 334 | uint8_t len = msg->len; |
| 335 | |
| 336 | /* GSM 04.11 RP-DATA header */ |
| 337 | rp = (struct gsm411_rp_hdr *)msgb_push(msg, sizeof(*rp)); |
| 338 | rp->len = len + 2; |
| 339 | rp->msg_type = rp_msg_type; |
| 340 | rp->msg_ref = rp_msg_ref; /* FIXME: Choose randomly */ |
| 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 345 | /*! Prefix \ref msgb with a 04.08/04.11 CP header |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 346 | * \param msg Message Buffer containing message |
| 347 | * \param[in] proto Protocol |
| 348 | * \param[in] trans Transaction |
| 349 | * \param[in] msg_type Message Type |
| 350 | * \retrns 0 */ |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 351 | int gsm411_push_cp_header(struct msgb *msg, uint8_t proto, uint8_t trans, |
| 352 | uint8_t msg_type) |
| 353 | { |
Neels Hofmeyr | 25774b9 | 2016-11-26 15:21:05 +0100 | [diff] [blame] | 354 | /* Outgoing proto_discr needs the highest bit set */ |
| 355 | gsm0480_l3hdr_push(msg, proto | (trans << 4), msg_type); |
Andreas.Eversberg | d84f47a | 2011-11-06 20:22:12 +0100 | [diff] [blame] | 356 | return 0; |
| 357 | } |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 358 | |
| 359 | /*! @} */ |