use osmo_st2_ or osmo_ prefix for [shared] library symbols

Change-Id: Ie2686b30717b9541b1217802ca967cd0a4cbde9b
This commit is contained in:
Harald Welte
2019-11-24 22:46:51 +01:00
parent 964cda309d
commit 208890ad6e
6 changed files with 87 additions and 75 deletions

View File

@@ -30,13 +30,13 @@
#include <osmocom/simtrace2/apdu_dispatch.h>
/*! \brief Has the command-data phase been completed yet? */
static inline bool is_dc_complete(struct apdu_context *ac)
static inline bool is_dc_complete(struct osmo_apdu_context *ac)
{
return (ac->lc.tot == ac->lc.cur);
}
/*! \brief Has the expected-data phase been completed yet? */
static inline bool is_de_complete(struct apdu_context *ac)
static inline bool is_de_complete(struct osmo_apdu_context *ac)
{
return (ac->le.tot == ac->le.cur);
}
@@ -50,7 +50,7 @@ static const char *dump_apdu_hdr(const struct osim_apdu_cmd_hdr *h)
return buf;
}
static void dump_apdu_ctx(const struct apdu_context *ac)
static void dump_apdu_ctx(const struct osmo_apdu_context *ac)
{
printf("%s; case=%d, lc=%d(%d), le=%d(%d)\n",
dump_apdu_hdr(&ac->hdr), ac->apdu_case,
@@ -71,8 +71,8 @@ static void dump_apdu_ctx(const struct apdu_context *ac)
* The function retunrs APDU_ACT_RX_MORE_CAPDU_FROM_READER when there
* is more data to be received from the card reader (GSM Phone).
*/
int apdu_segment_in(struct apdu_context *ac, const uint8_t *apdu_buf,
unsigned int apdu_len, bool new_apdu)
int osmo_apdu_segment_in(struct osmo_apdu_context *ac, const uint8_t *apdu_buf,
unsigned int apdu_len, bool new_apdu)
{
int rc = 0;

View File

@@ -8,9 +8,10 @@
#include <unistd.h>
#include <stdio.h>
/* global GSMTAP instance */
/*! global GSMTAP instance */
static struct gsmtap_inst *g_gti;
/*! initialize the global GSMTAP instance for SIM traces */
int osmo_st2_gsmtap_init(const char *gsmtap_host)
{
if (g_gti)
@@ -26,6 +27,11 @@ int osmo_st2_gsmtap_init(const char *gsmtap_host)
return 0;
}
/*! log one APDU via the global GSMTAP instance.
* \param[in] sub_type GSMTAP sub-type (GSMTAP_SIM_* constant)
* \param[in] apdu User-provided buffer with APDU to log
* \param[in] len Length of apdu in bytes
*/
int osmo_st2_gsmtap_send_apdu(uint8_t sub_type, const uint8_t *apdu, unsigned int len)
{
struct gsmtap_hdr *gh;

View File

@@ -69,7 +69,7 @@ static void apdu_out_cb(uint8_t *buf, unsigned int len, void *user_data)
#endif
/*! \brief Transmit a given command to the SIMtrace2 device */
int st_transp_tx_msg(struct st_transport *transp, struct msgb *msg)
int osmo_st2_transp_tx_msg(struct osmo_st2_transport *transp, struct msgb *msg)
{
int rc;
@@ -106,12 +106,12 @@ static struct simtrace_msg_hdr *st_push_hdr(struct msgb *msg, uint8_t msg_class,
/* transmit a given message to a specified slot. Expects all headers
* present before calling the function */
int st_slot_tx_msg(struct st_slot *slot, struct msgb *msg,
uint8_t msg_class, uint8_t msg_type)
int osmo_st2_slot_tx_msg(struct osmo_st2_slot *slot, struct msgb *msg,
uint8_t msg_class, uint8_t msg_type)
{
st_push_hdr(msg, msg_class, msg_type, slot->slot_nr);
return st_transp_tx_msg(slot->transp, msg);
return osmo_st2_transp_tx_msg(slot->transp, msg);
}
/***********************************************************************
@@ -120,7 +120,7 @@ int st_slot_tx_msg(struct st_slot *slot, struct msgb *msg,
/*! \brief Request the SIMtrace2 to generate a card-insert signal */
int cardem_request_card_insert(struct cardem_inst *ci, bool inserted)
int osmo_st2_cardem_request_card_insert(struct osmo_st2_cardem_inst *ci, bool inserted)
{
struct msgb *msg = st_msgb_alloc();
struct cardemu_usb_msg_cardinsert *cins;
@@ -130,11 +130,11 @@ int cardem_request_card_insert(struct cardem_inst *ci, bool inserted)
if (inserted)
cins->card_insert = 1;
return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_CARDINSERT);
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_CARDINSERT);
}
/*! \brief Request the SIMtrace2 to transmit a Procedure Byte, then Rx */
int cardem_request_pb_and_rx(struct cardem_inst *ci, uint8_t pb, uint8_t le)
int osmo_st2_cardem_request_pb_and_rx(struct osmo_st2_cardem_inst *ci, uint8_t pb, uint8_t le)
{
struct msgb *msg = st_msgb_alloc();
struct cardemu_usb_msg_tx_data *txd;
@@ -148,12 +148,12 @@ int cardem_request_pb_and_rx(struct cardem_inst *ci, uint8_t pb, uint8_t le)
/* one data byte */
msgb_put_u8(msg, pb);
return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
}
/*! \brief Request the SIMtrace2 to transmit a Procedure Byte, then Tx */
int cardem_request_pb_and_tx(struct cardem_inst *ci, uint8_t pb,
const uint8_t *data, uint16_t data_len_in)
int osmo_st2_cardem_request_pb_and_tx(struct osmo_st2_cardem_inst *ci, uint8_t pb,
const uint8_t *data, uint16_t data_len_in)
{
struct msgb *msg = st_msgb_alloc();
struct cardemu_usb_msg_tx_data *txd;
@@ -173,11 +173,11 @@ int cardem_request_pb_and_tx(struct cardem_inst *ci, uint8_t pb,
cur = msgb_put(msg, data_len_in);
memcpy(cur, data, data_len_in);
return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
}
/*! \brief Request the SIMtrace2 to send a Status Word */
int cardem_request_sw_tx(struct cardem_inst *ci, const uint8_t *sw)
int osmo_st2_cardem_request_sw_tx(struct osmo_st2_cardem_inst *ci, const uint8_t *sw)
{
struct msgb *msg = st_msgb_alloc();
struct cardemu_usb_msg_tx_data *txd;
@@ -194,10 +194,10 @@ int cardem_request_sw_tx(struct cardem_inst *ci, const uint8_t *sw)
cur[0] = sw[0];
cur[1] = sw[1];
return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
}
int cardem_request_set_atr(struct cardem_inst *ci, const uint8_t *atr, unsigned int atr_len)
int osmo_st2_cardem_request_set_atr(struct osmo_st2_cardem_inst *ci, const uint8_t *atr, unsigned int atr_len)
{
struct msgb *msg = st_msgb_alloc();
struct cardemu_usb_msg_set_atr *satr;
@@ -212,14 +212,14 @@ int cardem_request_set_atr(struct cardem_inst *ci, const uint8_t *atr, unsigned
cur = msgb_put(msg, atr_len);
memcpy(cur, atr, atr_len);
return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_SET_ATR);
return osmo_st2_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_SET_ATR);
}
/***********************************************************************
* Modem Control protocol
***********************************************************************/
static int _modem_reset(struct st_slot *slot, uint8_t asserted, uint16_t pulse_ms)
static int _modem_reset(struct osmo_st2_slot *slot, uint8_t asserted, uint16_t pulse_ms)
{
struct msgb *msg = st_msgb_alloc();
struct st_modem_reset *sr ;
@@ -228,28 +228,28 @@ static int _modem_reset(struct st_slot *slot, uint8_t asserted, uint16_t pulse_m
sr->asserted = asserted;
sr->pulse_duration_msec = pulse_ms;
return st_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_DT_MODEM_RESET);
return osmo_st2_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_DT_MODEM_RESET);
}
/*! \brief pulse the RESET line of the modem for \a duration_ms milli-seconds*/
int st_modem_reset_pulse(struct st_slot *slot, uint16_t duration_ms)
int osmo_st2_modem_reset_pulse(struct osmo_st2_slot *slot, uint16_t duration_ms)
{
return _modem_reset(slot, 2, duration_ms);
}
/*! \brief assert the RESET line of the modem */
int st_modem_reset_active(struct st_slot *slot)
int osmo_st2_modem_reset_active(struct osmo_st2_slot *slot)
{
return _modem_reset(slot, 1, 0);
}
/*! \brief de-assert the RESET line of the modem */
int st_modem_reset_inactive(struct st_slot *slot)
int osmo_st2_modem_reset_inactive(struct osmo_st2_slot *slot)
{
return _modem_reset(slot, 0, 0);
}
static int _modem_sim_select(struct st_slot *slot, uint8_t remote_sim)
static int _modem_sim_select(struct osmo_st2_slot *slot, uint8_t remote_sim)
{
struct msgb *msg = st_msgb_alloc();
struct st_modem_sim_select *ss;
@@ -257,25 +257,25 @@ static int _modem_sim_select(struct st_slot *slot, uint8_t remote_sim)
ss = (struct st_modem_sim_select *) msgb_put(msg, sizeof(*ss));
ss->remote_sim = remote_sim;
return st_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_DT_MODEM_SIM_SELECT);
return osmo_st2_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_DT_MODEM_SIM_SELECT);
}
/*! \brief select local (physical) SIM for given slot */
int st_modem_sim_select_local(struct st_slot *slot)
int osmo_st2_modem_sim_select_local(struct osmo_st2_slot *slot)
{
return _modem_sim_select(slot, 0);
}
/*! \brief select remote (emulated/forwarded) SIM for given slot */
int st_modem_sim_select_remote(struct st_slot *slot)
int osmo_st2_modem_sim_select_remote(struct osmo_st2_slot *slot)
{
return _modem_sim_select(slot, 1);
}
/*! \brief Request slot to send us status information about the modem */
int st_modem_get_status(struct st_slot *slot)
int osmo_st2_modem_get_status(struct osmo_st2_slot *slot)
{
struct msgb *msg = st_msgb_alloc();
return st_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_BD_MODEM_STATUS);
return osmo_st2_slot_tx_msg(slot, msg, SIMTRACE_MSGC_MODEM, SIMTRACE_MSGT_BD_MODEM_STATUS);
}