&& !get_config_string(lookup_config(myself->connection->config_tree, "Port"), &myport))
myport = xstrdup("655");
+ if(!atoi(myport)) {
+ struct addrinfo *ai = str2addrinfo("localhost", myport, SOCK_DGRAM);
+ sockaddr_t sa;
+ if(!ai || !ai->ai_addr)
+ return false;
+ free(myport);
+ memcpy(&sa, ai->ai_addr, ai->ai_addrlen);
+ sockaddr2str(&sa, NULL, &myport);
+ }
+
/* Read in all the subnets specified in the host configuration file */
cfg = lookup_config(myself->connection->config_tree, "Subnet");
if(scopeid)
*scopeid = '\0'; /* Descope. */
- *addrstr = xstrdup(address);
- *portstr = xstrdup(port);
+ if(addrstr)
+ *addrstr = xstrdup(address);
+ if(portstr)
+ *portstr = xstrdup(port);
}
char *sockaddr2hostname(const sockaddr_t *sa) {
bool ack_h(connection_t *c) {
char hisport[MAX_STRING_SIZE];
- char *hisaddress, *dummy;
+ char *hisaddress;
int weight, mtu;
uint32_t options;
node_t *n;
c->edge = new_edge();
c->edge->from = myself;
c->edge->to = n;
- sockaddr2str(&c->address, &hisaddress, &dummy);
+ sockaddr2str(&c->address, &hisaddress, NULL);
c->edge->address = str2sockaddr(hisaddress, hisport);
free(hisaddress);
- free(dummy);
c->edge->weight = (weight + c->estimated_weight) / 2;
c->edge->connection = c;
c->edge->options = c->options;