diff options
-rw-r--r-- | include/osmocom/abis/lapd.h | 23 | ||||
-rw-r--r-- | src/input/dahdi.c | 2 | ||||
-rw-r--r-- | src/input/lapd.c | 83 | ||||
-rw-r--r-- | src/input/misdn.c | 2 |
4 files changed, 67 insertions, 43 deletions
diff --git a/include/osmocom/abis/lapd.h b/include/osmocom/abis/lapd.h index ee4ee38..03f8190 100644 --- a/include/osmocom/abis/lapd.h +++ b/include/osmocom/abis/lapd.h @@ -6,12 +6,22 @@ #include <osmocom/core/linuxlist.h> #include <osmocom/gsm/lapd_core.h> -enum lapd_profile { - LAPD_PROFILE_ISDN, - LAPD_PROFILE_ABIS, - LAPD_PROFILE_ASAT, +struct lapd_profile { + uint8_t k, k_sapi0; + int n200; + int n201; + int n202; + int t200_sec, t200_usec; + int t201_sec, t201_usec; + int t202_sec, t202_usec; + int t203_sec, t203_usec; + int short_address; }; +extern const struct lapd_profile lapd_profile_isdn; +extern const struct lapd_profile lapd_profile_abis; +extern const struct lapd_profile lapd_profile_sat; + struct lapd_instance { struct llist_head list; /* list of LAPD instances */ int network_side; @@ -22,8 +32,7 @@ struct lapd_instance { uint8_t sapi, void *rx_cbdata); void *receive_cbdata; - enum lapd_profile profile; - uint8_t short_address; + struct lapd_profile profile; /* must be a copy */ struct llist_head tei_list; /* list of TEI in this LAPD instance */ }; @@ -49,7 +58,7 @@ struct lapd_instance *lapd_instance_alloc(int network_side, void (*tx_cb)(struct msgb *msg, void *cbdata), void *tx_cbdata, void (*rx_cb)(struct osmo_dlsap_prim *odp, uint8_t tei, uint8_t sapi, void *rx_cbdata), void *rx_cbdata, - enum lapd_profile profile); + const struct lapd_profile *profile); void lapd_instance_free(struct lapd_instance *li); diff --git a/src/input/dahdi.c b/src/input/dahdi.c index edc86ba..0cefa6c 100644 --- a/src/input/dahdi.c +++ b/src/input/dahdi.c @@ -526,7 +526,7 @@ static int dahdi_e1_setup(struct e1inp_line *line) if (!e1i_ts->lapd) e1i_ts->lapd = lapd_instance_alloc(1, dahdi_write_msg, bfd, e1inp_dlsap_up, - e1i_ts, LAPD_PROFILE_ABIS); + e1i_ts, &lapd_profile_abis); break; case E1INP_TS_TYPE_TRAU: /* close/release LAPD instance, if any */ diff --git a/src/input/lapd.c b/src/input/lapd.c index d40b61c..22040cb 100644 --- a/src/input/lapd.c +++ b/src/input/lapd.c @@ -68,6 +68,39 @@ #define LAPD_LEN(len) ((len << 2) | 0x1) #define LAPD_EL 0x1 +const struct lapd_profile lapd_profile_isdn = { + 7, 0, + 3, + 260, + 3, + 1,0, + 1,0, + 10,0, + 0 +}; + +const struct lapd_profile lapd_profile_abis = { + 1, 2, + 3, + 260, + 3, + 0,240000, + 1,0, + 10,0, + 0 +}; + +const struct lapd_profile lapd_profile_sat = { + 15, 0, + 5, + 260, + 5, + 2,500000, + 2,500000, + 20,0, + 1 +}; + typedef enum { LAPD_TEI_NONE = 0, LAPD_TEI_ASSIGNED, @@ -162,9 +195,8 @@ static struct lapd_sap *lapd_sap_alloc(struct lapd_tei *teip, uint8_t sapi) struct lapd_sap *sap; struct lapd_datalink *dl; struct lapd_instance *li; - int profile; - int n201, k; - int t200_sec, t200_usec; + struct lapd_profile *profile; + int k; sap = talloc_zero(teip, struct lapd_sap); if (!sap) @@ -177,41 +209,24 @@ static struct lapd_sap *lapd_sap_alloc(struct lapd_tei *teip, uint8_t sapi) sap->tei = teip; dl = &sap->dl; li = teip->li; + profile = &li->profile; - profile = li->profile; - switch (profile) { - case LAPD_PROFILE_ABIS: - n201 = 260; - t200_sec = 0; t200_usec = 240000; - if (sapi == 0) - k = 2; - else - k = 1; - break; - case LAPD_PROFILE_ASAT: - n201 = 260; - t200_sec = 2; t200_usec = 500000; - k = 15; - li->short_address = 1; - break; - case LAPD_PROFILE_ISDN: - default: - n201 = 260; - t200_sec = 1; t200_usec = 0; - k = 7; - break; - } - - lapd_dl_init(dl, k, 128, n201); + if (sapi == 0 && profile->k_sapi0) + k = profile->k_sapi0; + else + k = profile->k; + lapd_dl_init(dl, k, 128, profile->n201); dl->use_sabme = 1; /* use SABME instead of SABM (GSM) */ dl->send_ph_data_req = send_ph_data_req; dl->send_dlsap = send_dlsap; + dl->n200 = profile->n200; + dl->n200_est_rel = profile->n200; + dl->t200_sec = profile->t200_sec; dl->t200_usec = profile->t200_usec; + dl->t203_sec = profile->t203_sec; dl->t203_usec = profile->t203_usec; dl->lctx.dl = &sap->dl; dl->lctx.sapi = sapi; dl->lctx.tei = teip->tei; - dl->lctx.n201 = n201; - dl->t200_sec = t200_sec; - dl->t200_usec = t200_usec; + dl->lctx.n201 = profile->n201; lapd_set_mode(&sap->dl, (teip->li->network_side) ? LAPD_MODE_NETWORK : LAPD_MODE_USER); @@ -512,7 +527,7 @@ static int send_ph_data_req(struct lapd_msg_ctx *lctx, struct msgb *msg) return -EINVAL; } /* address field */ - if (li->short_address && lctx->tei == 0) + if (li->profile.short_address && lctx->tei == 0) addr_len = 1; else addr_len = 2; @@ -570,7 +585,7 @@ struct lapd_instance *lapd_instance_alloc(int network_side, void (*tx_cb)(struct msgb *msg, void *cbdata), void *tx_cbdata, void (*rx_cb)(struct osmo_dlsap_prim *odp, uint8_t tei, uint8_t sapi, void *rx_cbdata), void *rx_cbdata, - enum lapd_profile profile) + const struct lapd_profile *profile) { struct lapd_instance *li; @@ -583,7 +598,7 @@ struct lapd_instance *lapd_instance_alloc(int network_side, li->transmit_cbdata = tx_cbdata; li->receive_cb = rx_cb; li->receive_cbdata = rx_cbdata; - li->profile = profile; + memcpy(&li->profile, profile, sizeof(li->profile)); INIT_LLIST_HEAD(&li->tei_list); diff --git a/src/input/misdn.c b/src/input/misdn.c index b5b57ae..10bb47e 100644 --- a/src/input/misdn.c +++ b/src/input/misdn.c @@ -547,7 +547,7 @@ static int mi_e1_setup(struct e1inp_line *line, int release_l2) addr.channel = ts; e1i_ts->lapd = lapd_instance_alloc(1, misdn_write_msg, bfd, e1inp_dlsap_up, - e1i_ts, LAPD_PROFILE_ABIS); + e1i_ts, &lapd_profile_abis); } else { addr.channel = 0; /* SAPI not supported yet in kernel */ |