diff --git a/packetformats.c b/packetformats.c index ea1bd24d..63b19e5b 100644 --- a/packetformats.c +++ b/packetformats.c @@ -61,3 +61,26 @@ void write_uint16(unsigned char *o,uint16_t v) { *(o++)=v&0xff; v=v>>8; } } +uint64_t read_uint64(unsigned char *o) +{ + int i; + uint64_t v=0; + for(i=0;i<8;i++) v=(v<<8)|*(o++); + return v; +} + +uint32_t read_uint32(unsigned char *o) +{ + int i; + uint32_t v=0; + for(i=0;i<4;i++) v=(v<<8)|*(o++); + return v; +} + +uint16_t read_uint16(unsigned char *o) +{ + int i; + uint16_t v=0; + for(i=0;i<2;i++) v=(v<<8)|*(o++); + return v; +} diff --git a/serval.h b/serval.h index 5be1ce15..4ed6d496 100644 --- a/serval.h +++ b/serval.h @@ -768,5 +768,8 @@ int olsr_send(struct overlay_frame *frame); void write_uint64(unsigned char *o,uint64_t v); void write_uint16(unsigned char *o,uint16_t v); void write_uint32(unsigned char *o,uint32_t v); +uint64_t read_uint64(unsigned char *o); +uint32_t read_uint32(unsigned char *o); +uint16_t read_uint16(unsigned char *o); #endif // __SERVALD_SERVALD_H