Repository : ssh://git@open-mesh.org/doc
On branches: backup-redmine/2017-07-13,master
commit 10c9693a0d75f474e92c193205a66dd8725aaaec Author: Spyros Gasteratos spyrosgaster@gmail.com Date: Sat Apr 14 22:27:28 2012 +0000
doc: batman-adv/TVLV
10c9693a0d75f474e92c193205a66dd8725aaaec batman-adv/TVLV.textile | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/batman-adv/TVLV.textile b/batman-adv/TVLV.textile index 74d0b54c..85f1e916 100644 --- a/batman-adv/TVLV.textile +++ b/batman-adv/TVLV.textile @@ -53,6 +53,71 @@ BUT there exists something even better :-) our favorite kernel already provides capabilities to create and parse tlvs transparently "/net/netlink":http://lxr.linux.no/#linux+v3.3.2/include/net/netlink.h
+So there are the following functions which could be proven helpful + +Message Construction: + +<pre> + + nlmsg_new() create a new netlink message + nlmsg_put() add a netlink message to an skb + nlmsg_put_answer() callback based nlmsg_put() + nlmsg_end() finalize netlink message + nlmsg_get_pos() return current position in message + nlmsg_trim() trim part of message + nlmsg_cancel() cancel message construction + nlmsg_free() free a netlink message + </pre> + + Message Sending: + +<pre> + nlmsg_multicast() multicast message to several groups + nlmsg_unicast() unicast a message to a single socket + nlmsg_notify() send notification message + </pre> + + Message Length Calculations: + +<pre> + nlmsg_msg_size(payload) length of message w/o padding + nlmsg_total_size(payload) length of message w/ padding + nlmsg_padlen(payload) length of padding at tail + </pre> + + Message Payload Access: + +<pre> + nlmsg_data(nlh) head of message payload + nlmsg_len(nlh) length of message payload + nlmsg_attrdata(nlh, hdrlen) head of attributes data + nlmsg_attrlen(nlh, hdrlen) length of attributes data + </pre> + Message Parsing: + +<pre> + nlmsg_ok(nlh, remaining) does nlh fit into remaining bytes? + nlmsg_next(nlh, remaining) get next netlink message + nlmsg_parse() parse attributes of a message + nlmsg_find_attr() find an attribute in a message + nlmsg_for_each_msg() loop over all messages + nlmsg_validate() validate netlink message incl. attrs + nlmsg_for_each_attr() loop over all attributes + </pre> + +netlinkmsghdr struct + +<pre> +struct nlmsghdr { + __u32 nlmsg_len; /* Length of message including header */ + __u16 nlmsg_type; /* Message content */ + __u16 nlmsg_flags; /* Additional flags */ + __u32 nlmsg_seq; /* Sequence number */ + __u32 nlmsg_pid; /* Sending process port ID */ +}; +</pre> + + (it's actually a very rich api providing even fucntions to nest a tlv message inside another tlv message)