aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-06-02 10:25:40 +0200
committerHarald Welte <laforge@gnumonks.org>2010-06-02 10:25:40 +0200
commit16836a37aab8856ed75232b3f1673c591eb0bb14 (patch)
treeb85b281cb8e80baccc0710ae4088e806258519a8
parentf11b6d2f30f2a307d8b8e7398119d423ce8bb012 (diff)
[GPRS] SNDCP: Fix header length (pcomp is part of common_hdr)
Also add some more debug statements
-rw-r--r--openbsc/src/gprs/gprs_sndcp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/openbsc/src/gprs/gprs_sndcp.c b/openbsc/src/gprs/gprs_sndcp.c
index ec704e0d0..694d11a2d 100644
--- a/openbsc/src/gprs/gprs_sndcp.c
+++ b/openbsc/src/gprs/gprs_sndcp.c
@@ -146,11 +146,20 @@ static struct sndcp_entity *sndcp_entity_alloc(struct gprs_llc_lle *lle,
/* Entry point for the SNSM-ACTIVATE.indication */
int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi)
{
- if (sndcp_entity_by_lle(lle, nsapi))
+ LOGP(DSNDCP, LOGL_INFO, "SNSM-ACTIVATE.ind (TLLI=%08x, NSAPI=%u)\n",
+ lle->llme->tlli, nsapi);
+
+ if (sndcp_entity_by_lle(lle, nsapi)) {
+ LOGP(DSNDCP, LOGL_ERROR, "Trying to ACTIVATE "
+ "already-existing entity (TLLI=%08x, NSAPI=%u)\n",
+ lle->llme->tlli, nsapi);
return -EEXIST;
+ }
- if (!sndcp_entity_alloc(lle, nsapi))
+ if (!sndcp_entity_alloc(lle, nsapi)) {
+ LOGP(DSNDCP, LOGL_ERROR, "Out of memory during ACTIVATE\n");
return -ENOMEM;
+ }
return 0;
}
@@ -161,7 +170,7 @@ int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t *hd
struct sndcp_entity *sne;
struct sndcp_common_hdr *sch = (struct sndcp_common_hdr *)hdr;
struct sndcp_udata_hdr *suh;
- uint8_t *comp, *npdu;
+ uint8_t *npdu;
uint16_t npdu_num;
int npdu_len;
@@ -170,14 +179,15 @@ int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t *hd
return -EINVAL;
}
- if (len < sizeof(*sch) + sizeof(*comp) + sizeof(*suh)) {
+ if (len < sizeof(*sch) + sizeof(*suh)) {
LOGP(DGPRS, LOGL_ERROR, "SN-UNITDATA PDU too short (%u)\n", len);
return -EIO;
}
sne = sndcp_entity_by_lle(lle, sch->nsapi);
if (!sne) {
- LOGP(DGPRS, LOGL_ERROR, "Message for non-existing SNDCP Entity\n");
+ LOGP(DGPRS, LOGL_ERROR, "Message for non-existing SNDCP Entity "
+ "(TLLI=%08x, NSAPI=%u)\n", lle->llme->tlli, sch->nsapi);
return -EIO;
}
@@ -187,14 +197,13 @@ int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t *hd
return -EIO;
}
- comp = (hdr + sizeof(struct sndcp_common_hdr));
- if (comp) {
+ if (sch->pcomp || sch->dcomp) {
LOGP(DGPRS, LOGL_ERROR, "We don't support compression yet\n");
return -EIO;
}
- suh = (struct sndcp_udata_hdr *) (comp + sizeof(*comp));
- npdu_num = (suh->npdu_high << 8) | suh->npdu_low;
+ suh = (struct sndcp_udata_hdr *) (hdr + sizeof(struct sndcp_common_hdr));
+ npdu_num = (suh->npdu_high << 8) | suh->npdu_low;
npdu = (uint8_t *)suh + sizeof(*suh);
npdu_len = (msg->data + msg->len) - npdu;
if (npdu_len) {