diff options
author | RĂ©mi Denis-Courmont <remi.denis-courmont@nokia.com> | 2009-09-10 17:20:02 +0300 |
---|---|---|
committer | Aki Niemi <aki.niemi@nokia.com> | 2009-09-10 17:44:01 +0300 |
commit | 94a0c4e708df2f7b3596eb127549ec8bf23bfc79 (patch) | |
tree | feec56fd8a62811db71a2c77c7368e438837d75b /gisi/netlink.c | |
parent | 418dba1ec399c39e2c75a1fa33f6023d84b9b761 (diff) | |
download | ofono-94a0c4e708df2f7b3596eb127549ec8bf23bfc79.tar.bz2 |
gisi: cannot do ioctl() with Netlink sockets, use local instead
Diffstat (limited to 'gisi/netlink.c')
-rw-r--r-- | gisi/netlink.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gisi/netlink.c b/gisi/netlink.c index f7f97832..210ec5c1 100644 --- a/gisi/netlink.c +++ b/gisi/netlink.c @@ -56,17 +56,18 @@ static inline GIsiModem *make_modem(unsigned idx) return (void *)(uintptr_t)idx; } -static int bring_up(int fd, unsigned ifindex) +static void bring_up(unsigned ifindex) { struct ifreq req = { .ifr_ifindex = ifindex, }; + int fd = socket(PF_LOCAL, SOCK_DGRAM, 0); if (ioctl(fd, SIOCGIFNAME, &req) || ioctl(fd, SIOCGIFFLAGS, &req)) - return -errno; + goto error; req.ifr_flags |= IFF_UP | IFF_RUNNING; - if (ioctl(fd, SIOCSIFFLAGS, &req)) - return -errno; - return 0; + ioctl(fd, SIOCSIFFLAGS, &req); +error: + close(fd); } /* Parser Netlink messages */ @@ -130,7 +131,7 @@ static gboolean g_pn_nl_process(GIOChannel *channel, GIOCondition cond, if (rta->rta_type == IFA_LOCAL) memcpy(&addr, RTA_DATA(rta), 1); if (up) - bring_up(fd, ifa->ifa_index); + bring_up(ifa->ifa_index); self->callback(up, addr, make_modem(ifa->ifa_index), self->opaque); } |