diff options
| author | Andreas Eversberg <jolly@eversberg.eu> | 2012-09-23 06:05:20 +0200 | 
|---|---|---|
| committer | Harald Welte <laforge@gnumonks.org> | 2012-09-30 14:38:20 +0200 | 
| commit | f44ed8cf92113b01caf224200d325276d24d4691 (patch) | |
| tree | a6514141495a49492e456c2f880336d0ff942759 | |
| parent | aaccdac55d2adae276c5b882bbc70fe00e191516 (diff) | |
Fix: Correcting bssgp_tx_fc_bvc, bssgp_tx_fc_ms, bssgp_tx_ul_ud
| -rw-r--r-- | include/osmocom/gprs/gprs_bssgp_bss.h | 4 | ||||
| -rw-r--r-- | src/gb/gprs_bssgp_bss.c | 35 | ||||
| -rw-r--r-- | src/gb/libosmogb.map | 2 | 
3 files changed, 30 insertions, 11 deletions
diff --git a/include/osmocom/gprs/gprs_bssgp_bss.h b/include/osmocom/gprs/gprs_bssgp_bss.h index e327939a..f34281e3 100644 --- a/include/osmocom/gprs/gprs_bssgp_bss.h +++ b/include/osmocom/gprs/gprs_bssgp_bss.h @@ -64,12 +64,12 @@ int bssgp_tx_ul_ud(struct bssgp_bvc_ctx *bctx, uint32_t tlli,  int bssgp_rx_paging(struct bssgp_paging_info *pinfo,  		    struct msgb *msg); -int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint32_t tag, +int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag,  		    uint32_t bucket_size, uint32_t bucket_leak_rate,  		    uint16_t bmax_default_ms, uint32_t r_default_ms,  		    uint8_t *bucket_full_ratio, uint32_t *queue_delay_ms); -int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tag, +int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag,  		   uint32_t ms_bucket_size, uint32_t bucket_leak_rate,  		   uint8_t *bucket_full_ratio);  #endif diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c index 9cf16efb..9cec844e 100644 --- a/src/gb/gprs_bssgp_bss.c +++ b/src/gb/gprs_bssgp_bss.c @@ -312,14 +312,14 @@ int bssgp_tx_bvc_reset(struct bssgp_bvc_ctx *bctx, uint16_t bvci, uint8_t cause)   *  \param[in] bucket_full_ratio Ratio (in percent) of queue filling   *  \param[in] queue_delay_ms Average queuing delay in milliseconds   */ -int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint32_t tag, +int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag,  		    uint32_t bucket_size, uint32_t bucket_leak_rate,  		    uint16_t bmax_default_ms, uint32_t r_default_ms,  		    uint8_t *bucket_full_ratio, uint32_t *queue_delay_ms)  {  	struct msgb *msg;  	struct bssgp_normal_hdr *bgph; -	uint16_t e_bucket_size, e_leak_rate, e_r_default_ms; +	uint16_t e_bucket_size, e_leak_rate, e_bmax_default_ms, e_r_default_ms;  	uint16_t e_queue_delay = 0; /* to make gcc happy */  	if ((bucket_size / 100) > 0xffff) @@ -330,6 +330,10 @@ int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint32_t tag,  		return -EINVAL;  	e_leak_rate = (bucket_leak_rate * 8) / 100; +	if ((bmax_default_ms / 100) > 0xffff) +		return -EINVAL; +	e_bmax_default_ms = bmax_default_ms / 100; +  	if ((r_default_ms * 8 / 100) > 0xffff)  		return -EINVAL;  	e_r_default_ms = (r_default_ms * 8) / 100; @@ -346,16 +350,17 @@ int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint32_t tag,  	msg = bssgp_msgb_alloc();  	bgph = (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));  	msgb_nsei(msg) = bctx->nsei; -	msgb_bvci(msg) = 0; /* Signalling */ +	msgb_bvci(msg) = bctx->bvci;  	bgph->pdu_type = BSSGP_PDUT_FLOW_CONTROL_BVC;  	msgb_tvlv_put(msg, BSSGP_IE_TAG, sizeof(tag), (uint8_t *)&tag);  	msgb_tvlv_put(msg, BSSGP_IE_BVC_BUCKET_SIZE, -		      sizeof(e_bucket_size), (uint8_t *) &e_bucket_size); +		     sizeof(e_bucket_size), (uint8_t *) &e_bucket_size);  	msgb_tvlv_put(msg, BSSGP_IE_BUCKET_LEAK_RATE,  		      sizeof(e_leak_rate), (uint8_t *) &e_leak_rate);  	msgb_tvlv_put(msg, BSSGP_IE_BMAX_DEFAULT_MS, -		      sizeof(bmax_default_ms), (uint8_t *) &bmax_default_ms); +		      sizeof(e_bmax_default_ms), +					(uint8_t *) &e_bmax_default_ms);  	msgb_tvlv_put(msg, BSSGP_IE_R_DEFAULT_MS,  		      sizeof(e_r_default_ms), (uint8_t *) &e_r_default_ms);  	if (bucket_full_ratio) @@ -375,13 +380,14 @@ int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint32_t tag,   *  \param[in] bucket_leak_rate Bucket leak rate in octets/sec   *  \param[in] bucket_full_ratio Ratio (in percent) of queue filling   */ -int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tag, +int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag,  		   uint32_t ms_bucket_size, uint32_t bucket_leak_rate,  		   uint8_t *bucket_full_ratio)  {  	struct msgb *msg;  	struct bssgp_normal_hdr *bgph;  	uint16_t e_bucket_size, e_leak_rate; +	uint32_t e_tlli;  	if ((ms_bucket_size / 100) > 0xffff)  		return -EINVAL; @@ -394,9 +400,11 @@ int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tag,  	msg = bssgp_msgb_alloc();  	bgph = (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));  	msgb_nsei(msg) = bctx->nsei; -	msgb_bvci(msg) = 0; /* Signalling */ +	msgb_bvci(msg) = bctx->bvci;  	bgph->pdu_type = BSSGP_PDUT_FLOW_CONTROL_MS; +	e_tlli = htonl(tlli); +	msgb_tvlv_put(msg, BSSGP_IE_TLLI, sizeof(e_tlli), (uint8_t *)&e_tlli);  	msgb_tvlv_put(msg, BSSGP_IE_TAG, sizeof(tag), (uint8_t *)&tag);  	msgb_tvlv_put(msg, BSSGP_IE_MS_BUCKET_SIZE,  		      sizeof(e_bucket_size), (uint8_t *) &e_bucket_size); @@ -415,14 +423,23 @@ int bssgp_tx_ul_ud(struct bssgp_bvc_ctx *bctx, uint32_t tlli,  {  	struct msgb *msg = llc_pdu;  	uint8_t bssgp_cid[8]; +	uint8_t bssgp_align[3] = {0, 0, 0};  	struct bssgp_ud_hdr *budh; - -	/* FIXME: First push alignment octets, if rqd */ +	int align = sizeof(*budh);  	/* FIXME: Optional LSA Identifier List, PFI */  	/* Cell Identifier */  	bssgp_create_cell_id(bssgp_cid, &bctx->ra_id, bctx->cell_id); +	align += 2; /* add T+L */ +	align += sizeof(bssgp_cid); + +	/* First push alignment IE */ +	align += 2; /* add T+L */ +	align = (4 - align) & 3; /* how many octest are required to align? */ +	msgb_tvlv_push(msg, BSSGP_IE_ALIGNMENT, align, bssgp_align); + +	/* Push other IEs */  	msgb_tvlv_push(msg, BSSGP_IE_CELL_ID, sizeof(bssgp_cid), bssgp_cid);  	/* User Data Header */ diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index d0f76f86..d65819b4 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -11,6 +11,8 @@ bssgp_parse_cell_id;  bssgp_tx_bvc_block;  bssgp_tx_bvc_reset;  bssgp_tx_bvc_unblock; +bssgp_tx_fc_bvc; +bssgp_tx_fc_ms;  bssgp_tx_flush_ll_ack;  bssgp_tx_llc_discarded;  bssgp_tx_ra_capa_upd;  | 
