ipa: Use two defines instead of magic numbers
We spearate OML/RSL by putting a magic number into the priv_nr. Use a define instead of ordinary integers.
This commit is contained in:
parent
354ef81d80
commit
dc6af631e5
|
@ -44,6 +44,9 @@
|
|||
#include <openbsc/ipaccess.h>
|
||||
#include <osmocore/talloc.h>
|
||||
|
||||
#define PRIV_OML 1
|
||||
#define PRIV_RSL 2
|
||||
|
||||
/* data structure for one E1 interface with A-bis */
|
||||
struct ia_e1_handle {
|
||||
struct bsc_fd listen_fd;
|
||||
|
@ -230,17 +233,17 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
|
|||
return -EIO;
|
||||
}
|
||||
DEBUGP(DINP, "Identified BTS %u/%u/%u\n", site_id, bts_id, trx_id);
|
||||
if (bfd->priv_nr == 1) {
|
||||
bts->oml_link = e1inp_sign_link_create(&line->ts[1-1],
|
||||
if (bfd->priv_nr == PRIV_OML) {
|
||||
bts->oml_link = e1inp_sign_link_create(&line->ts[PRIV_OML - 1],
|
||||
E1INP_SIGN_OML, bts->c0,
|
||||
bts->oml_tei, 0);
|
||||
} else if (bfd->priv_nr == 2) {
|
||||
} else if (bfd->priv_nr == PRIV_RSL) {
|
||||
struct e1inp_ts *e1i_ts;
|
||||
struct bsc_fd *newbfd;
|
||||
struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_id);
|
||||
|
||||
bfd->data = line = bts->oml_link->ts->line;
|
||||
e1i_ts = &line->ts[2+trx_id - 1];
|
||||
e1i_ts = &line->ts[PRIV_RSL + trx_id - 1];
|
||||
newbfd = &e1i_ts->driver.ipaccess.fd;
|
||||
e1inp_ts_config(e1i_ts, line, E1INP_TS_TYPE_SIGN);
|
||||
|
||||
|
@ -256,7 +259,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
|
|||
|
||||
/* get rid of our old temporary bfd */
|
||||
memcpy(newbfd, bfd, sizeof(*newbfd));
|
||||
newbfd->priv_nr = 2+trx_id;
|
||||
newbfd->priv_nr = PRIV_RSL + trx_id;
|
||||
bsc_unregister_fd(bfd);
|
||||
bsc_register_fd(newbfd);
|
||||
talloc_free(bfd);
|
||||
|
@ -536,7 +539,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
|
|||
bfd = &e1i_ts->driver.ipaccess.fd;
|
||||
bfd->fd = ret;
|
||||
bfd->data = line;
|
||||
bfd->priv_nr = 1;
|
||||
bfd->priv_nr = PRIV_OML;
|
||||
bfd->cb = ipaccess_fd_cb;
|
||||
bfd->when = BSC_FD_READ;
|
||||
ret = bsc_register_fd(bfd);
|
||||
|
@ -578,7 +581,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
|
|||
return bfd->fd;
|
||||
}
|
||||
LOGP(DINP, LOGL_NOTICE, "accept()ed new RSL link from %s\n", inet_ntoa(sa.sin_addr));
|
||||
bfd->priv_nr = 2;
|
||||
bfd->priv_nr = PRIV_RSL;
|
||||
bfd->cb = ipaccess_fd_cb;
|
||||
bfd->when = BSC_FD_READ;
|
||||
ret = bsc_register_fd(bfd);
|
||||
|
@ -652,7 +655,7 @@ int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
|
|||
bfd->cb = ipaccess_fd_cb;
|
||||
bfd->when = BSC_FD_READ | BSC_FD_WRITE;
|
||||
bfd->data = line;
|
||||
bfd->priv_nr = 1;
|
||||
bfd->priv_nr = PRIV_OML;
|
||||
|
||||
if (bfd->fd < 0) {
|
||||
LOGP(DINP, LOGL_ERROR, "could not create TCP socket.\n");
|
||||
|
|
Loading…
Reference in New Issue