update it

This commit is contained in:
Sukchan Lee 2017-03-01 00:23:24 +09:00
parent d9281ba7c0
commit c989c76951
2 changed files with 42 additions and 0 deletions

20
src/common.c Normal file
View File

@ -0,0 +1,20 @@
#define TRACE_MODULE _cw_common
#include "common.h"
#define PLMN_ID_DIGIT1(x) (((x) / 100) % 10)
#define PLMN_ID_DIGIT2(x) (((x) / 10) % 10)
#define PLMN_ID_DIGIT3(x) ((x) % 10)
void encode_plmn_id(c_uint8_t *buf, plmn_id_t *plmn_id)
{
buf[0] = (PLMN_ID_DIGIT2(plmn_id->mcc) << 4) | PLMN_ID_DIGIT1(plmn_id->mcc);
if (plmn_id->mnc_len == 2)
buf[1] = (0xf << 4);
else
buf[1] = (PLMN_ID_DIGIT1(plmn_id->mnc) << 4);
buf[1] |= PLMN_ID_DIGIT3(plmn_id->mcc);
buf[2] = (PLMN_ID_DIGIT3(plmn_id->mnc) << 4) | PLMN_ID_DIGIT2(plmn_id->mnc);
}

22
src/common.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef __CELLWIRE_COMMON_H__
#define __CELLWIRE_COMMON_H__
#include "core_errno.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _plmn_id_t {
c_uint16_t mcc;
c_uint16_t mnc;
c_uint16_t mnc_len;
} plmn_id_t;
CORE_DECLARE(void) encode_plmn_id(c_uint8_t *buf, plmn_id_t *plmn_id);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* !__CELLWIRE_COMMON_H__ */