Rizin
unix-like reverse engineering framework and cli tools
android-ifaddrs.h File Reference
#include <sys/cdefs.h>

Go to the source code of this file.

Classes

struct  ifaddrs
 

Macros

#define ifa_broadaddr   ifa_dstaddr /* broadcast address interface */
 

Functions

__BEGIN_DECLS int getifaddrs (struct ifaddrs **ifap)
 
void freeifaddrs (struct ifaddrs *ifa)
 

Macro Definition Documentation

◆ ifa_broadaddr

#define ifa_broadaddr   ifa_dstaddr /* broadcast address interface */

Definition at line 44 of file android-ifaddrs.h.

Function Documentation

◆ freeifaddrs()

void freeifaddrs ( struct ifaddrs ifa)

Definition at line 704 of file android-ifaddrs.c.

705 {
706  struct ifaddrs *l_cur;
707  while(ifa)
708  {
709  l_cur = ifa;
710  ifa = ifa->ifa_next;
711  uv__free(l_cur);
712  }
713 }
struct ifaddrs * ifa_next
void uv__free(void *ptr)
Definition: uv-common.c:81

References ifaddrs::ifa_next, and uv__free().

Referenced by uv_interface_addresses().

◆ getifaddrs()

__BEGIN_DECLS int getifaddrs ( struct ifaddrs **  ifap)

Definition at line 655 of file android-ifaddrs.c.

656 {
657  int l_socket;
658  int l_result;
659  int l_numLinks;
660  pid_t l_pid;
661  NetlinkList *l_linkResults;
662  NetlinkList *l_addrResults;
663 
664  if(!ifap)
665  {
666  return -1;
667  }
668  *ifap = NULL;
669 
670  l_socket = netlink_socket(&l_pid);
671  if(l_socket < 0)
672  {
673  return -1;
674  }
675 
676  l_linkResults = getResultList(l_socket, RTM_GETLINK, l_pid);
677  if(!l_linkResults)
678  {
679  close(l_socket);
680  return -1;
681  }
682 
683  l_addrResults = getResultList(l_socket, RTM_GETADDR, l_pid);
684  if(!l_addrResults)
685  {
686  close(l_socket);
687  freeResultList(l_linkResults);
688  return -1;
689  }
690 
691  l_result = 0;
692  l_numLinks = interpretLinks(l_socket, l_pid, l_linkResults, ifap);
693  if(l_numLinks == -1 || interpretAddrs(l_socket, l_pid, l_addrResults, ifap, l_numLinks) == -1)
694  {
695  l_result = -1;
696  }
697 
698  freeResultList(l_linkResults);
699  freeResultList(l_addrResults);
700  close(l_socket);
701  return l_result;
702 }
static NetlinkList * getResultList(int p_socket, int p_request, pid_t p_pid)
static int netlink_socket(pid_t *p_pid)
static int interpretAddrs(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks)
static void freeResultList(NetlinkList *p_list)
static int interpretLinks(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList)
#define NULL
Definition: cris-opc.c:27
static static fork const void static count close
Definition: sflib.h:33
int pid_t
Definition: sftypes.h:38

References close, freeResultList(), getResultList(), interpretAddrs(), interpretLinks(), netlink_socket(), and NULL.

Referenced by uv_interface_addresses().