Module: sip-router
Branch: 3.3
Commit: 28be16549831df46dd1b8312da223b02359d8a9c
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=28be165…
Author: Richard Fuchs <rfuchs(a)sipwise.com>
Committer: Richard Fuchs <rfuchs(a)sipwise.com>
Date: Thu Jul 26 09:41:26 2012 -0400
modules/lcr: Fix printing of IPv4 addresses in lcr.dump_gws
IPv4 addresses were printed incorrectly. Also add special handling for
null gw addresses and print them as 0.0.0.0 for backwards compatibility.
---
modules/lcr/lcr_rpc.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/modules/lcr/lcr_rpc.c b/modules/lcr/lcr_rpc.c
index 5aec547..698b89f 100644
--- a/modules/lcr/lcr_rpc.c
+++ b/modules/lcr/lcr_rpc.c
@@ -87,13 +87,15 @@ static void dump_gws(rpc_t* rpc, void* c)
} else {
rpc->struct_add(st, "s", "scheme", "sips");
}
- if (gws[i].ip_addr.af == AF_INET)
+ switch (gws[i].ip_addr.af) {
+ case AF_INET:
rpc->struct_printf(st, "ip_addr", "%d.%d.%d.%d",
- gws[i].ip_addr.u.addr32[0],
- gws[i].ip_addr.u.addr32[1],
- gws[i].ip_addr.u.addr32[2],
- gws[i].ip_addr.u.addr32[3]);
- else /* AF_INET6 */
+ gws[i].ip_addr.u.addr[0],
+ gws[i].ip_addr.u.addr[1],
+ gws[i].ip_addr.u.addr[2],
+ gws[i].ip_addr.u.addr[3]);
+ break;
+ case AF_INET6:
rpc->struct_printf(st, "ip_addr", "%x:%x:%x:%x:%x:%x:%x:%x",
gws[i].ip_addr.u.addr16[0],
gws[i].ip_addr.u.addr16[1],
@@ -103,6 +105,11 @@ static void dump_gws(rpc_t* rpc, void* c)
gws[i].ip_addr.u.addr16[5],
gws[i].ip_addr.u.addr16[6],
gws[i].ip_addr.u.addr16[7]);
+ break;
+ case 0:
+ rpc->struct_add(st, "s", "ip_addr", "0.0.0.0");
+ break;
+ }
hostname.s=gws[i].hostname;
hostname.len=gws[i].hostname_len;
rpc->struct_add(st, "S", "hostname", &hostname);