From f4283be67732c2edce701762d871cf7b8495dd4a Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Fri, 17 Oct 2008 15:21:11 +0000 Subject: Fix debug output for addresses >127 --- opentracker.c | 3 ++- ot_accesslist.c | 3 ++- ot_stats.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/opentracker.c b/opentracker.c index 2a746cf..fa63378 100644 --- a/opentracker.c +++ b/opentracker.c @@ -237,7 +237,8 @@ static int64_t ot_try_bind( char ip[4], uint16_t port, PROTO_FLAG proto ) { #ifdef _DEBUG char *protos[] = {"TCP","UDP","UDP mcast"}; - fprintf( stderr, "Binding socket type %s to address %d.%d.%d.%d:%d...", protos[proto],(int)ip[0],(int)ip[1],(int)ip[2],(int)ip[3],port); + uint8_t *_ip = (uint8_t *)ip; + fprintf( stderr, "Binding socket type %s to address %d.%d.%d.%d:%d...", protos[proto],_ip[0],_ip[1],_ip[2],_ip[3],port); #endif if( socket_bind4_reuse( s, ip, port ) == -1 ) diff --git a/ot_accesslist.c b/ot_accesslist.c index 412c539..91e99b3 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c @@ -107,7 +107,8 @@ int accesslist_blessip( char *ip, ot_permissions permissions ) { memmove( g_adminip_addresses + g_adminip_count, ip, 4 ); g_adminip_permissions[ g_adminip_count++ ] = permissions; #ifdef _DEBUG - fprintf( stderr, "Blessing ip address %d.%d.%d.%d with:", (uint8_t)ip[0], (uint8_t)ip[1], (uint8_t)ip[2], (uint8_t)ip[3]); + uint8_t *_ip = (uint8_t*)ip; + fprintf( stderr, "Blessing ip address %d.%d.%d.%d with:", _ip[0], _ip[1], _ip[2], _ip[3]); if( permissions & OT_PERMISSION_MAY_STAT ) fputs( " may_fetch_stats", stderr ); if( permissions & OT_PERMISSION_MAY_SYNC ) fputs( " may_sync_batch", stderr ); if( permissions & OT_PERMISSION_MAY_LIVESYNC ) fputs( " may_sync_live", stderr ); diff --git a/ot_stats.c b/ot_stats.c index cc7dc30..8810151 100644 --- a/ot_stats.c +++ b/ot_stats.c @@ -512,14 +512,14 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uint32_t event_ break; case EVENT_FULLSCRAPE_REQUEST: { - unsigned char ip[4]; *(int*)ip = (int)proto; /* ugly hack to transfer ip to stats */ + uint8_t ip[4]; *(uint32_t*)ip = (uint32_t)proto; /* ugly hack to transfer ip to stats */ LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE\n", (unsigned int)(g_now - ot_start_time), ip[0], ip[1], ip[2], ip[3] ); ot_full_scrape_request_count++; } break; case EVENT_FULLSCRAPE_REQUEST_GZIP: { - unsigned char ip[4]; *(int*)ip = (int)proto; /* ugly hack to transfer ip to stats */ + uint8_t ip[4]; *(uint32_t*)ip = (uint32_t)proto; /* ugly hack to transfer ip to stats */ LOG_TO_STDERR( "[%08d] scrp: %d.%d.%d.%d - FULL SCRAPE GZIP\n", (unsigned int)(g_now - ot_start_time), ip[0], ip[1], ip[2], ip[3] ); ot_full_scrape_request_count++; } -- cgit v1.2.3