From: darkcoven Date: Sat, 12 Oct 2013 17:11:27 +0000 (+0200) Subject: Raw: expose encoding functions X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e16b606f328f17800a1dab563a191555182fe32;p=ngadmin Raw: expose encoding functions --- diff --git a/raw/include/nsdp/Makefile.am b/raw/include/nsdp/Makefile.am index c2c9d40..ccce647 100644 --- a/raw/include/nsdp/Makefile.am +++ b/raw/include/nsdp/Makefile.am @@ -1,3 +1,3 @@ -noinst_HEADERS = attr.h list.h misc.h net.h protocol.h +noinst_HEADERS = attr.h encoding.h list.h misc.h net.h protocol.h diff --git a/raw/include/nsdp/encoding.h b/raw/include/nsdp/encoding.h new file mode 100644 index 0000000..27ec812 --- /dev/null +++ b/raw/include/nsdp/encoding.h @@ -0,0 +1,51 @@ + +#ifndef DEF_ENCODING +#define DEF_ENCODING + + +#include + +#include + +#include +#include +#include + + +struct nsdp_packet { + union { + unsigned char *buffer; + struct nsdp_header *nh; + }; + int maxlen; + struct attr_header *ah; +}; + + + +void initNsdpHeader (struct nsdp_header *nh, const struct nsdp_cmd *nc); + + +bool extractNsdpHeader (const struct nsdp_header *nh, struct nsdp_cmd *nc); + + +static inline void initNsdpPacket (struct nsdp_packet *np) +{ + np->ah = (struct attr_header*)np->nh->data; +} + + +static inline int getPacketTotalSize (const struct nsdp_packet *np) +{ + return ((unsigned char*)np->ah) - np->buffer; +} + + +int addPacketAttributes (struct nsdp_packet *np, const List* attr, unsigned char ports); + + +int extractPacketAttributes (struct nsdp_packet *np, List *attr, unsigned char ports); + + +#endif + diff --git a/raw/src/Makefile.am b/raw/src/Makefile.am index b0ca5db..cc047c9 100644 --- a/raw/src/Makefile.am +++ b/raw/src/Makefile.am @@ -1,5 +1,6 @@ noinst_LTLIBRARIES = librawnsdp.la +noinst_HEADERS = encoding_attr.h librawnsdp_la_SOURCES = attr.c encoding.c encoding_attr.c list.c misc.c net.c librawnsdp_la_CPPFLAGS = -I$(top_srcdir)/raw/include/ -I$(top_srcdir)/lib/include/ diff --git a/raw/src/encoding.c b/raw/src/encoding.c index a21c372..0d8e889 100644 --- a/raw/src/encoding.c +++ b/raw/src/encoding.c @@ -3,7 +3,7 @@ #include #include -#include "encoding.h" +#include #include "encoding_attr.h" diff --git a/raw/src/encoding.h b/raw/src/encoding.h deleted file mode 100644 index 27ec812..0000000 --- a/raw/src/encoding.h +++ /dev/null @@ -1,51 +0,0 @@ - -#ifndef DEF_ENCODING -#define DEF_ENCODING - - -#include - -#include - -#include -#include -#include - - -struct nsdp_packet { - union { - unsigned char *buffer; - struct nsdp_header *nh; - }; - int maxlen; - struct attr_header *ah; -}; - - - -void initNsdpHeader (struct nsdp_header *nh, const struct nsdp_cmd *nc); - - -bool extractNsdpHeader (const struct nsdp_header *nh, struct nsdp_cmd *nc); - - -static inline void initNsdpPacket (struct nsdp_packet *np) -{ - np->ah = (struct attr_header*)np->nh->data; -} - - -static inline int getPacketTotalSize (const struct nsdp_packet *np) -{ - return ((unsigned char*)np->ah) - np->buffer; -} - - -int addPacketAttributes (struct nsdp_packet *np, const List* attr, unsigned char ports); - - -int extractPacketAttributes (struct nsdp_packet *np, List *attr, unsigned char ports); - - -#endif - diff --git a/raw/src/net.c b/raw/src/net.c index c94f4eb..e5af939 100644 --- a/raw/src/net.c +++ b/raw/src/net.c @@ -8,7 +8,7 @@ #include #include -#include "encoding.h" +#include static inline void timespec_add (struct timespec *tsa, const struct timespec *tsb)