mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 13:03:33 +00:00
Add mgcp_common.h to libosmo-mgcp-client, to not need to share a header file
with libosmo-legacy-mgcp (nor the upcoming libosmo-mgcp). Both libraries use
the enum mgcp_connection_mode (and a for-loop macro and a string mangling
function), so far declared in mgcp.h, and both mgcp-dev and mgcp-client-dev
debian packages would require this header file to be installed. So far the
mgcp-client-dev lacks this header file, which causes the osmo-msc debian
package to fail building. Ways to solve:
- If both -dev debian packages installed the same header file in the same
place, they would conflict if ever installed at the same time.
- mgcp-client-dev can depend on mgcp-dev, but it seems bad to keep such a large
dependency for just one enum and two helpers.
- Instead, this patch solves this by copying the few definitions to
libosmo-mgcp-client.
Once libosmo-mgcp-client has its own copy of those definitions, it is
fully self-contained and depending builds (osmo-msc deb) will succeed.
Copy the few actually common definitions to new header
<osmocom/mgcp_client/mgcp_common.h>. The nature of this .h is that it may be
shared with future libosmo-mgcp without causing linking problems.
Remove libosmo-legacy-mgcp/mgcp_common.c file from the build of
libosmo-mgcp-client, no longer needed.
Add to new mgcp_common.h:
- enum mgcp_connection_mode;
- for_each_non_empty_line() macro.
- mgcp_msg_terminate_nul() as static function. Its complexity is just above
your average static inline, but being inline is a way to use it in both mgcp
and mgcp_client without linking problems.
Replace for_each_line() use in mgcp_client with for_each_non_empty_line()
(for_each_non_empty_line() replaces for_each_line() and uses strtok_r() instead
of a local reinvention).
mgcp_connection_mode_strs are actually only used in libosmo-mgcp-client, so
rename to mgcp_client_ prefix and move to mgcp_client.c.
BTW, the future plan for upcoming libosmo-mgcp is to use the identical header
file, and keep only one copy in the git source tree. The second copy may be
generated during 'make', to avoid code dup while having two distinct headers.
Related: I8e3359bedf973077c0a038aa04f5371a00c48fa0 (fix osmo-msc after this),
I7a5d3b9a2eb90be7e34b95efa529429f2e6c3ed8 (mgcp_common.h)
Change-Id: Ifb8f3fc2b399662a9dbba174e942352a1a21df3f
82 lines
2.5 KiB
C
82 lines
2.5 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <osmocom/mgcp_client/mgcp_common.h>
|
|
|
|
#define MGCP_CLIENT_LOCAL_ADDR_DEFAULT "0.0.0.0"
|
|
#define MGCP_CLIENT_LOCAL_PORT_DEFAULT 0
|
|
#define MGCP_CLIENT_REMOTE_ADDR_DEFAULT "127.0.0.1"
|
|
#define MGCP_CLIENT_REMOTE_PORT_DEFAULT 2427
|
|
|
|
struct msgb;
|
|
struct vty;
|
|
struct mgcp_client;
|
|
|
|
struct mgcp_client_conf {
|
|
const char *local_addr;
|
|
int local_port;
|
|
const char *remote_addr;
|
|
int remote_port;
|
|
uint16_t first_endpoint;
|
|
uint16_t last_endpoint;
|
|
uint16_t bts_base;
|
|
};
|
|
|
|
typedef unsigned int mgcp_trans_id_t;
|
|
|
|
struct mgcp_response_head {
|
|
int response_code;
|
|
mgcp_trans_id_t trans_id;
|
|
const char *comment;
|
|
};
|
|
|
|
struct mgcp_response {
|
|
char *body;
|
|
struct mgcp_response_head head;
|
|
uint16_t audio_port;
|
|
};
|
|
|
|
void mgcp_client_conf_init(struct mgcp_client_conf *conf);
|
|
void mgcp_client_vty_init(void *talloc_ctx, int node, struct mgcp_client_conf *conf);
|
|
int mgcp_client_config_write(struct vty *vty, const char *indent);
|
|
struct mgcp_client_conf *mgcp_client_conf_actual(struct mgcp_client *mgcp);
|
|
|
|
struct mgcp_client *mgcp_client_init(void *ctx,
|
|
struct mgcp_client_conf *conf);
|
|
int mgcp_client_connect(struct mgcp_client *mgcp);
|
|
|
|
const char *mgcp_client_remote_addr_str(struct mgcp_client *mgcp);
|
|
uint16_t mgcp_client_remote_port(struct mgcp_client *mgcp);
|
|
uint32_t mgcp_client_remote_addr_n(struct mgcp_client *mgcp);
|
|
|
|
int mgcp_client_next_endpoint(struct mgcp_client *client);
|
|
void mgcp_client_release_endpoint(uint16_t id, struct mgcp_client *client);
|
|
|
|
/* Invoked when an MGCP response is received or sending failed. When the
|
|
* response is passed as NULL, this indicates failure during transmission. */
|
|
typedef void (* mgcp_response_cb_t )(struct mgcp_response *response, void *priv);
|
|
int mgcp_response_parse_params(struct mgcp_response *r);
|
|
|
|
int mgcp_client_tx(struct mgcp_client *mgcp, struct msgb *msg,
|
|
mgcp_response_cb_t response_cb, void *priv);
|
|
|
|
enum mgcp_connection_mode;
|
|
|
|
struct msgb *mgcp_msg_crcx(struct mgcp_client *mgcp,
|
|
uint16_t rtp_endpoint, unsigned int call_id,
|
|
enum mgcp_connection_mode mode);
|
|
|
|
struct msgb *mgcp_msg_mdcx(struct mgcp_client *mgcp,
|
|
uint16_t rtp_endpoint, const char *rtp_conn_addr,
|
|
uint16_t rtp_port, enum mgcp_connection_mode mode);
|
|
|
|
struct msgb *mgcp_msg_dlcx(struct mgcp_client *mgcp, uint16_t rtp_endpoint,
|
|
unsigned int call_id);
|
|
|
|
extern const struct value_string mgcp_client_connection_mode_strs[];
|
|
static inline const char *mgcp_client_cmode_name(enum mgcp_connection_mode mode)
|
|
{
|
|
return get_value_string(mgcp_client_connection_mode_strs, mode);
|
|
}
|