rlocs: Move debug outputter to common code

This commit is contained in:
Nick Thomas
2013-08-06 14:25:31 +01:00
parent 15a200eb0c
commit 47d65d8c3e
3 changed files with 34 additions and 24 deletions

View File

@@ -409,6 +409,36 @@ ssize_t rloc_encrypt( struct rloc *rloc, unsigned char *data, size_t data_len, u
return RSA_public_encrypt( data_len, data, dest, rloc->key, RSA_PKCS1_OAEP_PADDING );
}
void rlocs_debug_output( struct rlocs *reg )
{
int i;
char addr1[128], addr2[128];
info( "Configuration has parsed as:" );
for( i = 0 ; i < reg->num_entries; i++ ) {
struct rloc *current = &reg->entries[i];
inet_ntop( current->family, &current->addr, &addr1[0], 128 );
info( "RLOC %i: family %i, address %s", i, current->family, &addr1[0] );
}
for ( i = 0 ; i < reg->num_ip4_map_entries ; i++ ) {
struct ip4_eid_map_entry *current = &reg->ip4_mappings[i];
inet_ntop( AF_INET, &current->network, &addr1[0], 128 );
inet_ntop( AF_INET, &current->rloc->addr, &addr2[0], 128 );
info( "IPv4 EID mapping %i: %s/%u => %s", i, addr1, current->mask, addr2 );
}
for ( i = 0 ; i < reg->num_ip6_map_entries ; i++ ) {
struct ip6_eid_map_entry *current = &reg->ip6_mappings[i];
inet_ntop( AF_INET6, &current->network, &addr1[0], 128 );
inet_ntop( AF_INET6, &current->rloc->addr, &addr2[0], 128 );
info( "IPv6 EID mapping %i: %s/%u => %s", i, addr1, current->mask, addr2 );
}
return;
}
void rlocs_free( struct rlocs* registry )
{

View File

@@ -57,6 +57,8 @@ struct rloc *rloc_find_for_ipv4( struct rlocs *reg, struct in_addr *eid );
struct rloc *rloc_find_for_ipv6( struct rlocs *reg, struct in6_addr *eid );
struct rloc *rloc_find_by_address( struct rlocs *reg, struct in_addr *ipv4, struct in6_addr *ipv6 );
void rlocs_debug_output( struct rlocs *reg );
/* Returns -1 on error, or number of bytes written */
ssize_t rloc_encrypt( struct rloc *rloc, unsigned char *data, size_t data_len, unsigned char *dest, size_t dest_len );

View File

@@ -173,8 +173,7 @@ int wrap_ipv6_packet(struct rlocs *reg, struct recv_pkt* pkt, struct rsp_data* o
int main(int argc, char** argv)
{
wrapper wrap;
char addr1[128], addr2[128];
int i;
if ( argc < 4 ) {
warn( "Usage: %s <rloc database> <listen_ifname> <output_ifname>", argv[0] );
return 1;
@@ -190,28 +189,7 @@ int main(int argc, char** argv)
warn( "Failed to get config from %s", argv[1] );
return 1;
}
info( "Configuration has parsed as:" );
for( i = 0 ; i < wrap.rlocs->num_entries; i++ ) {
struct rloc *current = &wrap.rlocs->entries[i];
inet_ntop( current->family, &current->addr, &addr1[0], 128 );
info( "RLOC %i: family %i, address %s", i, current->family, &addr1[0] );
}
for ( i = 0 ; i < wrap.rlocs->num_ip4_map_entries ; i++ ) {
struct ip4_eid_map_entry *current = &wrap.rlocs->ip4_mappings[i];
inet_ntop( AF_INET, &current->network, &addr1[0], 128 );
inet_ntop( AF_INET, &current->rloc->addr, &addr2[0], 128 );
info( "IPv4 EID mapping %i: %s/%u => %s", i, addr1, current->mask, addr2 );
}
for ( i = 0 ; i < wrap.rlocs->num_ip6_map_entries ; i++ ) {
struct ip6_eid_map_entry *current = &wrap.rlocs->ip6_mappings[i];
inet_ntop( AF_INET6, &current->network, &addr1[0], 128 );
inet_ntop( AF_INET6, &current->rloc->addr, &addr2[0], 128 );
info( "IPv6 EID mapping %i: %s/%u => %s", i, addr1, current->mask, addr2 );
}
rlocs_debug_output( wrap.rlocs );
// TODO: We can scale the tun architecture by using multiqueue and having
// a bunch of workers, rather than this noddy scheme. If we don't jump