diff --git a/libgtnl/include/libgtpnl/gtp.h b/libgtnl/include/libgtpnl/gtp.h index 8239335..10b34d5 100644 --- a/libgtnl/include/libgtpnl/gtp.h +++ b/libgtnl/include/libgtpnl/gtp.h @@ -13,11 +13,13 @@ void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr); void gtp_tunnel_set_sgsn_ip4(struct gtp_tunnel *t, struct in_addr *sgsn_addr); void gtp_tunnel_set_version(struct gtp_tunnel *t, uint32_t version); void gtp_tunnel_set_tid(struct gtp_tunnel *t, uint64_t tid); +void gtp_tunnel_set_flowid(struct gtp_tunnel *t, uint16_t flowid); const uint32_t gtp_tunnel_get_ifidx(struct gtp_tunnel *t); const struct in_addr *gtp_tunnel_get_ms_ip4(struct gtp_tunnel *t); const struct in_addr *gtp_tunnel_get_sgsn_ip4(struct gtp_tunnel *t); int gtp_tunnel_get_version(struct gtp_tunnel *t); uint64_t gtp_tunnel_get_tid(struct gtp_tunnel *t); +uint16_t gtp_tunnel_get_flowid(struct gtp_tunnel *t); #endif diff --git a/libgtnl/include/linux/gtp_nl.h b/libgtnl/include/linux/gtp_nl.h index ff45fba..0a28046 100644 --- a/libgtnl/include/linux/gtp_nl.h +++ b/libgtnl/include/linux/gtp_nl.h @@ -39,6 +39,7 @@ enum gtp_attrs { GTPA_TID, /* 64 bits for GTPv1 */ GTPA_SGSN_ADDRESS, GTPA_MS_ADDRESS, + GTPA_FLOWID, /* only for GTPv0 */ __GTPA_MAX, }; #define GTPA_MAX (__GTPA_MAX + 1) diff --git a/libgtnl/src/gtp-genl.c b/libgtnl/src/gtp-genl.c index 43ffb30..c7a0522 100644 --- a/libgtnl/src/gtp-genl.c +++ b/libgtnl/src/gtp-genl.c @@ -19,15 +19,14 @@ #include "internal.h" -static void gtp_build_payload(struct nlmsghdr *nlh, uint64_t tid, - uint32_t ifidx, uint32_t sgsn_addr, - uint32_t ms_addr, uint32_t version) +static void gtp_build_payload(struct nlmsghdr *nlh, struct gtp_tunnel *t) { - mnl_attr_put_u32(nlh, GTPA_VERSION, version); - mnl_attr_put_u32(nlh, GTPA_LINK, ifidx); - mnl_attr_put_u32(nlh, GTPA_SGSN_ADDRESS, sgsn_addr); - mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, ms_addr); - mnl_attr_put_u64(nlh, GTPA_TID, tid); + mnl_attr_put_u32(nlh, GTPA_VERSION, t->gtp_version); + mnl_attr_put_u32(nlh, GTPA_LINK, t->ifidx); + mnl_attr_put_u32(nlh, GTPA_SGSN_ADDRESS, t->sgsn_addr.s_addr); + mnl_attr_put_u32(nlh, GTPA_MS_ADDRESS, t->ms_addr.s_addr); + mnl_attr_put_u64(nlh, GTPA_TID, t->tid); + mnl_attr_put_u16(nlh, GTPA_FLOWID, t->flowid); } int gtp_add_tunnel(int genl_id, struct mnl_socket *nl, struct gtp_tunnel *t) @@ -44,8 +43,7 @@ int gtp_add_tunnel(int genl_id, struct mnl_socket *nl, struct gtp_tunnel *t) nlh = genl_nlmsg_build_hdr(buf, genl_id, NLM_F_EXCL | NLM_F_ACK, ++seq, GTP_CMD_TUNNEL_NEW); - gtp_build_payload(nlh, t->tid, t->ifidx, t->sgsn_addr.s_addr, - t->ms_addr.s_addr, t->gtp_version); + gtp_build_payload(nlh, t); if (genl_socket_talk(nl, nlh, seq, NULL, NULL) < 0) perror("genl_socket_talk"); @@ -62,7 +60,7 @@ int gtp_del_tunnel(int genl_id, struct mnl_socket *nl, struct gtp_tunnel *t) nlh = genl_nlmsg_build_hdr(buf, genl_id, NLM_F_ACK, ++seq, GTP_CMD_TUNNEL_DELETE); - gtp_build_payload(nlh, t->tid, t->ifidx, 0, 0, t->gtp_version); + gtp_build_payload(nlh, t); if (genl_socket_talk(nl, nlh, seq, NULL, NULL) < 0) perror("genl_socket_talk"); diff --git a/libgtnl/src/gtp.c b/libgtnl/src/gtp.c index 9ec523f..1986954 100644 --- a/libgtnl/src/gtp.c +++ b/libgtnl/src/gtp.c @@ -47,6 +47,12 @@ void gtp_tunnel_set_tid(struct gtp_tunnel *t, uint64_t tid) } EXPORT_SYMBOL(gtp_tunnel_set_tid); +void gtp_tunnel_set_flowid(struct gtp_tunnel *t, uint16_t flowid) +{ + t->flowid = flowid; +} +EXPORT_SYMBOL(gtp_tunnel_set_flowid); + const uint32_t gtp_tunnel_get_ifidx(struct gtp_tunnel *t) { return t->ifidx; @@ -76,3 +82,9 @@ uint64_t gtp_tunnel_get_tid(struct gtp_tunnel *t) return t->tid; } EXPORT_SYMBOL(gtp_tunnel_get_tid); + +uint16_t gtp_tunnel_get_flowid(struct gtp_tunnel *t) +{ + return t->flowid; +} +EXPORT_SYMBOL(gtp_tunnel_get_flowid); diff --git a/libgtnl/src/internal.h b/libgtnl/src/internal.h index cd2093a..75b3954 100644 --- a/libgtnl/src/internal.h +++ b/libgtnl/src/internal.h @@ -17,6 +17,7 @@ struct gtp_tunnel { struct in_addr ms_addr; struct in_addr sgsn_addr; uint64_t tid; + uint16_t flowid; int gtp_version; }; diff --git a/libgtnl/src/libgtpnl.map b/libgtnl/src/libgtpnl.map index 326bf17..2e80543 100644 --- a/libgtnl/src/libgtpnl.map +++ b/libgtnl/src/libgtpnl.map @@ -19,11 +19,13 @@ global: gtp_tunnel_set_sgsn_ip4; gtp_tunnel_set_version; gtp_tunnel_set_tid; + gtp_tunnel_set_flowid; gtp_tunnel_get_ifidx; gtp_tunnel_get_ms_ip4; gtp_tunnel_get_sgsn_ip4; gtp_tunnel_get_version; gtp_tunnel_get_tid; + gtp_tunnel_get_flowid; local: *; };