- int ret = __netconfig_rtnl_open(&rth, 0, NETLINK_ROUTE);
- if (ret < 0) {
- DBG("Failed to open rtnl socket");
+ struct in6_rtmsg rt;
+ int fd = 0;
+ int err = 0;
+
+ memset(&rt, 0, sizeof(rt));
+
+ rt.rtmsg_dst_len = prefix_len;
+
+ rt.rtmsg_flags = RTF_UP | RTF_HOST;
+
+ if (inet_pton(AF_INET6, ip_addr, &rt.rtmsg_dst) < 0) {
+ err = -errno;
+ return err;
+ }
+
+ if (gateway != NULL) {
+ rt.rtmsg_flags |= RTF_GATEWAY;
+ if (inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway) < 0) {
+ err = -errno;
+ return err;
+ }
+ }
+
+ rt.rtmsg_metric = 1;
+
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd < 0)