Neels Hofmeyr | 3243c7c | 2018-09-30 05:01:20 +0200 | [diff] [blame^] | 1 | /* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ |
| 2 | /* IuUP CN node, minimal implementation */ |
| 3 | |
| 4 | /* _____IuUP_CN_____ |
| 5 | * | | |
| 6 | * UE <--> RNC --PDU-> osmo_iuup_cn_rx_pdu() -+-> ---+-> rx_payload() |
| 7 | * | | | |
| 8 | * | <-PDU-- tx_msg() <-------------+-- <-+--- osmo_iuup_cn_tx_payload() |
| 9 | * | | |
| 10 | * ----------------- |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | #pragma once |
| 15 | |
| 16 | struct osmo_iuup_cn; |
| 17 | struct msgb; |
| 18 | |
| 19 | typedef int (*osmo_iuup_data_cb_t)(struct msgb *msg, void *node_priv, void *pdu_priv); |
| 20 | |
| 21 | struct osmo_iuup_cn_cfg { |
| 22 | void *node_priv; |
| 23 | |
| 24 | /* When an IuUP PDU containing voice payload has been received, this callback is invoked to pass |
| 25 | * the voice payload towards the Core Network, msgb_l3() pointing at the payload. */ |
| 26 | osmo_iuup_data_cb_t rx_payload; |
| 27 | |
| 28 | /* IuUP handler sends a PDU to the IuUP peer (e.g. the RNC) */ |
| 29 | osmo_iuup_data_cb_t tx_msg; |
| 30 | }; |
| 31 | |
| 32 | bool osmo_iuup_cn_is_iuup_init(struct msgb *msg); |
| 33 | |
| 34 | struct osmo_iuup_cn *osmo_iuup_cn_init(void *ctx, struct osmo_iuup_cn_cfg *cfg, |
| 35 | const char *name_fmt, ...); |
| 36 | void osmo_iuup_cn_free(struct osmo_iuup_cn *cn); |
| 37 | |
| 38 | /* Encapsulate voice stream payload in IuUP and, if appropriate, call the tx_msg() to transmit the |
| 39 | * resulting message to the IuUP peer. msgb_l3() should point at the payload data. |
| 40 | * pdu_priv is transparently passed on to tx_msg(). |
| 41 | * Returns 0 on success, negative on error. */ |
| 42 | int osmo_iuup_cn_tx_payload(struct osmo_iuup_cn *cn, struct msgb *payload, void *pdu_priv); |
| 43 | |
| 44 | /* Feed a received PDU to the IuUP CN node. This function takes ownership of the msgb, it must not be |
| 45 | * freed by the caller. */ |
| 46 | int osmo_iuup_cn_rx_pdu(struct osmo_iuup_cn *cn, struct msgb *pdu, void *pdu_priv); |