#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
static GWeb *web;
static guint web_request_id;
-#define STATUS_URL "http://ipv6.google.com/"
+#define STATUS_URL "http://ipv6.connman.net/online/status.html"
#define NLMSG_TAIL(nmsg) \
((struct rtattr *) (((void *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
memset(rth, 0, sizeof(*rth));
- rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ rth->fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
if (rth->fd < 0) {
connman_error("Can not open netlink socket: %s",
strerror(errno));
strncpy(ifr.ifr_name, "sit0", IFNAMSIZ);
ifr.ifr_ifru.ifru_data = (void *)&p;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
+ fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
ret = ioctl(fd, SIOCADDTUNNEL, &ifr);
if (ret)
connman_error("add tunnel %s failed: %s", ifr.ifr_name,
strncpy(ifr.ifr_name, "tun6to4", IFNAMSIZ);
ifr.ifr_ifru.ifru_data = (void *)&p;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
+ fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (fd < 0) {
connman_error("socket failed: %s", strerror(errno));
return;
static int init_6to4(struct in_addr *ip4addr)
{
unsigned int a, b, c, d;
+ int ret, if_index;
in_addr_t addr;
- int ret;
DBG("");
if (ret)
goto error;
+ if_index = connman_inet_ifindex("tun6to4");
+ if (if_index < 0)
+ goto error;
+
/* We try to verify that connectivity through tunnel works ok.
*/
- web = g_web_new(0);
+ web = g_web_new(if_index);
if (web == NULL)
goto error;
return -1;
}
-static void receive_rs_reply(struct nd_router_advert *reply, void *user_data)
+static void receive_rs_reply(struct nd_router_advert *reply,
+ unsigned int length, void *user_data)
{
char *address = user_data;
struct in_addr ip4addr;
- DBG("reply %p address %s", reply, address);
+ DBG("reply %p len %d address %s", reply, length, address);
/* We try to create tunnel if autoconfiguration did not work i.e.,
* we did not receive any reply to router solicitation message.
{
struct connman_ipconfig *ip4config, *ip6config;
enum connman_ipconfig_method method;
- unsigned int a, b, c, d;
+ unsigned int a, b;
struct in_addr ip4addr;
in_addr_t addr;
const char *address;
a = (addr & 0xff000000) >> 24;
b = (addr & 0x00ff0000) >> 16;
- c = (addr & 0x0000ff00) >> 8;
- d = addr & 0x000000ff;
/* 6to4 tunnel is only usable if we have a public IPv4 address */
if (a == 10 || (a == 192 && b == 168) ||
(a == 172 && (b >= 16 && b <= 31)))
return -1;
- index = connman_ipconfig_get_index(ip4config);
+ index = __connman_ipconfig_get_index(ip4config);
ip_address = g_strdup(address);
tunnel_pending = 1;