Use IN_LOOPBACKNET where is the case
Don't forget to freeifaddrs() in case of error Update a couple of debug messages
This commit is contained in:
parent
0065d26e0b
commit
298f340a61
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsm.c,v 1.3 2010/12/13 01:25:19 christos Exp $ */
|
||||
/* $NetBSD: fsm.c,v 1.4 2011/06/14 11:23:02 kefren Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
@ -50,7 +50,7 @@ char my_ldp_id[20];
|
||||
struct sockaddr mplssockaddr;
|
||||
|
||||
/* Processing a hello */
|
||||
void
|
||||
void
|
||||
run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
|
||||
struct in_addr * padd, struct in_addr * ladd, int mysock)
|
||||
{
|
||||
@ -62,7 +62,7 @@ run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
|
||||
if ((!pduid) || (!ht))
|
||||
return;
|
||||
|
||||
debugp("Received it on address: %s\n", inet_ntoa(*ladd));
|
||||
debugp("Hello received for address: %s\n", inet_ntoa(*ladd));
|
||||
debugp("Hello: Type: 0x%.4X Length: %.2d ID: %.8X\n", ht->type,
|
||||
ht->length, ht->messageid);
|
||||
|
||||
@ -73,7 +73,7 @@ run_ldp_hello(struct ldp_pdu * pduid, struct hello_tlv * ht,
|
||||
if (hi == NULL) {
|
||||
hi = malloc(sizeof(*hi));
|
||||
if (!hi) {
|
||||
fatalp("Cannot alloc a hello info");
|
||||
fatalp("Cannot alloc a hello info structure");
|
||||
return;
|
||||
}
|
||||
hi->ldp_id.s_addr = pduid->ldp_id.s_addr;
|
||||
@ -143,13 +143,14 @@ build_address_list_tlv(void)
|
||||
if ((ifb->ifa_addr->sa_family == AF_INET) &&
|
||||
(ifb->ifa_flags & IFF_UP)) {
|
||||
sa = (struct sockaddr_in *) ifb->ifa_addr;
|
||||
if (sa->sin_addr.s_addr << 24 >> 24 != 127)
|
||||
if (ntohl(sa->sin_addr.s_addr) >> 24 != IN_LOOPBACKNET)
|
||||
adrcount++;
|
||||
}
|
||||
t = malloc(sizeof(*t) + (adrcount - 1) * sizeof(struct in_addr));
|
||||
|
||||
if (!t) {
|
||||
fatalp("build_address_list_tlv: malloc problem\n");
|
||||
freeifaddrs(ifa);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -191,7 +192,7 @@ set_my_ldp_id()
|
||||
struct sockaddr_in *sa;
|
||||
|
||||
a.s_addr = 0;
|
||||
my_ldp_id[0] = 0;
|
||||
my_ldp_id[0] = '\0';
|
||||
mplssockaddr.sa_len = 0;
|
||||
|
||||
if (getifaddrs(&ifa) == -1)
|
||||
@ -208,7 +209,7 @@ set_my_ldp_id()
|
||||
continue;
|
||||
|
||||
sa = (struct sockaddr_in *) ifb->ifa_addr;
|
||||
if (ntohl(sa->sin_addr.s_addr) >> 24 == 127)
|
||||
if (ntohl(sa->sin_addr.s_addr) >> 24 == IN_LOOPBACKNET)
|
||||
continue; /* No 127/8 */
|
||||
if (ntohl(sa->sin_addr.s_addr) > ntohl(a.s_addr))
|
||||
a.s_addr = sa->sin_addr.s_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user