ipa: add ipa_*_send() to transmit messages

This patch adds ipa_*_send() functions to transmit messages
using the new A-bis over IP infrastructure.

This patch completes the transmission path support for the A-bis
over IP infrastructure.
This commit is contained in:
Pablo Neira Ayuso 2011-06-23 20:42:19 +02:00
parent 6af9b61a48
commit af3fed9213
2 changed files with 19 additions and 0 deletions

View File

@ -31,6 +31,8 @@ struct ipa_server_peer {
struct ipa_server_peer *ipa_server_peer_create(void *ctx, struct ipa_server_link *link, int fd, int (*cb)(struct ipa_server_peer *peer, struct msgb *msg), void *data);
void ipa_server_peer_destroy(struct ipa_server_peer *peer);
void ipa_server_peer_send(struct ipa_server_peer *peer, struct msgb *msg);
enum ipa_client_link_state {
IPA_CLIENT_LINK_STATE_NONE = 0,
IPA_CLIENT_LINK_STATE_CONNECTING = 1,
@ -56,6 +58,8 @@ void ipa_client_link_destroy(struct ipa_client_link *link);
int ipa_client_link_open(struct ipa_client_link *link);
void ipa_client_link_close(struct ipa_client_link *link);
void ipa_client_link_send(struct ipa_client_link *link, struct msgb *msg);
int ipa_msg_recv(int fd, struct msgb **rmsg);
#endif

View File

@ -199,6 +199,7 @@ ipa_client_link_create(void *ctx, struct e1inp_line *line,
ipa_link->cb = cb;
ipa_link->line = line;
ipa_link->data = data;
INIT_LLIST_HEAD(&ipa_link->tx_queue);
return ipa_link;
}
@ -242,6 +243,12 @@ static void ipa_link_timer_cb(void *data)
}
}
void ipa_client_link_send(struct ipa_client_link *link, struct msgb *msg)
{
msgb_enqueue(&link->tx_queue, msg);
link->ofd.when |= BSC_FD_WRITE;
}
int ipa_server_fd_cb(struct osmo_fd *ofd, unsigned int what)
{
int ret;
@ -401,6 +408,8 @@ ipa_server_peer_create(void *ctx, struct ipa_server_link *link, int fd,
peer->ofd.when = BSC_FD_READ;
peer->cb = cb;
peer->data = data;
INIT_LLIST_HEAD(&peer->tx_queue);
if (osmo_fd_register(&peer->ofd) < 0) {
LOGP(DINP, LOGL_ERROR, "could not register FD\n");
talloc_free(peer);
@ -415,3 +424,9 @@ void ipa_server_peer_destroy(struct ipa_server_peer *peer)
osmo_fd_unregister(&peer->ofd);
talloc_free(peer);
}
void ipa_server_peer_send(struct ipa_server_peer *peer, struct msgb *msg)
{
msgb_enqueue(&peer->tx_queue, msg);
peer->ofd.when |= BSC_FD_WRITE;
}