return 0;
}
-#if 0
-
-/*
- * In a bigger mesh, there are probs with the fixed
- * bufsize. Because the Content-Length header is
- * optional, the sprintf() is changed to a more
- * scalable solution here.
- */
-
-int
-netsprintf(char *str, const char *format, ...)
-{
- va_list arg;
- int rv;
- va_start(arg, format);
- rv = vsprintf(str, format, arg);
- va_end(arg);
- if (0 != netsprintf_direct) {
- if (0 == netsprintf_error) {
- if (0 > send(client_sockets[curr_clients], str, rv, 0)) {
- olsr_printf(1, "(HTTPINFO) Failed sending data to client!\n");
- netsprintf_error = 1;
- }
- }
- return 0;
- }
- return rv;
-}
-#endif
-
/*
* Local Variables:
* c-basic-offset: 2
*ptr++ = 0;
if (olsr_cnf->ip_version == AF_INET && strchr(ptr, '.')) {
uint8_t subnetbuf[4];
- if (inet_pton(AF_INET, ptr, subnetbuf)) {
- return 1;
+ if (inet_pton(AF_INET, ptr, subnetbuf) != 1) {
+ return -1;
}
dst->prefix_len = netmask_to_prefix(subnetbuf, sizeof(subnetbuf));
dst->prefix_len = atoi(ptr);
}
}
- return inet_pton(ipversion, buf, &dst->prefix);
+ return inet_pton(ipversion, buf, &dst->prefix) == 1 ? 0 : -1;
}
/* see if the ipaddr is in the net. That is equivalent to the fact that the net part
return ip4_to_string(buf, addr4->sin_addr);
}
-/* we need to handle one value specifically since shifting 32 bits of a 32 bit integer is the same as shifting 0 bits.
- * The result is in host-byte-order.
+/* we need to handle one value specifically since shifting
+ * 32 bits of a 32 bit integer is the same as shifting 0 bits.
+ * The result is in network-byte-order.
*/
static INLINE uint32_t
prefix_to_netmask4(uint8_t prefixlen)
{
- return prefixlen == 0 ? 0 : (~0U << (32 - prefixlen));
+ return prefixlen == 0 ? 0 : (~0U >> (32 - prefixlen));
}
static INLINE bool