diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2013-04-09 21:43:21 +0200 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2013-04-17 09:06:35 +0400 |
commit | d3ad0e29c57c74c93db97f165bfa43024e180db3 (patch) | |
tree | e47d5b250fc6dc796dd45d26c6d98fb830ce8673 | |
parent | 967f5689f8a38e7ac5e095e6c26edd765611f0e3 (diff) | |
download | accel-ppp-d3ad0e29c57c74c93db97f165bfa43024e180db3.tar.gz accel-ppp-d3ad0e29c57c74c93db97f165bfa43024e180db3.zip |
l2tp: Handle 64 bits attributes
Define l2tp_packet_add_int64() to create attributes of 64 bits long
integers.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.h | 1 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/packet.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.h b/accel-pppd/ctrl/l2tp/l2tp.h index 566212a3..b816bc85 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.h +++ b/accel-pppd/ctrl/l2tp/l2tp.h @@ -88,6 +88,7 @@ struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type, int l2tp_packet_send(int sock, struct l2tp_packet_t *); int l2tp_packet_add_int16(struct l2tp_packet_t *pack, int id, int16_t val, int M); int l2tp_packet_add_int32(struct l2tp_packet_t *pack, int id, int32_t val, int M); +int l2tp_packet_add_int64(struct l2tp_packet_t *pack, int id, int64_t val, int M); int l2tp_packet_add_string(struct l2tp_packet_t *pack, int id, const char *val, int M); int l2tp_packet_add_octets(struct l2tp_packet_t *pack, int id, const uint8_t *val, int size, int M); diff --git a/accel-pppd/ctrl/l2tp/packet.c b/accel-pppd/ctrl/l2tp/packet.c index 9bd11eb1..e4278a3c 100644 --- a/accel-pppd/ctrl/l2tp/packet.c +++ b/accel-pppd/ctrl/l2tp/packet.c @@ -511,6 +511,9 @@ int l2tp_packet_send(int sock, struct l2tp_packet_t *pack) case ATTR_TYPE_INT32: *(int32_t *)avp->val = htonl(attr->val.int32); break; + case ATTR_TYPE_INT64: + *(uint64_t *)avp->val = htobe64(attr->val.uint64); + break; case ATTR_TYPE_STRING: case ATTR_TYPE_OCTETS: memcpy(avp->val, attr->val.string, attr->length); @@ -800,6 +803,33 @@ err: return -1; } +int l2tp_packet_add_int64(struct l2tp_packet_t *pack, int id, int64_t val, int M) +{ + struct l2tp_attr_t *attr = attr_alloc(id, M, pack->hide_avps); + + if (!attr) + return -1; + + if (attr->H) { + if (pack->last_RV == NULL) + if (l2tp_packet_add_random_vector(pack) < 0) + goto err; + val = htobe64(val); + if (encode_attr(pack, attr, &val, sizeof(val)) < 0) + goto err; + } else { + attr->length = sizeof(val); + attr->val.uint64 = val; + } + list_add_tail(&attr->entry, &pack->attrs); + + return 0; + +err: + mempool_free(attr); + return -1; +} + int l2tp_packet_add_string(struct l2tp_packet_t *pack, int id, const char *val, int M) { struct l2tp_attr_t *attr = attr_alloc(id, M, pack->hide_avps); |