mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 10:46:23 +00:00
added functions for reading values from byte streams.
This commit is contained in:
parent
e5d5f3f750
commit
692817ffba
@ -61,3 +61,26 @@ void write_uint16(unsigned char *o,uint16_t v)
|
|||||||
{ *(o++)=v&0xff; v=v>>8; }
|
{ *(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;
|
||||||
|
}
|
||||||
|
3
serval.h
3
serval.h
@ -768,5 +768,8 @@ int olsr_send(struct overlay_frame *frame);
|
|||||||
void write_uint64(unsigned char *o,uint64_t v);
|
void write_uint64(unsigned char *o,uint64_t v);
|
||||||
void write_uint16(unsigned char *o,uint16_t v);
|
void write_uint16(unsigned char *o,uint16_t v);
|
||||||
void write_uint32(unsigned char *o,uint32_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
|
#endif // __SERVALD_SERVALD_H
|
||||||
|
Loading…
Reference in New Issue
Block a user