From cefa4d764defe88aa3a4bd3a92236f41e2f8c02b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 4 May 2012 18:57:55 +0000 Subject: [PATCH] correctly restore ipv4 addresses from redis --- daemon/call.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon/call.c b/daemon/call.c index 6d845e0a7..6aad02816 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1580,6 +1580,7 @@ void call_restore(struct callmaster *m, char *uuid, redisReply **hash, GList *st redisReply *rps[2], *rp; int i, kernel; struct peer *p; + u_int32_t ipv4; c = call_get_or_create(hash[0]->str, NULL, m); strcpy(c->redis_uuid, uuid); @@ -1600,7 +1601,12 @@ void call_restore(struct callmaster *m, char *uuid, redisReply **hash, GList *st p = &cs->peers[i]; rp = rps[i]; - inet_pton(AF_INET6, rp->element[0]->str, &p->rtps[0].peer.ip46); + if (inet_pton(AF_INET6, rp->element[0]->str, &p->rtps[0].peer.ip46) != 1) { + ipv4 = inet_addr(rp->element[0]->str); + if (ipv4 == -1) + continue; + in4_to_6(&p->rtps[0].peer.ip46, ipv4); + } p->rtps[1].peer.ip46 = p->rtps[0].peer.ip46; p->rtps[0].peer.port = atoi(rp->element[1]->str); p->rtps[1].peer.port = p->rtps[0].peer.port + 1;