diff options
-rw-r--r-- | include/internal.h | 13 | ||||
-rw-r--r-- | src/e1_input.c | 39 | ||||
-rw-r--r-- | src/input/hsl.c | 12 | ||||
-rw-r--r-- | src/input/ipaccess.c | 5 |
4 files changed, 46 insertions, 23 deletions
diff --git a/include/internal.h b/include/internal.h index 6969748..ddb2ae2 100644 --- a/include/internal.h +++ b/include/internal.h @@ -3,6 +3,10 @@ #include <stdint.h> +struct osmo_fd; +struct e1inp_sign_link; +struct e1inp_ts; + /* talloc context for libosmo-abis. */ extern void *libosmo_abis_ctx; @@ -15,4 +19,13 @@ void ipaccess_prepend_header(struct msgb *msg, int proto); struct msgb *ipa_msg_alloc(int headroom); void ipa_msg_push_header(struct msgb *msg, uint8_t proto); +/* + * helper for internal drivers, not public + */ +void e1inp_close_socket(struct e1inp_ts *ts, + struct e1inp_sign_link *sign_link, + struct osmo_fd *bfd); + + + #endif diff --git a/src/e1_input.c b/src/e1_input.c index 1bd4744..957b74c 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -645,27 +645,46 @@ struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, return msg; } -/* called by driver in case some kind of link state event */ -int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi) +static int e1inp_int_snd_event(struct e1inp_ts *ts, + struct e1inp_sign_link *link, int evt) { - struct e1inp_sign_link *link; struct input_signal_data isd; - - link = e1inp_lookup_sign_link(ts, tei, sapi); - if (!link) - return -EINVAL; - isd.line = ts->line; isd.link_type = link->type; isd.trx = link->trx; - isd.tei = tei; - isd.sapi = sapi; + isd.tei = link->tei; + isd.sapi = link->sapi; /* report further upwards */ osmo_signal_dispatch(SS_L_INPUT, evt, &isd); return 0; } + +/* called by driver in case some kind of link state event */ +int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi) +{ + struct e1inp_sign_link *link; + + link = e1inp_lookup_sign_link(ts, tei, sapi); + if (!link) + return -EINVAL; + return e1inp_int_snd_event(ts, link, evt); +} + +void e1inp_close_socket(struct e1inp_ts *ts, + struct e1inp_sign_link *sign_link, + struct osmo_fd *bfd) +{ + e1inp_int_snd_event(ts, sign_link, S_L_INP_TEI_DN); + /* the first e1inp_sign_link_destroy call closes the socket. */ + if (bfd->fd != -1) { + osmo_fd_unregister(bfd); + close(bfd->fd); + bfd->fd = -1; + } +} + /* register a driver with the E1 core */ int e1inp_driver_register(struct e1inp_driver *drv) { diff --git a/src/input/hsl.c b/src/input/hsl.c index 408228e..3dcba1d 100644 --- a/src/input/hsl.c +++ b/src/input/hsl.c @@ -307,15 +307,9 @@ static int hsl_fd_cb(struct osmo_fd *bfd, unsigned int what) static void hsl_close(struct e1inp_sign_link *sign_link) { - struct e1inp_ts *ts = sign_link->ts; - struct osmo_fd *bfd = &ts->driver.ipaccess.fd; - e1inp_event(ts, S_L_INP_TEI_DN, sign_link->tei, sign_link->sapi); - /* the first e1inp_sign_link_destroy call closes the socket. */ - if (bfd->fd != -1) { - osmo_fd_unregister(bfd); - close(bfd->fd); - bfd->fd = -1; - } + struct e1inp_ts *e1i_ts = sign_link->ts; + struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd; + return e1inp_close_socket(e1i_ts, sign_link, bfd); } static int hsl_line_update(struct e1inp_line *line); diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 2621290..6ae9ab3 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -464,10 +464,7 @@ static void ipaccess_close(struct e1inp_sign_link *sign_link) { struct e1inp_ts *e1i_ts = sign_link->ts; struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd; - e1inp_event(e1i_ts, S_L_INP_TEI_DN, sign_link->tei, sign_link->sapi); - osmo_fd_unregister(bfd); - close(bfd->fd); - bfd->fd = -1; + return e1inp_close_socket(e1i_ts, sign_link, bfd); } static void timeout_ts1_write(void *data) |