gsmtap: Hide implementation of gsmtap_inst

- Use forward decl. of struct gsmtap_inst in header
 - Remove 'static inline' attributes from gsmtap_inst_fd() declaration,
   move function definition to gsmtap_util.c and mark it as deprecated
 - Add gsmtap_inst_fd2() as replacement for gsmtap_inst_fd()

Related: OS#6213
Change-Id: Ibe1a51205a6df764571b6d074e365825555609a5
This commit is contained in:
arehbein 2023-10-12 00:20:17 +02:00
parent 9519d8d27a
commit 1584b2ac39
4 changed files with 33 additions and 15 deletions

View File

@ -7,4 +7,5 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
core ADD osmo_sock_multiaddr_{add,del}_local_addr()
core ADD osmo_sock_multiaddr_{add,del}_local_addr()
core ADD gsmtap_inst_fd2() core, DEPRECATE gsmtap_inst_fd()

View File

@ -24,19 +24,12 @@ struct msgb *gsmtap_makemsg(uint16_t arfcn, uint8_t ts, uint8_t chan_type,
int8_t snr, const uint8_t *data, unsigned int len);
/*! one gsmtap instance */
struct gsmtap_inst {
int ofd_wq_mode; /*!< wait queue mode? */
struct osmo_wqueue wq; /*!< the wait queue */
struct osmo_fd sink_ofd;/*!< file descriptor */
};
struct gsmtap_inst;
/*! obtain the file descriptor associated with a gsmtap instance
* \param[in] gti GSMTAP instance
* \returns file descriptor of GSMTAP instance */
static inline int gsmtap_inst_fd(struct gsmtap_inst *gti)
{
return gti->wq.bfd.fd;
}
int gsmtap_inst_fd(struct gsmtap_inst *gti)
OSMO_DEPRECATED("Use gsmtap_inst_fd2() instead");
int gsmtap_inst_fd2(const struct gsmtap_inst *gti);
int gsmtap_source_init_fd(const char *host, uint16_t port);
int gsmtap_source_init_fd2(const char *local_host, uint16_t local_port, const char *rem_host, uint16_t rem_port);

View File

@ -46,6 +46,28 @@
*
* \file gsmtap_util.c */
/*! one gsmtap instance */
struct gsmtap_inst {
int ofd_wq_mode; /*!< wait queue mode? This field member may not be changed or moved (backwards compatibility) */
struct osmo_wqueue wq; /*!< the wait queue. This field member may not be changed or moved (backwards compatibility) */
struct osmo_fd sink_ofd; /*!< file descriptor */
};
/*! Deprecated, use gsmtap_inst_fd2() instead
* \param[in] gti GSMTAP instance
* \returns file descriptor of GSMTAP instance */
int gsmtap_inst_fd(struct gsmtap_inst *gti)
{
return gsmtap_inst_fd2(gti);
}
/*! obtain the file descriptor associated with a gsmtap instance
* \param[in] gti GSMTAP instance
* \returns file descriptor of GSMTAP instance */
int gsmtap_inst_fd2(const struct gsmtap_inst *gti)
{
return gti->wq.bfd.fd;
}
/*! convert RSL channel number to GSMTAP channel type
* \param[in] rsl_chantype RSL channel type
@ -330,7 +352,7 @@ int gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg)
/* try immediate send and return error if any */
int rc;
rc = write(gsmtap_inst_fd(gti), msg->data, msg->len);
rc = write(gsmtap_inst_fd2(gti), msg->data, msg->len);
if (rc < 0) {
return rc;
} else if (rc >= msg->len) {
@ -447,7 +469,7 @@ int gsmtap_source_add_sink(struct gsmtap_inst *gti)
{
int fd, rc;
fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd(gti));
fd = gsmtap_source_add_sink_fd(gsmtap_inst_fd2(gti));
if (fd < 0)
return fd;

View File

@ -39,6 +39,8 @@ get_string_value;
get_value_string;
get_value_string_or_null;
gsmtap_gsm_channel_names;
gsmtap_inst_fd;
gsmtap_inst_fd2;
gsmtap_makemsg;
gsmtap_makemsg_ex;
gsmtap_send;