diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2009-10-29 16:33:59 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2009-10-29 16:33:59 +0100 |
commit | d7d1c99a5366b6d289990ef521fb5c19ea2d4b40 (patch) | |
tree | a7a05453e04832ea7371dbe2f1f17a109242b954 /openbsc/src/input/ipaccess.c | |
parent | 5ea731338d9497e26b8bde1483de7c768f17c244 (diff) |
ip.access: Header has a 16bit length in network byte order
This is confirmed by looking at the source of their dissector.
The length can go up to 273 bytes apparently (again, according
to the source of their dissector).
Diffstat (limited to 'openbsc/src/input/ipaccess.c')
-rw-r--r-- | openbsc/src/input/ipaccess.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c index 3882ea677..34d9462b9 100644 --- a/openbsc/src/input/ipaccess.c +++ b/openbsc/src/input/ipaccess.c @@ -259,7 +259,7 @@ struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error) { struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP"); struct ipaccess_head *hh; - int ret = 0; + int len, ret = 0; if (!msg) { *error = -ENOMEM; @@ -284,8 +284,9 @@ struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error) /* then read te length as specified in header */ msg->l2h = msg->data + sizeof(*hh); - ret = recv(bfd->fd, msg->l2h, hh->len, 0); - if (ret < hh->len) { + len = ntohs(hh->len); + ret = recv(bfd->fd, msg->l2h, len, 0); + if (ret < len) { fprintf(stderr, "short read!\n"); msgb_free(msg); *error = -EIO; @@ -374,8 +375,7 @@ void ipaccess_prepend_header(struct msgb *msg, int proto) /* prepend the ip.access header */ hh = (struct ipaccess_head *) msgb_push(msg, sizeof(*hh)); - hh->zero = 0; - hh->len = msg->len - sizeof(*hh); + hh->len = htons(msg->len - sizeof(*hh)); hh->proto = proto; } |