mirror of git://git.sysmocom.de/ofono
gisi: Remove route adding API
This commit is contained in:
parent
f6966a3c5e
commit
a7879d4e0c
|
@ -439,77 +439,3 @@ int g_pn_netlink_set_address(GIsiModem *idx, uint8_t local)
|
|||
|
||||
return netlink_setaddr(ifindex, local);
|
||||
}
|
||||
|
||||
/* Add remote address */
|
||||
static int netlink_addroute(uint32_t ifa_index, uint8_t remote)
|
||||
{
|
||||
struct rtmsg *rtm;
|
||||
struct rtattr *rta;
|
||||
uint32_t reqlen = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(*rtm)) +
|
||||
RTA_SPACE(1) +
|
||||
RTA_SPACE(sizeof(ifa_index)));
|
||||
struct req {
|
||||
struct nlmsghdr nlh;
|
||||
char buf[512];
|
||||
} req = {
|
||||
.nlh = {
|
||||
.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK
|
||||
| NLM_F_CREATE | NLM_F_APPEND,
|
||||
.nlmsg_type = RTM_NEWROUTE,
|
||||
.nlmsg_pid = getpid(),
|
||||
.nlmsg_len = reqlen,
|
||||
},
|
||||
};
|
||||
size_t buflen = sizeof(req.buf) - sizeof(*rtm);
|
||||
int fd;
|
||||
int error;
|
||||
struct sockaddr_nl addr = { .nl_family = AF_NETLINK, };
|
||||
|
||||
rtm = NLMSG_DATA(&req.nlh);
|
||||
rtm->rtm_family = AF_PHONET;
|
||||
rtm->rtm_dst_len = 6;
|
||||
rtm->rtm_src_len = 0;
|
||||
rtm->rtm_tos = 0;
|
||||
|
||||
rtm->rtm_table = RT_TABLE_MAIN;
|
||||
rtm->rtm_protocol = RTPROT_STATIC;
|
||||
rtm->rtm_scope = RT_SCOPE_UNIVERSE;
|
||||
rtm->rtm_type = RTN_UNICAST;
|
||||
rtm->rtm_flags = 0;
|
||||
|
||||
rta = IFA_RTA(rtm);
|
||||
rta->rta_type = RTA_DST;
|
||||
rta->rta_len = RTA_LENGTH(1);
|
||||
*(uint8_t *)RTA_DATA(rta) = remote;
|
||||
|
||||
rta = RTA_NEXT(rta, buflen);
|
||||
rta->rta_type = RTA_OIF;
|
||||
rta->rta_len = RTA_LENGTH(sizeof(ifa_index));
|
||||
*(uint32_t *)RTA_DATA(rta) = ifa_index;
|
||||
|
||||
fd = netlink_socket();
|
||||
if (fd == -1)
|
||||
return -errno;
|
||||
|
||||
if (sendto(fd, &req, reqlen, 0, (void *)&addr, sizeof(addr)) == -1)
|
||||
error = -errno;
|
||||
else
|
||||
error = netlink_getack(fd);
|
||||
|
||||
close(fd);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
int g_pn_netlink_add_route(GIsiModem *idx, uint8_t remote)
|
||||
{
|
||||
uint32_t ifindex = g_isi_modem_index(idx);
|
||||
|
||||
if (ifindex == 0)
|
||||
return -ENODEV;
|
||||
|
||||
if (remote != PN_DEV_SOS && remote != PN_DEV_HOST)
|
||||
return -EINVAL;
|
||||
|
||||
return netlink_addroute(ifindex, remote);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ GPhonetNetlink *g_pn_netlink_start(GIsiModem *idx,
|
|||
void g_pn_netlink_stop(GPhonetNetlink *self);
|
||||
|
||||
int g_pn_netlink_set_address(GIsiModem *, uint8_t local);
|
||||
int g_pn_netlink_add_route(GIsiModem *, uint8_t remote);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -771,15 +771,6 @@ int gpio_probe(GIsiModem *idx, unsigned addr, gpio_finished_cb_t cb, void *data)
|
|||
DBG("g_pn_netlink_set_address: %s", strerror(-error));
|
||||
}
|
||||
|
||||
#if notyet
|
||||
if (route) {
|
||||
error = g_pn_netlink_add_route(idx, PN_DEV_HOST);
|
||||
/* We get ENOTSUP on Maemo 5 kernel */
|
||||
if (error && error != -ENOTSUP)
|
||||
DBG("g_pn_netlink_add_route: %s", strerror(-error));
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue