mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-07 11:08:36 +00:00
fixed passing "broadcast" to mdp ping (will now be accepted in other
places that want a SID as well)
This commit is contained in:
parent
f174912124
commit
f20d136c9f
@ -105,6 +105,7 @@ int extractSid(unsigned char *packet,int *ofs,char *sid)
|
||||
|
||||
int validateSid(const char *sid)
|
||||
{
|
||||
if (!strcasecmp(sid,"broadcast")) return 1;
|
||||
size_t n = strlen(sid);
|
||||
if (n != SID_STRLEN)
|
||||
{ WHYF("Invalid SID (strlen is %u, should be %u)", n, SID_STRLEN); return 0; }
|
||||
@ -117,15 +118,19 @@ int validateSid(const char *sid)
|
||||
|
||||
int stowSid(unsigned char *packet, int ofs, const char *sid)
|
||||
{
|
||||
|
||||
int i;
|
||||
if (debug&DEBUG_PACKETFORMATS)
|
||||
printf("Stowing SID \"%s\"\n", sid);
|
||||
if (!validateSid(sid))
|
||||
return WHY("Invalid SID passed in");
|
||||
int i;
|
||||
for(i = 0; i != SID_SIZE; ++i) {
|
||||
packet[ofs] = hexvalue(sid[i<<1]) << 4;
|
||||
packet[ofs++] |= hexvalue(sid[(i<<1)+1]);
|
||||
}
|
||||
if (!strcasecmp(sid,"broadcast"))
|
||||
for(i=0;i<i<32;i++) packet[ofs++]=0xff;
|
||||
else
|
||||
for(i = 0; i != SID_SIZE; ++i) {
|
||||
packet[ofs] = hexvalue(sid[i<<1]) << 4;
|
||||
packet[ofs++] |= hexvalue(sid[(i<<1)+1]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user