#include <arpa/inet.h>
#include <netinet/in.h>
+#ifdef __APPLE__
+#include <libproc.h>
+#endif
+
void
__vlist_simple_init(struct vlist_simple_tree *tree, int offset)
{
return c ^ 0xFFFFFFFF;
}
+
+bool check_pid_path(int pid, const char *exe)
+{
+ int proc_exe_len;
+ int exe_len = strlen(exe);
+
+#ifdef __APPLE__
+ char proc_exe_buf[PROC_PIDPATHINFO_SIZE];
+
+ proc_exe_len = proc_pidpath(pid, proc_exe_buf, sizeof(proc_exe_buf));
+#else
+ char proc_exe[32];
+ char *proc_exe_buf = alloca(exe_len);
+
+ sprintf(proc_exe, "/proc/%d/exe", pid);
+ proc_exe_len = readlink(proc_exe, proc_exe_buf, exe_len);
+#endif
+
+ if (proc_exe_len != exe_len)
+ return false;
+
+ return !memcmp(exe, proc_exe_buf, exe_len);
+}
#ifndef __NETIFD_UTILS_H
#define __NETIFD_UTILS_H
+#include <unistd.h>
#include <stdio.h>
#include <libubox/list.h>
#include <libubox/avl.h>
unsigned int parse_netmask_string(const char *str, bool v6);
bool split_netmask(char *str, unsigned int *netmask, bool v6);
int parse_ip_and_netmask(int af, const char *str, void *addr, unsigned int *netmask);
+bool check_pid_path(int pid, const char *exe);
char * format_macaddr(uint8_t *mac);