diff options
author | Kirill Zakharenko <earwin@gmail.com> | 2020-05-01 18:21:58 +0300 |
---|---|---|
committer | Kirill Zakharenko <earwin@gmail.com> | 2020-05-01 18:21:58 +0300 |
commit | 357ab3abba5a1be0a66f8ae6c6a0460ddb4b7c06 (patch) | |
tree | ad0979169f0d7911bb503466036f36f1489bc714 /include | |
parent | 459224a99391fa9adf22a45cb6a63d56703aa3a8 (diff) | |
parent | d87d6f177837c848381e362d3880509ba275cac8 (diff) |
Merge master into fairwaves/production
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_amr_dtx.h | 40 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_coding.h | 6 | ||||
-rw-r--r-- | include/osmocom/coding/gsm0503_parity.h | 19 | ||||
-rw-r--r-- | include/osmocom/core/exec.h | 1 | ||||
-rw-r--r-- | include/osmocom/core/gsmtap.h | 31 | ||||
-rw-r--r-- | include/osmocom/core/gsmtap_util.h | 6 | ||||
-rw-r--r-- | include/osmocom/core/select.h | 18 | ||||
-rw-r--r-- | include/osmocom/core/socket.h | 1 | ||||
-rw-r--r-- | include/osmocom/core/utils.h | 2 | ||||
-rw-r--r-- | include/osmocom/ctrl/ports.h | 2 | ||||
-rw-r--r-- | include/osmocom/gprs/protocol/gsm_04_60.h | 153 | ||||
-rw-r--r-- | include/osmocom/gsm/l1sap.h | 3 | ||||
-rw-r--r-- | include/osmocom/sim/sim.h | 51 | ||||
-rw-r--r-- | include/osmocom/usb/libusb.h | 8 | ||||
-rw-r--r-- | include/osmocom/vty/ports.h | 1 | ||||
-rw-r--r-- | include/osmocom/vty/tdef_vty.h | 2 |
17 files changed, 178 insertions, 167 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index b341ee3c..572c880f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -90,6 +90,7 @@ nobase_include_HEADERS = \ osmocom/coding/gsm0503_mapping.h \ osmocom/coding/gsm0503_interleaving.h \ osmocom/coding/gsm0503_coding.h \ + osmocom/coding/gsm0503_amr_dtx.h \ osmocom/gsm/gsm0808.h \ osmocom/gsm/gsm29205.h \ osmocom/gsm/gsm0808_utils.h \ diff --git a/include/osmocom/coding/gsm0503_amr_dtx.h b/include/osmocom/coding/gsm0503_amr_dtx.h new file mode 100644 index 00000000..f048a6e3 --- /dev/null +++ b/include/osmocom/coding/gsm0503_amr_dtx.h @@ -0,0 +1,40 @@ +/*! \file gsm0503_amr_dtx.h + * GSM TS 05.03 coding + */ + +#pragma once + +#include <stdint.h> + +#include <osmocom/core/defs.h> +#include <osmocom/core/bits.h> + +/*! \addtogroup coding + * @{ + * \file gsm0503_amr_dtx.h */ + +enum gsm0503_amr_dtx_frames { + AMR_OTHER, + AFS_SID_FIRST, + AFS_SID_UPDATE, + AFS_SID_UPDATE_CN, + AFS_ONSET, + AHS_SID_UPDATE, + AHS_SID_UPDATE_CN, + AHS_SID_FIRST_P1, + AHS_SID_FIRST_P2, + AHS_ONSET, + AHS_SID_FIRST_INH, + AHS_SID_UPDATE_INH, +}; + +extern const struct value_string gsm0503_amr_dtx_frame_names[]; +static inline const char *gsm0503_amr_dtx_frame_name(enum gsm0503_amr_dtx_frames frame) +{ + return get_value_string(gsm0503_amr_dtx_frame_names, frame); +} + +enum gsm0503_amr_dtx_frames gsm0503_detect_afs_dtx_frame(int *n_errors, int *n_bits_total, const ubit_t *ubits); +enum gsm0503_amr_dtx_frames gsm0503_detect_ahs_dtx_frame(int *n_errors, int *n_bits_total, const ubit_t *ubits); + +/*! @} */ diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h index 98038f8f..2afa049b 100644 --- a/include/osmocom/coding/gsm0503_coding.h +++ b/include/osmocom/coding/gsm0503_coding.h @@ -58,12 +58,18 @@ int gsm0503_tch_afs_encode(ubit_t *bursts, const uint8_t *tch_data, int len, int gsm0503_tch_afs_decode(uint8_t *tch_data, const sbit_t *bursts, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total); +int gsm0503_tch_afs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, + uint8_t *cmr, int *n_errors, int *n_bits_total, uint8_t *dtx); int gsm0503_tch_ahs_encode(ubit_t *bursts, const uint8_t *tch_data, int len, int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr); int gsm0503_tch_ahs_decode(uint8_t *tch_data, const sbit_t *bursts, int odd, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total); +int gsm0503_tch_ahs_decode_dtx(uint8_t *tch_data, const sbit_t *bursts, int odd, + int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, + uint8_t *cmr, int *n_errors, int *n_bits_total, uint8_t *dtx); int gsm0503_rach_ext_encode(ubit_t *burst, uint16_t ra, uint8_t bsic, bool is_11bit); int gsm0503_rach_encode(ubit_t *burst, const uint8_t *ra, uint8_t bsic) OSMO_DEPRECATED("Use gsm0503_rach_ext_encode() instead"); diff --git a/include/osmocom/coding/gsm0503_parity.h b/include/osmocom/coding/gsm0503_parity.h index 28a54443..bda5f99e 100644 --- a/include/osmocom/coding/gsm0503_parity.h +++ b/include/osmocom/coding/gsm0503_parity.h @@ -10,14 +10,15 @@ * @{ * \file gsm0503_parity.h */ -const struct osmo_crc64gen_code gsm0503_fire_crc40; -const struct osmo_crc16gen_code gsm0503_cs234_crc16; -const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr; -const struct osmo_crc16gen_code gsm0503_mcs_crc12; -const struct osmo_crc8gen_code gsm0503_rach_crc6; -const struct osmo_crc16gen_code gsm0503_sch_crc10; -const struct osmo_crc8gen_code gsm0503_tch_fr_crc3; -const struct osmo_crc8gen_code gsm0503_tch_efr_crc8; -const struct osmo_crc8gen_code gsm0503_amr_crc6; +extern const struct osmo_crc64gen_code gsm0503_fire_crc40; +extern const struct osmo_crc16gen_code gsm0503_cs234_crc16; +extern const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr; +extern const struct osmo_crc16gen_code gsm0503_mcs_crc12; +extern const struct osmo_crc8gen_code gsm0503_rach_crc6; +extern const struct osmo_crc16gen_code gsm0503_sch_crc10; +extern const struct osmo_crc8gen_code gsm0503_tch_fr_crc3; +extern const struct osmo_crc8gen_code gsm0503_tch_efr_crc8; +extern const struct osmo_crc8gen_code gsm0503_amr_crc6; +extern const struct osmo_crc16gen_code gsm0503_amr_crc14; /*! @} */ diff --git a/include/osmocom/core/exec.h b/include/osmocom/core/exec.h index 6bbd352c..e63ec114 100644 --- a/include/osmocom/core/exec.h +++ b/include/osmocom/core/exec.h @@ -25,4 +25,5 @@ extern const char *osmo_environment_whitelist[]; int osmo_environment_filter(char **out, size_t out_len, char **in, const char **whitelist); int osmo_environment_append(char **out, size_t out_len, char **in); int osmo_close_all_fds_above(int last_fd_to_keep); +int osmo_system_nowait2(const char *command, const char **env_whitelist, char **addl_env, const char *user); int osmo_system_nowait(const char *command, const char **env_whitelist, char **addl_env); diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h index 35ba71e5..82e95254 100644 --- a/include/osmocom/core/gsmtap.h +++ b/include/osmocom/core/gsmtap.h @@ -82,8 +82,8 @@ #define GSMTAP_CHANNEL_SDCCH 0x06 #define GSMTAP_CHANNEL_SDCCH4 0x07 #define GSMTAP_CHANNEL_SDCCH8 0x08 -#define GSMTAP_CHANNEL_TCH_F 0x09 -#define GSMTAP_CHANNEL_TCH_H 0x0a +#define GSMTAP_CHANNEL_FACCH_F 0x09 /* Actually, it's FACCH/F (signaling) */ +#define GSMTAP_CHANNEL_FACCH_H 0x0a /* Actually, it's FACCH/H (signaling) */ #define GSMTAP_CHANNEL_PACCH 0x0b #define GSMTAP_CHANNEL_CBCH52 0x0c #define GSMTAP_CHANNEL_PDTCH 0x0d @@ -91,6 +91,10 @@ #define GSMTAP_CHANNEL_PDCH GSMTAP_CHANNEL_PDTCH #define GSMTAP_CHANNEL_PTCCH 0x0e #define GSMTAP_CHANNEL_CBCH51 0x0f +#define GSMTAP_CHANNEL_VOICE_F 0x10 /* voice codec payload (FR/EFR/AMR) */ +#define GSMTAP_CHANNEL_VOICE_H 0x11 /* voice codec payload (HR/AMR) */ +#define GSMTAP_CHANNEL_TCH_F GSMTAP_CHANNEL_FACCH_F /* We used the wrong naming in 2008 when we were young */ +#define GSMTAP_CHANNEL_TCH_H GSMTAP_CHANNEL_FACCH_H /* We used the wrong naming in 2008 when we were young */ /* GPRS Coding Scheme CS1..4 */ #define GSMTAP_GPRS_CS_BASE 0x20 @@ -318,3 +322,26 @@ struct gsmtap_osmocore_log_hdr { uint32_t line_nr;/*!< line number */ } src_file; } __attribute__((packed)); + +/*! First byte of type==GSMTAP_TYPE_UM sub_type==GSMTAP_CHANNEL_VOICE payload */ +enum gsmtap_um_voice_type { + /*! 1 byte TOC + 112 bits (14 octets) = 15 octets payload; + * Reference is RFC5993 Section 5.2.1 + 3GPP TS 46.030 Annex B */ + GSMTAP_UM_VOICE_HR, + /*! 33 payload bytes; Reference is RFC3551 Section 4.5.8.1 */ + GSMTAP_UM_VOICE_FR, + /*! 31 payload bytes; Reference is RFC3551 Section 4.5.9 + ETSI TS 101 318 */ + GSMTAP_UM_VOICE_EFR, + /*! 1 byte TOC + 5..31 bytes = 6..32 bytes payload; RFC4867 octet-aligned */ + GSMTAP_UM_VOICE_AMR, + /* TODO: Revisit the types below; their usage; ... */ + GSMTAP_UM_VOICE_AMR_SID_BAD, + GSMTAP_UM_VOICE_AMR_ONSET, + GSMTAP_UM_VOICE_AMR_RATSCCH, + GSMTAP_UM_VOICE_AMR_SID_UPDATE_INH, + GSMTAP_UM_VOICE_AMR_SID_FIRST_P1, + GSMTAP_UM_VOICE_AMR_SID_FIRST_P2, + GSMTAP_UM_VOICE_AMR_SID_FIRST_INH, + GSMTAP_UM_VOICE_AMR_RATSCCH_MARKER, + GSMTAP_UM_VOICE_AMR_RATSCCH_DATA, +}; diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h index f8a12a60..9b215be3 100644 --- a/include/osmocom/core/gsmtap_util.h +++ b/include/osmocom/core/gsmtap_util.h @@ -8,7 +8,11 @@ * @{ * \file gsmtap_util.h */ -uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id); +uint8_t chantype_rsl2gsmtap2(uint8_t rsl_chantype, uint8_t rsl_link_id, bool user_plane); + +uint8_t chantype_rsl2gsmtap(uint8_t rsl_chantype, uint8_t rsl_link_id) + OSMO_DEPRECATED("Use chantype_rsl2gsmtap2() instead"); + void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype, uint8_t *link_id); struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t chan_type, diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 92904e2f..bc601982 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -7,6 +7,7 @@ #include <osmocom/core/linuxlist.h> #include <stdbool.h> #include <time.h> +#include <signal.h> /*! \defgroup select Select loop abstraction * @{ @@ -68,4 +69,21 @@ int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first, const struct timespec *interval); int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned int), void *data); +/* signalfd integration */ +struct osmo_signalfd; +struct signalfd_siginfo; + +typedef void osmo_signalfd_cb(struct osmo_signalfd *osfd, const struct signalfd_siginfo *fdsi); + +struct osmo_signalfd { + struct osmo_fd ofd; + sigset_t sigset; + osmo_signalfd_cb *cb; + void *data; +}; + +struct osmo_signalfd * +osmo_signalfd_setup(void *ctx, sigset_t set, osmo_signalfd_cb *cb, void *data); + + /*! @} */ diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h index e26ca0d3..129612c6 100644 --- a/include/osmocom/core/socket.h +++ b/include/osmocom/core/socket.h @@ -87,6 +87,7 @@ int osmo_sock_get_remote_ip_port(int fd, char *port, size_t len); int osmo_sock_mcast_loop_set(int fd, bool enable); int osmo_sock_mcast_ttl_set(int fd, uint8_t ttl); int osmo_sock_mcast_all_set(int fd, bool enable); +int osmo_sock_mcast_iface_set(int fd, const char *ifname); int osmo_sock_mcast_subscribe(int fd, const char *grp_addr); int osmo_sock_local_ip(char *local_ip, const char *remote_ip); diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 01c4de6e..40f44468 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -40,7 +40,7 @@ /*! A mapping between human-readable string and numeric value */ struct value_string { - unsigned int value; /*!< numeric value */ + int value; /*!< numeric value */ const char *str; /*!< human-readable string */ }; diff --git a/include/osmocom/ctrl/ports.h b/include/osmocom/ctrl/ports.h index 25d2491b..4c3b77f9 100644 --- a/include/osmocom/ctrl/ports.h +++ b/include/osmocom/ctrl/ports.h @@ -24,4 +24,6 @@ #define OSMO_CTRL_PORT_GBPROXY 4263 /* 4264 used by VTY interface */ #define OSMO_CTRL_PORT_CBC 4265 +/* 4266 used by D-GSM mDNS */ +#define OSMO_CTRL_PORT_MGW 4267 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */ diff --git a/include/osmocom/gprs/protocol/gsm_04_60.h b/include/osmocom/gprs/protocol/gsm_04_60.h index f592b14f..05728f49 100644 --- a/include/osmocom/gprs/protocol/gsm_04_60.h +++ b/include/osmocom/gprs/protocol/gsm_04_60.h @@ -9,7 +9,6 @@ #include <stdint.h> #include <osmocom/core/endian.h> -#if OSMO_IS_LITTLE_ENDIAN == 1 /* TS 04.60 10.3a.4.1.1 */ struct gprs_rlc_ul_header_egprs_1 { #if OSMO_IS_LITTLE_ENDIAN @@ -160,158 +159,6 @@ struct gprs_rlc_dl_header_egprs_3 { uint8_t dummy:1, spb:2, cps:4, bsn1_lo:1; #endif } __attribute__ ((packed)); -#else -/* TS 04.60 10.3a.4.1.1 */ -struct gprs_rlc_ul_header_egprs_1 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:2, - cv:4, - si:1, - r:1; - uint8_t bsn1_hi:5, - tfi_lo:3; - uint8_t bsn2_hi:2, - bsn1_lo:6; - uint8_t bsn2_lo:8; - uint8_t spare_hi:1, - pi:1, - rsb:1, - cps:5; - uint8_t dummy:2, - spare_lo:6; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t r:1, si:1, cv:4, tfi_hi:2; - uint8_t tfi_lo:3, bsn1_hi:5; - uint8_t bsn1_lo:6, bsn2_hi:2; - uint8_t bsn2_lo:8; - uint8_t cps:5, rsb:1, pi:1, spare_hi:1; - uint8_t spare_lo:6, dummy:2; -#endif -} __attribute__ ((packed)); - -/* TS 04.60 10.3a.4.2.1 */ -struct gprs_rlc_ul_header_egprs_2 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:2, - cv:4, - si:1, - r:1; - uint8_t bsn1_hi:5, - tfi_lo:3; - uint8_t cps_hi:2, - bsn1_lo:6; - uint8_t spare_hi:5, - pi:1, - rsb:1, - cps_lo:1; - uint8_t dummy:3, - spare_lo:5; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t r:1, si:1, cv:4, tfi_hi:2; - uint8_t tfi_lo:3, bsn1_hi:5; - uint8_t bsn1_lo:6, cps_hi:2; - uint8_t cps_lo:1, rsb:1, pi:1, spare_hi:5; - uint8_t spare_lo:5, dummy:3; -#endif -} __attribute__ ((packed)); - -/* TS 04.60 10.3a.4.3.1 */ -struct gprs_rlc_ul_header_egprs_3 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:2, - cv:4, - si:1, - r:1; - uint8_t bsn1_hi:5, - tfi_lo:3; - uint8_t cps_hi:2, - bsn1_lo:6; - uint8_t dummy:1, - spare:1, - pi:1, - rsb:1, - spb:2, - cps_lo:2; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t r:1, si:1, cv:4, tfi_hi:2; - uint8_t tfi_lo:3, bsn1_hi:5; - uint8_t bsn1_lo:6, cps_hi:2; - uint8_t cps_lo:2, spb:2, rsb:1, pi:1, spare:1, dummy:1; -#endif -} __attribute__ ((packed)); - -struct gprs_rlc_dl_header_egprs_1 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:1, - rrbp:2, - es_p:2, - usf:3; - uint8_t bsn1_hi:2, - pr:2, - tfi_lo:4; - uint8_t bsn1_mid:8; - uint8_t bsn2_hi:7, - bsn1_lo:1; - uint8_t cps:5, - bsn2_lo:3; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; - uint8_t tfi_lo:4, pr:2, bsn1_hi:2; - uint8_t bsn1_mid:8; - uint8_t bsn1_lo:1, bsn2_hi:7; - uint8_t bsn2_lo:3, cps:5; -#endif -} __attribute__ ((packed)); - -struct gprs_rlc_dl_header_egprs_2 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:1, - rrbp:2, - es_p:2, - usf:3; - uint8_t bsn1_hi:2, - pr:2, - tfi_lo:4; - uint8_t bsn1_mid:8; - uint8_t dummy:4, - cps:3, - bsn1_lo:1; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; - uint8_t tfi_lo:4, pr:2, bsn1_hi:2; - uint8_t bsn1_mid:8; - uint8_t bsn1_lo:1, cps:3, dummy:4; -#endif -} __attribute__ ((packed)); - -struct gprs_rlc_dl_header_egprs_3 { -#if OSMO_IS_LITTLE_ENDIAN - uint8_t tfi_hi:1, - rrbp:2, - es_p:2, - usf:3; - uint8_t bsn1_hi:2, - pr:2, - tfi_lo:4; - uint8_t bsn1_mid:8; - uint8_t dummy:1, - spb:2, - cps:4, - bsn1_lo:1; -#elif OSMO_IS_BIG_ENDIAN -/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */ - uint8_t usf:3, es_p:2, rrbp:2, tfi_hi:1; - uint8_t tfi_lo:4, pr:2, bsn1_hi:2; - uint8_t bsn1_mid:8; - uint8_t bsn1_lo:1, cps:4, spb:2, dummy:1; -#endif -} __attribute__ ((packed)); -#endif /* TS 03.60 Chapter 6.3.3.1: Network Mode of Operation */ enum osmo_gprs_nmo { diff --git a/include/osmocom/gsm/l1sap.h b/include/osmocom/gsm/l1sap.h index 3d2ad253..11b27730 100644 --- a/include/osmocom/gsm/l1sap.h +++ b/include/osmocom/gsm/l1sap.h @@ -84,6 +84,7 @@ struct ph_data_param { }; int16_t lqual_cb; /*!< Link quality in centiBel */ enum osmo_ph_pres_info_type pdch_presence_info; /*!< Info regarding presence/validity of header and data parts */ + uint8_t is_sub:1; /*!< flags */ }; /*! for TCH.{req,ind} | TCH-RTS.ind */ @@ -94,6 +95,8 @@ struct ph_tch_param { uint8_t marker; /*!< RTP Marker bit (speech onset indicator) */ uint16_t ber10k; /*!< BER in units of 0.01% */ int16_t lqual_cb; /*!< Link quality in centiBel */ + int16_t ta_offs_256bits;/*!< timing advance offset (in 1/256th bits) */ + uint8_t is_sub:1; /*!< flags */ }; /*! for PH-CONN.ind */ diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h index 2bc47153..33ebdd75 100644 --- a/include/osmocom/sim/sim.h +++ b/include/osmocom/sim/sim.h @@ -9,6 +9,7 @@ #include <osmocom/core/linuxlist.h> #define APDU_HDR_LEN 5 +#define MAX_AID_LEN 16 /* Table 13.2 of TS 102 221 */ /*! command-response pairs cases * @@ -66,6 +67,8 @@ struct osim_msgb_cb { #define msgb_apdu_dc(__x) ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr)) #define msgb_apdu_de(__x) ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr) + msgb_apdu_lc(__x)) +int osim_init(void *ctx); + /* FILES */ struct osim_file; @@ -135,6 +138,7 @@ enum osim_file_type { TYPE_ADF, /*!< Application Dedicated File */ TYPE_EF, /*!< Entry File */ TYPE_EF_INT, /*!< Internal Entry File */ + TYPE_MF, /*!< Master File */ }; enum osim_ef_type { @@ -242,6 +246,9 @@ struct osim_file_desc * osim_file_desc_find_name(struct osim_file_desc *parent, const char *name); struct osim_file_desc * +osim_file_desc_find_aid(struct osim_file_desc *parent, const uint8_t *aid, uint8_t aid_len); + +struct osim_file_desc * osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid); struct osim_file_desc * @@ -281,6 +288,28 @@ struct osim_card_sw { .class = SW_CLS_NONE, .u.str = NULL \ } +/*! A card application (e.g. USIM, ISIM, HPSIM) */ +struct osim_card_app_profile { + /*! entry in the global list of card application profiles */ + struct llist_head list; + /*! human-readable name */ + const char *name; + /*! AID of this application, as used in EF.DIR */ + uint8_t aid[MAX_AID_LEN]; + uint8_t aid_len; + /*! file system description */ + struct osim_file_desc *adf; + /*! Status words defined by application */ + const struct osim_card_sw *sw; +}; + +const struct osim_card_app_profile * +osim_app_profile_find_by_name(const char *name); + +const struct osim_card_app_profile * +osim_app_profile_find_by_aid(const uint8_t *aid, uint8_t aid_len); + + /*! A card profile (e.g. SIM card */ struct osim_card_profile { const char *name; @@ -353,6 +382,19 @@ struct osim_reader_hdl { struct osim_card_hdl *card; }; +/*! descriptor for a given application present on a card */ +struct osim_card_app_hdl { + /*! member in card list of applications */ + struct llist_head list; + /*! AID of the application */ + uint8_t aid[MAX_AID_LEN]; + uint8_t aid_len; + /*! application label from EF_DIR */ + char *label; + /*! application profile (if any known) */ + const struct osim_card_app_profile *prof; +}; + struct osim_card_hdl { /*! member in global list of cards */ struct llist_head list; @@ -365,6 +407,9 @@ struct osim_card_hdl { /*! list of channels for this card */ struct llist_head channels; + + /*! list of applications found on card */ + struct llist_head apps; }; struct osim_chan_hdl { @@ -372,9 +417,15 @@ struct osim_chan_hdl { struct llist_head list; /*! card to which this channel belongs */ struct osim_card_hdl *card; + /*! current working directory */ const struct osim_file_desc *cwd; + /*! currently selected application (if any) */ + struct osim_card_app_hdl *cur_app; }; +int osim_card_hdl_add_app(struct osim_card_hdl *ch, const uint8_t *aid, uint8_t aid_len, + const char *label); + /* reader.c */ int osim_transceive_apdu(struct osim_chan_hdl *st, struct msgb *amsg); struct osim_reader_hdl *osim_reader_open(enum osim_reader_driver drv, int idx, diff --git a/include/osmocom/usb/libusb.h b/include/osmocom/usb/libusb.h index 382c86e1..2220e03d 100644 --- a/include/osmocom/usb/libusb.h +++ b/include/osmocom/usb/libusb.h @@ -62,6 +62,14 @@ char *osmo_libusb_dev_get_path_c(void *ctx, libusb_device *dev); libusb_device **osmo_libusb_find_matching_usb_devs(void *ctx, struct libusb_context *luctx, const struct dev_id *dev_ids); +libusb_device *osmo_libusb_find_matching_dev_path(struct libusb_context *luctx, + const struct dev_id *dev_ids, + const char *path); + +libusb_device *osmo_libusb_find_matching_dev_serial(struct libusb_context *luctx, + const struct dev_id *dev_ids, + const char *serial); + int osmo_libusb_dev_find_matching_interfaces(libusb_device *dev, int class, int sub_class, int protocol, struct usb_interface_match *out, unsigned int out_len); diff --git a/include/osmocom/vty/ports.h b/include/osmocom/vty/ports.h index 201e1157..56f73077 100644 --- a/include/osmocom/vty/ports.h +++ b/include/osmocom/vty/ports.h @@ -34,4 +34,5 @@ #define OSMO_VTY_PORT_HNBGW 4261 /* 4262-4263 used by control interface */ #define OSMO_VTY_PORT_CBC 4264 +#define OSMO_VTY_PORT_UECUPS 4268 /* When adding/changing port numbers, keep docs and wiki in sync. See above. */ diff --git a/include/osmocom/vty/tdef_vty.h b/include/osmocom/vty/tdef_vty.h index 6334d5ba..800af7d7 100644 --- a/include/osmocom/vty/tdef_vty.h +++ b/include/osmocom/vty/tdef_vty.h @@ -68,7 +68,7 @@ void osmo_tdef_vty_out_all_va(struct vty *vty, struct osmo_tdef *tdefs, const ch struct osmo_tdef *osmo_tdef_vty_parse_T_arg(struct vty *vty, struct osmo_tdef *tdefs, const char *osmo_tdef_str); unsigned long osmo_tdef_vty_parse_val_arg(const char *val_arg, unsigned long default_val); -void osmo_tdef_vty_groups_init(enum node_type parent_node, struct osmo_tdef_group *groups); +void osmo_tdef_vty_groups_init(unsigned int parent_cfg_node, struct osmo_tdef_group *groups); void osmo_tdef_vty_groups_write(struct vty *vty, const char *indent); /*! @} */ |