Dump traffic statistics over control sockets.
This commit is contained in:
		
							parent
							
								
									f5843e7d64
								
							
						
					
					
						commit
						362d8a6358
					
				
					 3 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -113,6 +113,9 @@ bool control_h(connection_t *c, char *request) {
 | 
			
		|||
			return control_return(c, REQ_DISCONNECT, found ? 0 : -2);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		case REQ_DUMP_TRAFFIC:
 | 
			
		||||
			return dump_traffic(c);
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			return send_request(c, "%d %d", CONTROL, REQ_INVALID);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,6 +37,7 @@ enum request_type {
 | 
			
		|||
	REQ_RETRY,
 | 
			
		||||
	REQ_CONNECT,
 | 
			
		||||
	REQ_DISCONNECT,
 | 
			
		||||
	REQ_DUMP_TRAFFIC,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define TINC_CTL_VERSION_CURRENT 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								src/node.c
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/node.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -179,3 +179,16 @@ bool dump_nodes(connection_t *c) {
 | 
			
		|||
 | 
			
		||||
	return send_request(c, "%d %d", CONTROL, REQ_DUMP_NODES);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool dump_traffic(connection_t *c) {
 | 
			
		||||
	splay_node_t *node;
 | 
			
		||||
	node_t *n;
 | 
			
		||||
 | 
			
		||||
	for(node = node_tree->head; node; node = node->next) {
 | 
			
		||||
		n = node->data;
 | 
			
		||||
		send_request(c, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, CONTROL, REQ_DUMP_TRAFFIC,
 | 
			
		||||
			   n->name, n->in_packets, n->in_bytes, n->out_packets, n->out_bytes);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return send_request(c, "%d %d", CONTROL, REQ_DUMP_TRAFFIC);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue