Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int nl_addr_valid ( char *  addr,
int  family 
)

Check if an address matches a certain family.

  • addr Address represented as character string.
  • family Desired address family.
Returns:
1 if the address is of the desired address family, otherwise 0 is returned.

Definition at line 568 of file addr.c.

{
      int ret;
      char buf[32];

      switch (family) {
      case AF_INET:
      case AF_INET6:
            ret = inet_pton(family, addr, buf);
            if (ret <= 0)
                  return 0;
            break;

      case AF_DECnet:
            ret = dnet_pton(addr, buf);
            if (ret <= 0)
                  return 0;
            break;

      case AF_LLC:
            if (sscanf(addr, "%*02x:%*02x:%*02x:%*02x:%*02x:%*02x") != 6)
                  return 0;
            break;
      }

      return 1;
}

Generated by  Doxygen 1.6.0   Back to index