Skip to content

Commit

Permalink
add specification and helper for VRF linkinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schultz committed Nov 22, 2016
1 parent f214e91 commit a152795
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions priv/decode_gen.escript
Expand Up @@ -849,6 +849,9 @@ define_consts() ->
{id, huint32}
]},

{{linkinfo, vrf}, [{unspec, none},
{vrf_table, huint32}]},

{{linkinfo, gtp}, [{unspec, none},
{fd0, huint32},
{fd1, huint32},
Expand Down
4 changes: 4 additions & 0 deletions src/netlink.erl
Expand Up @@ -959,11 +959,15 @@ nl_rt_dec(Protocol, << Len:32/native-integer, Type:16/native-integer, Flags:16/n
nl_rt_dec(_Protocol, << >>, Acc) ->
lists:reverse(Acc).

linkinfo_dec(Family, "vrf", Data) ->
nl_dec_nla(Family, fun decode_linkinfo_vrf/3, Data);
linkinfo_dec(Family, "gtp", Data) ->
nl_dec_nla(Family, fun decode_linkinfo_gtp/3, Data);
linkinfo_dec(_Family, _Kind, Data) ->
Data.

linkinfo_enc(Family, "vrf", Data) ->
nl_enc_nla(Family, fun encode_linkinfo_vrf/2, Data);
linkinfo_enc(Family, "gtp", Data) ->
nl_enc_nla(Family, fun encode_linkinfo_gtp/2, Data).

Expand Down
23 changes: 23 additions & 0 deletions src/netlink_decoder_gen.hrl
Expand Up @@ -2403,6 +2403,17 @@ decode_genl_ctrl_attr_mcast_grp(_Family, Id, Value) ->

%% ============================

decode_linkinfo_vrf(_Family, 0, Value) ->
{unspec, decode_none(Value)};

decode_linkinfo_vrf(_Family, 1, Value) ->
{vrf_table, decode_huint32(Value)};

decode_linkinfo_vrf(_Family, Id, Value) ->
{Id, Value}.

%% ============================

decode_linkinfo_gtp(_Family, 0, Value) ->
{unspec, decode_none(Value)};

Expand Down Expand Up @@ -4849,6 +4860,18 @@ encode_genl_ctrl_attr_mcast_grp(_Family, {Type, Value})

%% ============================

encode_linkinfo_vrf(_Family, {unspec, Value}) ->
encode_none(0, Value);

encode_linkinfo_vrf(_Family, {vrf_table, Value}) ->
encode_huint32(1, Value);

encode_linkinfo_vrf(_Family, {Type, Value})
when is_integer(Type), is_binary(Value) ->
enc_nla(Type, Value).

%% ============================

encode_linkinfo_gtp(_Family, {unspec, Value}) ->
encode_none(0, Value);

Expand Down

0 comments on commit a152795

Please sign in to comment.