mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-30 18:07:01 +00:00
Fix clang compiler warnings (revealed some bugs)
This commit is contained in:
parent
a9a1ffecde
commit
a8b88a462f
2
cli.h
2
cli.h
@ -46,7 +46,7 @@ struct cli_parsed {
|
|||||||
unsigned labelc;
|
unsigned labelc;
|
||||||
const char *const *args;
|
const char *const *args;
|
||||||
unsigned argc;
|
unsigned argc;
|
||||||
unsigned varargi;
|
int varargi; // -1 means no var args
|
||||||
};
|
};
|
||||||
|
|
||||||
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed);
|
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed);
|
||||||
|
@ -1927,7 +1927,7 @@ int app_count_peers(const struct cli_parsed *parsed, void *context)
|
|||||||
bzero(&a, sizeof(overlay_mdp_frame));
|
bzero(&a, sizeof(overlay_mdp_frame));
|
||||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||||
a.addrlist.mode = MDP_ADDRLIST_MODE_ROUTABLE_PEERS;
|
a.addrlist.mode = MDP_ADDRLIST_MODE_ROUTABLE_PEERS;
|
||||||
a.addrlist.first_sid=0x7fffffff;
|
a.addrlist.first_sid = OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
|
||||||
if (overlay_mdp_send(&a,MDP_AWAITREPLY,5000)){
|
if (overlay_mdp_send(&a,MDP_AWAITREPLY,5000)){
|
||||||
if (a.packetTypeAndFlags==MDP_ERROR)
|
if (a.packetTypeAndFlags==MDP_ERROR)
|
||||||
return WHYF(" MDP Server error #%d: '%s'",a.error.error,a.error.message);
|
return WHYF(" MDP Server error #%d: '%s'",a.error.error,a.error.message);
|
||||||
|
@ -315,7 +315,7 @@ ATOM(uint32_t, uid, 0, uint32_nonzero,, "Allowed UID for mon
|
|||||||
END_STRUCT
|
END_STRUCT
|
||||||
|
|
||||||
STRUCT(mdp_iftype)
|
STRUCT(mdp_iftype)
|
||||||
ATOM(uint32_t, tick_ms, -1, uint32_nonzero,, "Tick interval for this interface type")
|
ATOM(int32_t, tick_ms, -1, int32_nonneg,, "Tick interval for this interface type")
|
||||||
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
|
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
|
||||||
END_STRUCT
|
END_STRUCT
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ int overlay_mdp_bind(const sid_t *localaddr, int port)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int overlay_mdp_getmyaddr(int index, sid_t *sid)
|
int overlay_mdp_getmyaddr(unsigned index, sid_t *sid)
|
||||||
{
|
{
|
||||||
overlay_mdp_frame a;
|
overlay_mdp_frame a;
|
||||||
memset(&a, 0, sizeof(a));
|
memset(&a, 0, sizeof(a));
|
||||||
@ -258,7 +258,7 @@ int overlay_mdp_getmyaddr(int index, sid_t *sid)
|
|||||||
a.packetTypeAndFlags=MDP_GETADDRS;
|
a.packetTypeAndFlags=MDP_GETADDRS;
|
||||||
a.addrlist.mode = MDP_ADDRLIST_MODE_SELF;
|
a.addrlist.mode = MDP_ADDRLIST_MODE_SELF;
|
||||||
a.addrlist.first_sid=index;
|
a.addrlist.first_sid=index;
|
||||||
a.addrlist.last_sid=0x7fffffff;
|
a.addrlist.last_sid=OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
|
||||||
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
|
||||||
int result=overlay_mdp_send(&a,MDP_AWAITREPLY,5000);
|
int result=overlay_mdp_send(&a,MDP_AWAITREPLY,5000);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -794,19 +794,13 @@ static int search_subscribers(struct subscriber *subscriber, void *context){
|
|||||||
|
|
||||||
int overlay_mdp_address_list(overlay_mdp_addrlist *request, overlay_mdp_addrlist *response){
|
int overlay_mdp_address_list(overlay_mdp_addrlist *request, overlay_mdp_addrlist *response){
|
||||||
if (config.debug.mdprequests)
|
if (config.debug.mdprequests)
|
||||||
DEBUGF("MDP_GETADDRS first_sid=%u mode=%d",
|
DEBUGF("MDP_GETADDRS first_sid=%u mode=%d", request->first_sid, request->mode);
|
||||||
request->first_sid,
|
|
||||||
request->mode
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Prepare reply packet */
|
/* Prepare reply packet */
|
||||||
response->mode = request->mode;
|
response->mode = request->mode;
|
||||||
response->first_sid = request->first_sid;
|
response->first_sid = request->first_sid;
|
||||||
response->frame_sid_count = 0;
|
response->frame_sid_count = 0;
|
||||||
|
|
||||||
/* ... and constrain list for sanity */
|
|
||||||
if (response->first_sid<0) response->first_sid=0;
|
|
||||||
|
|
||||||
/* Populate with SIDs */
|
/* Populate with SIDs */
|
||||||
enum_subscribers(NULL, search_subscribers, response);
|
enum_subscribers(NULL, search_subscribers, response);
|
||||||
|
|
||||||
|
@ -112,13 +112,13 @@ int process_incoming_frame(time_ms_t now, struct overlay_interface *interface, s
|
|||||||
// duplicate the frame and queue it
|
// duplicate the frame and queue it
|
||||||
int overlay_forward_payload(struct overlay_frame *f){
|
int overlay_forward_payload(struct overlay_frame *f){
|
||||||
IN();
|
IN();
|
||||||
if (f->ttl<=0)
|
if (f->ttl == 0)
|
||||||
RETURN(0);
|
RETURN(0);
|
||||||
|
|
||||||
if (config.debug.overlayframes)
|
if (config.debug.overlayframes)
|
||||||
DEBUGF("Forwarding payload for %s, ttl=%d",
|
DEBUGF("Forwarding payload for %s, ttl=%u",
|
||||||
(f->destination?alloca_tohex_sid(f->destination->sid):"broadcast"),
|
(f->destination?alloca_tohex_sid(f->destination->sid):"broadcast"),
|
||||||
f->ttl);
|
(unsigned)f->ttl);
|
||||||
|
|
||||||
/* Queue frame for dispatch.
|
/* Queue frame for dispatch.
|
||||||
Don't forget to put packet in the correct queue based on type.
|
Don't forget to put packet in the correct queue based on type.
|
||||||
@ -212,17 +212,18 @@ int parseMdpPacketHeader(struct decode_context *context, struct overlay_frame *f
|
|||||||
frame->ttl = ttl_qos & 0x1F;
|
frame->ttl = ttl_qos & 0x1F;
|
||||||
frame->queue = (ttl_qos >> 5) & 3;
|
frame->queue = (ttl_qos >> 5) & 3;
|
||||||
}
|
}
|
||||||
frame->ttl--;
|
if (frame->ttl == 0){
|
||||||
if (frame->ttl<=0){
|
forward = 0;
|
||||||
forward=0;
|
|
||||||
if (config.debug.overlayframes)
|
if (config.debug.overlayframes)
|
||||||
DEBUGF("Don't forward when TTL expired");
|
DEBUGF("Don't forward when TTL expired");
|
||||||
}
|
} else
|
||||||
|
--frame->ttl;
|
||||||
|
|
||||||
if (flags & PAYLOAD_FLAG_LEGACY_TYPE){
|
if (flags & PAYLOAD_FLAG_LEGACY_TYPE){
|
||||||
frame->type=ob_get(buffer);
|
int ftype = ob_get(buffer);
|
||||||
if (frame->type<0)
|
if (ftype == -1)
|
||||||
RETURN(WHY("Unable to read type"));
|
RETURN(WHY("Unable to read type"));
|
||||||
|
frame->type = ftype;
|
||||||
}else
|
}else
|
||||||
frame->type=OF_TYPE_DATA;
|
frame->type=OF_TYPE_DATA;
|
||||||
|
|
||||||
|
3
serval.h
3
serval.h
@ -622,6 +622,7 @@ typedef struct overlay_mdp_error {
|
|||||||
|
|
||||||
typedef struct overlay_mdp_addrlist {
|
typedef struct overlay_mdp_addrlist {
|
||||||
int mode;
|
int mode;
|
||||||
|
#define OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT (~(unsigned int)0)
|
||||||
unsigned int server_sid_count;
|
unsigned int server_sid_count;
|
||||||
unsigned int first_sid;
|
unsigned int first_sid;
|
||||||
unsigned int last_sid;
|
unsigned int last_sid;
|
||||||
@ -693,7 +694,7 @@ void cli_put_long(int64_t value, const char *delim);
|
|||||||
void cli_put_string(const char *value, const char *delim);
|
void cli_put_string(const char *value, const char *delim);
|
||||||
void cli_put_hexvalue(const unsigned char *value, int length, const char *delim);
|
void cli_put_hexvalue(const unsigned char *value, int length, const char *delim);
|
||||||
|
|
||||||
int overlay_mdp_getmyaddr(int index, sid_t *sid);
|
int overlay_mdp_getmyaddr(unsigned index, sid_t *sid);
|
||||||
int overlay_mdp_bind(const sid_t *localaddr, int port) ;
|
int overlay_mdp_bind(const sid_t *localaddr, int port) ;
|
||||||
int overlay_route_node_info(overlay_mdp_nodeinfo *node_info);
|
int overlay_route_node_info(overlay_mdp_nodeinfo *node_info);
|
||||||
int overlay_interface_register(char *name,
|
int overlay_interface_register(char *name,
|
||||||
|
Loading…
Reference in New Issue
Block a user