Example #1
0
static void netlink_process_link(struct nlmsghdr *h)
{
  struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(h);
  struct interface *iface;
  struct olsr_if *oif;
  char namebuffer[IF_NAMESIZE];

  iface = if_ifwithindex(ifi->ifi_index);
  oif = NULL;

  if (iface == NULL && (ifi->ifi_flags & IFF_UP) == IFF_UP) {
    if (if_indextoname(ifi->ifi_index, namebuffer)) {
      if ((oif = olsrif_ifwithname(namebuffer)) != NULL) {
        /* try to take interface up, will trigger ifchange */
        chk_if_up(oif, 3);
      }
    }
  }
  else if (iface != NULL && (ifi->ifi_flags & IFF_UP) == 0) {
    /* try to take interface down, will trigger ifchange */
    olsr_remove_interface(iface->olsr_if);
  }

  if (iface == NULL && oif == NULL) {
    /* this is not an OLSR interface */
    if ((ifi->ifi_flags & IFF_UP) != 0) {
      olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_ADD);
    }
    else if ((ifi->ifi_flags & IFF_UP) == 0){
      olsr_trigger_ifchange(ifi->ifi_index, NULL, IFCHG_IF_REMOVE);
    }
  }
}
Example #2
0
/**
 *Get an interface name for a given interface index
 *
 *@param iif_index of the interface to find.
 *
 *@return "" or interface name.
 */
const char *
if_ifwithindex_name(const int if_index)
{
  const struct interface * const ifp = if_ifwithindex(if_index);
  return ifp == NULL ? "void" : ifp->int_name;
}