diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-02-03 11:03:45 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-02-03 11:03:45 +0100 |
commit | 62e836c53394acccc83283ba6b11d462ba8e8483 (patch) | |
tree | 1fa62b745fb8b570bf14dd59493e1b87890a4811 /openbsc/src/mgcp/mgcp_main.c | |
parent | 77f7afe08e2529ff7be301f6cf5298207370807f (diff) |
[mgcp] Make the mgcp_protocol generate a struct msgb*
Do not directly send data from inside the mgcp_protocol.c
implementation. Instead allocate and return a struct msgb*. The
caller can then either wrap that into the IPA protcol or directly
send it over the UDP socket.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_main.c')
-rw-r--r-- | openbsc/src/mgcp/mgcp_main.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c index 134148c62..6d8b3e9c6 100644 --- a/openbsc/src/mgcp/mgcp_main.c +++ b/openbsc/src/mgcp/mgcp_main.c @@ -106,6 +106,7 @@ static int read_call_agent(struct bsc_fd *fd, unsigned int what) struct sockaddr_in addr; socklen_t slen = sizeof(addr); struct msgb *msg; + struct msgb *resp; msg = (struct msgb *) fd->data; @@ -123,14 +124,25 @@ static int read_call_agent(struct bsc_fd *fd, unsigned int what) if (first_request) { first_request = 0; - mgcp_send_rsip(bfd.fd, &addr); + resp = mgcp_create_rsip(); + + if (resp) { + sendto(bfd.fd, resp->l2h, msgb_l2len(resp), 0, + (struct sockaddr *) &addr, sizeof(addr)); + msgb_free(resp); + } return 0; } /* handle message now */ msg->l2h = msgb_put(msg, rc); - mgcp_handle_message(bfd.fd, msg, &addr); + resp = mgcp_handle_message(msg); msgb_reset(msg); + + if (resp) { + sendto(bfd.fd, resp->l2h, msgb_l2len(resp), 0, (struct sockaddr *) &addr, sizeof(addr)); + msgb_free(resp); + } return 0; } |