Skip to content

Commit

Permalink
add a plain binary value to the v1 private extension
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed Sep 12, 2022
1 parent 37dbb49 commit 4d9df24
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion include/gtp_packet.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,9 @@
}).

-record(private_extension, {
instance = 0
instance = 0,
enterprise_id = 0,
value = <<>>
}).

%% -include("gtp_packet_v2_gen.hrl").
Expand Down
3 changes: 2 additions & 1 deletion priv/ie_gen_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ ies() ->
{254, "Address of Recommended Node", '_',
[{"Address", 0, binary}]},
{255, "Private Extension", '_',
[]}
[{"Enterprise Id", 16, integer},
{"Value", 0, binary}]}
].

msgs() ->
Expand Down
14 changes: 10 additions & 4 deletions src/gtp_packet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1897,8 +1897,11 @@ decode_v1_element(<<M_address/binary>>, 254, Instance) ->
#address_of_recommended_node{instance = Instance,
address = M_address};

decode_v1_element(<<>>, 255, Instance) ->
#private_extension{instance = Instance};
decode_v1_element(<<M_enterprise_id:16/integer,
M_value/binary>>, 255, Instance) ->
#private_extension{instance = Instance,
enterprise_id = M_enterprise_id,
value = M_value};

decode_v1_element(Value, Tag, Instance) ->
{Tag, Instance, Value}.
Expand Down Expand Up @@ -2723,8 +2726,11 @@ encode_v1_element(#address_of_recommended_node{
encode_v1_element(254, Instance, <<M_address/binary>>);

encode_v1_element(#private_extension{
instance = Instance}) ->
encode_v1_element(255, Instance, <<>>);
instance = Instance,
enterprise_id = M_enterprise_id,
value = M_value}) ->
encode_v1_element(255, Instance, <<M_enterprise_id:16,
M_value/binary>>);

encode_v1_element({Tag, Instance, Value}) when is_integer(Tag), is_integer(Instance), is_binary(Value) ->
encode_v1_element(Tag, Instance, Value).
Expand Down
3 changes: 2 additions & 1 deletion test/property_test/gtplib_prop.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,8 @@ gen_address_of_recommended_node() ->

gen_private_extension() ->
#private_extension{
instance = instance()
instance = instance(),
value = binary()
}.

%% v2 generator ==========================================================================
Expand Down

0 comments on commit 4d9df24

Please sign in to comment.