From 49e65abef920eb377b79d5db4535084c950e0cf4 Mon Sep 17 00:00:00 2001 From: Skylar Chang Date: Wed, 13 Aug 2014 12:43:57 -0700 Subject: ipanat: move ipaNatTable device node creation For running ipacm/ipanat as net_admin instead of root on Android. The dev/ipaNatTable device node creation should be done in bootup time instead of dynamic allocate. Change-Id: Ice77752fa31b5d72f0fe5df23734801783e92253 --- ipanat/src/ipa_nat_drvi.c | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'ipanat') diff --git a/ipanat/src/ipa_nat_drvi.c b/ipanat/src/ipa_nat_drvi.c index 75b38a8..74161a7 100644 --- a/ipanat/src/ipa_nat_drvi.c +++ b/ipanat/src/ipa_nat_drvi.c @@ -165,24 +165,7 @@ uint32_t Read32BitFieldValue(uint32_t param, */ int CreateNatDevice(struct ipa_ioc_nat_alloc_mem *mem) { -#define EVENT_SIZE (sizeof (struct inotify_event)) -#define FILE_NAME_LENGTH (sizeof(NAT_DEV_NAME)*2 + 1) -#define BUF_LEN (EVENT_SIZE + FILE_NAME_LENGTH) - - int length; - int wd; - char buffer[BUF_LEN]; - int ret, inotify_fd; - - inotify_fd = inotify_init(); - if (inotify_fd < 0) { - perror("inotify_init"); - return -EINVAL; - } - - IPADBG("Waiting for nofications in dir %s\n", NAT_DEV_DIR); - wd = inotify_add_watch(inotify_fd, - NAT_DEV_DIR, IN_CREATE); + int ret; ret = ioctl(ipv4_nat_cache.ipa_fd, IPA_IOC_ALLOC_NAT_MEM, mem); if (ret != 0) { @@ -192,27 +175,6 @@ int CreateNatDevice(struct ipa_ioc_nat_alloc_mem *mem) return -EINVAL; } IPADBG("posted IPA_IOC_ALLOC_NAT_MEM to kernel successfully\n"); - - length = read(inotify_fd, buffer, BUF_LEN); - - if (length < 0) { - perror("inotify read"); - return -EINVAL; - } - - struct inotify_event *event = (struct inotify_event *)buffer; - if (event->len) { - if (event->mask & IN_CREATE) { - if (event->mask & IN_ISDIR) { - IPADBG("The directory %s was created.\n", event->name); - } else { - IPADBG("The file %s was created.\n", event->name); - } - } - } - - (void) inotify_rm_watch(inotify_fd, wd); - (void) close(inotify_fd); return 0; } -- cgit v1.2.3