This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22575 ) Change subject: frame_relay: Add status call-backs for link + DLC status changes ...................................................................... frame_relay: Add status call-backs for link + DLC status changes Change-Id: Iec19db4e48642c3fcb0aa11fa7787b8323fd0e5a Related: Os#4999 --- M include/osmocom/gprs/frame_relay.h M src/gb/frame_relay.c 2 files changed, 36 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/22575/1 diff --git a/include/osmocom/gprs/frame_relay.h b/include/osmocom/gprs/frame_relay.h index 2860c6b..1be37ee 100644 --- a/include/osmocom/gprs/frame_relay.h +++ b/include/osmocom/gprs/frame_relay.h @@ -87,11 +87,15 @@ /* list of data link connections at this link */ struct llist_head dlc_list; + /* optional call-back to be called for each PDU received on an unknown DLC */ int (*unknown_dlc_rx_cb)(void *cb_data, struct msgb *msg); void *unknown_dlc_rx_cb_data; + /* call-back to be called for transmitting on the underlying hardware */ int (*tx_cb)(void *data, struct msgb *msg); - void *tx_cb_data; + /* optional call-back to be called each time the status changes active/inactive */ + void (*status_cb)(struct osmo_fr_link *link, void *cb_data, bool active); + void *cb_data; }; /* Frame Relay Data Link Connection */ @@ -113,8 +117,11 @@ * NET must wait until USER confirms it implicitly by a seq number check */ bool state_send; + /* call-back to be called for each PDU received on this DLC */ int (*rx_cb)(void *cb_data, struct msgb *msg); - void *rx_cb_data; + /* optional call-back to be called each time the status changes active/inactive */ + void (*status_cb)(struct osmo_fr_dlc *dlc, void *cb_data, bool active); + void *cb_data; }; /* allocate a frame relay network */ diff --git a/src/gb/frame_relay.c b/src/gb/frame_relay.c index 03b847a..da7d771 100644 --- a/src/gb/frame_relay.c +++ b/src/gb/frame_relay.c @@ -189,6 +189,18 @@ hdr[1] = ((dlci << 4) & 0xF0) | 0x01; } +static void dlc_set_active(struct osmo_fr_dlc *dlc, bool active) +{ + if (active == dlc->active) + return; + + dlc->active = active; + + LOGPFRL(dlc->link, LOGL_NOTICE, "DLCI %u became %s\n", dlc->dlci, active ? "active" : "inactive"); + if (dlc->status_cb) + dlc->status_cb(dlc, dlc->cb_data, active); +} + /* allocate a message buffer and put Q.933 Annex A headers (L2 + L3) */ static struct msgb *q933_msgb_alloc(uint16_t dlci, uint8_t prot_disc, uint8_t msg_type) { @@ -285,7 +297,7 @@ msgb_tlv_put(resp, Q933_IEI_REPORT_TYPE, 1, &rep_type); msgb_put_link_int_verif(resp, link); - return link->tx_cb(link->tx_cb_data, resp); + return link->tx_cb(link->cb_data, resp); } /* Send a Q.933 STATUS of given type over given link */ @@ -327,7 +339,7 @@ break; } - return link->tx_cb(link->tx_cb_data, resp); + return link->tx_cb(link->cb_data, resp); } @@ -369,7 +381,7 @@ continue; if (dlc->add) { - dlc->active = link->state; + dlc_set_active(dlc, link->state); dlc->add = false; } @@ -417,11 +429,11 @@ LOGPFRL(link, LOGL_NOTICE, "Link failed\n"); link->state = false; - if (link->role == FR_ROLE_USER_EQUIPMENT) - return; + if (link->status_cb) + link->status_cb(link, link->cb_data, link->state); llist_for_each_entry(dlc, &link->dlc_list, list) { - dlc->active = false; + dlc_set_active(dlc, false); } } else { /* good link */ @@ -430,16 +442,18 @@ LOGPFRL(link, LOGL_NOTICE, "Link recovered\n"); link->state = true; + if (link->status_cb) + link->status_cb(link, link->cb_data, link->state); + if (link->role == FR_ROLE_USER_EQUIPMENT) { /* make sure the next STATUS ENQUIRY is for a full * status report to get the configred DLCs ASAP */ link->polling_count = 0; - return; } llist_for_each_entry(dlc, &link->dlc_list, list) { if (!dlc->add && !dlc->del) - dlc->active = true; + dlc_set_active(dlc, true); } } } @@ -508,7 +522,7 @@ * using the optional single PVC asynchronous status report. * Ignoring the delete. */ dlc->add = pvc->new; - dlc->active = pvc->active; + dlc_set_active(dlc, pvc->active); dlc->del = 0; } @@ -523,7 +537,7 @@ } if (!found) { - dlc->active = false; + dlc_set_active(dlc, false); dlc->del = true; } } @@ -575,7 +589,7 @@ dlc->del = 1; } else { dlc->add = pvc->new; - dlc->active = pvc->active; + dlc_set_active(dlc, pvc->active); dlc->del = 0; } } @@ -771,7 +785,7 @@ if (dlc->dlci == dlci) { /* dispatch to handler of respective DLC */ msg->dst = dlc; - return dlc->rx_cb(dlc->rx_cb_data, msg); + return dlc->rx_cb(dlc->cb_data, msg); } } @@ -816,7 +830,7 @@ dlci_to_q922(frh, dlc->dlci); msg->dst = link; - return link->tx_cb(link->tx_cb_data, msg); + return link->tx_cb(link->cb_data, msg); } /* Every T391 seconds, the user equipment sends a STATUS ENQUIRY -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22575 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iec19db4e48642c3fcb0aa11fa7787b8323fd0e5a Gerrit-Change-Number: 22575 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210131/4c071c50/attachment.htm>