mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-02 21:13:44 +00:00
mgcp: Move the rtp state into a struct
Use a struct to group the rtp state for the up and the down link of the bts.
This commit is contained in:
@@ -36,6 +36,12 @@ enum mgcp_connection_mode {
|
|||||||
MGCP_CONN_LOOPBACK = 4,
|
MGCP_CONN_LOOPBACK = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct mgcp_rtp_state {
|
||||||
|
int initialized;
|
||||||
|
|
||||||
|
uint16_t seq_no;
|
||||||
|
int lost_no;
|
||||||
|
};
|
||||||
|
|
||||||
struct mgcp_endpoint {
|
struct mgcp_endpoint {
|
||||||
int ci;
|
int ci;
|
||||||
@@ -73,10 +79,8 @@ struct mgcp_endpoint {
|
|||||||
unsigned int in_remote;
|
unsigned int in_remote;
|
||||||
|
|
||||||
/* sequence bits */
|
/* sequence bits */
|
||||||
uint16_t net_seq_no;
|
struct mgcp_rtp_state net_state;
|
||||||
uint16_t bts_seq_no;
|
struct mgcp_rtp_state bts_state;
|
||||||
int net_lost_no;
|
|
||||||
int bts_lost_no;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
|
#define ENDPOINT_NUMBER(endp) abs(endp - endp->cfg->endpoints)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int mgcp_send_dummy(struct mgcp_endpoint *endp)
|
|||||||
endp->net_rtp, buf, 1);
|
endp->net_rtp, buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void patch_and_count(uint16_t *last_seq, int *lost, int payload, char *data, int len)
|
static void patch_and_count(struct mgcp_rtp_state *state, int payload, char *data, int len)
|
||||||
{
|
{
|
||||||
uint16_t seq;
|
uint16_t seq;
|
||||||
struct rtp_hdr *rtp_hdr;
|
struct rtp_hdr *rtp_hdr;
|
||||||
@@ -105,14 +105,13 @@ static void patch_and_count(uint16_t *last_seq, int *lost, int payload, char *da
|
|||||||
rtp_hdr = (struct rtp_hdr *) data;
|
rtp_hdr = (struct rtp_hdr *) data;
|
||||||
seq = ntohs(rtp_hdr->sequence);
|
seq = ntohs(rtp_hdr->sequence);
|
||||||
|
|
||||||
/* 0 is assumed to be not set */
|
if (!state->initialized) {
|
||||||
if (*last_seq == 0)
|
state->seq_no = seq;
|
||||||
*last_seq = seq;
|
state->initialized = 1;
|
||||||
else if (*last_seq + 1 != seq)
|
} else if (state->seq_no + 1u != seq)
|
||||||
*lost = abs(seq - (*last_seq + 1));
|
state->lost_no = abs(seq - (state->seq_no + 1));
|
||||||
|
|
||||||
*last_seq = seq;
|
|
||||||
|
|
||||||
|
state->seq_no = seq;
|
||||||
|
|
||||||
if (payload < 0)
|
if (payload < 0)
|
||||||
return;
|
return;
|
||||||
@@ -212,14 +211,14 @@ static int rtp_data_cb(struct bsc_fd *fd, unsigned int what)
|
|||||||
|
|
||||||
if (dest == DEST_NETWORK) {
|
if (dest == DEST_NETWORK) {
|
||||||
if (proto == PROTO_RTP)
|
if (proto == PROTO_RTP)
|
||||||
patch_and_count(&endp->bts_seq_no, &endp->bts_lost_no,
|
patch_and_count(&endp->bts_state,
|
||||||
endp->net_payload_type, buf, rc);
|
endp->net_payload_type, buf, rc);
|
||||||
return udp_send(fd->fd, &endp->remote,
|
return udp_send(fd->fd, &endp->remote,
|
||||||
proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp,
|
proto == PROTO_RTP ? endp->net_rtp : endp->net_rtcp,
|
||||||
buf, rc);
|
buf, rc);
|
||||||
} else {
|
} else {
|
||||||
if (proto == PROTO_RTP)
|
if (proto == PROTO_RTP)
|
||||||
patch_and_count(&endp->net_seq_no, &endp->net_lost_no,
|
patch_and_count(&endp->net_state,
|
||||||
endp->bts_payload_type, buf, rc);
|
endp->bts_payload_type, buf, rc);
|
||||||
return udp_send(fd->fd, &endp->bts,
|
return udp_send(fd->fd, &endp->bts,
|
||||||
proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp,
|
proto == PROTO_RTP ? endp->bts_rtp : endp->bts_rtcp,
|
||||||
|
|||||||
@@ -763,8 +763,8 @@ void mgcp_free_endp(struct mgcp_endpoint *endp)
|
|||||||
memset(&endp->remote, 0, sizeof(endp->remote));
|
memset(&endp->remote, 0, sizeof(endp->remote));
|
||||||
memset(&endp->bts, 0, sizeof(endp->bts));
|
memset(&endp->bts, 0, sizeof(endp->bts));
|
||||||
|
|
||||||
endp->net_seq_no = endp->bts_seq_no = 0;
|
memset(&endp->net_state, 0, sizeof(endp->net_state));
|
||||||
endp->net_lost_no = endp->bts_lost_no = 0;
|
memset(&endp->bts_state, 0, sizeof(endp->bts_state));
|
||||||
|
|
||||||
endp->conn_mode = endp->orig_mode = MGCP_CONN_NONE;
|
endp->conn_mode = endp->orig_mode = MGCP_CONN_NONE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ DEFUN(show_mcgp, show_mgcp_cmd, "show mgcp",
|
|||||||
i, endp->ci,
|
i, endp->ci,
|
||||||
ntohs(endp->net_rtp), ntohs(endp->net_rtcp),
|
ntohs(endp->net_rtp), ntohs(endp->net_rtcp),
|
||||||
ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
|
ntohs(endp->bts_rtp), ntohs(endp->bts_rtcp),
|
||||||
inet_ntoa(endp->bts), endp->in_bts, endp->bts_lost_no,
|
inet_ntoa(endp->bts), endp->in_bts, endp->bts_state.lost_no,
|
||||||
endp->in_remote, endp->net_lost_no,
|
endp->in_remote, endp->net_state.lost_no,
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user