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

int nl_addr_info ( struct nl_addr *  addr,
struct addrinfo **  result 
)

Call getaddrinfo() for an abstract address object.

  • addr Abstract address object.
  • result Pointer to store resulting address list.
Calls getaddrinfo() for the specified abstract address in AI_NUMERICHOST mode.

Note:
The caller is responsible for freeing the linked list using the interface provided by getaddrinfo(3).
Returns:
0 on success or a negative error code.

Definition at line 684 of file addr.c.

References nl_addr2str().

{
      int err;
      char buf[INET6_ADDRSTRLEN+5];
      struct addrinfo hint = {
            .ai_flags = AI_NUMERICHOST,
            .ai_family = addr->a_family,
      };

      nl_addr2str(addr, buf, sizeof(buf));

      err = getaddrinfo(buf, NULL, &hint, result);
      if (err != 0) {
            switch (err) {
            case EAI_ADDRFAMILY: return -NLE_AF_NOSUPPORT;
            case EAI_AGAIN: return -NLE_AGAIN;
            case EAI_BADFLAGS: return -NLE_INVAL;
            case EAI_FAIL: return -NLE_NOADDR;
            case EAI_FAMILY: return -NLE_AF_NOSUPPORT;
            case EAI_MEMORY: return -NLE_NOMEM;
            case EAI_NODATA: return -NLE_NOADDR;
            case EAI_NONAME: return -NLE_OBJ_NOTFOUND;
            case EAI_SERVICE: return -NLE_OPNOTSUPP;
            case EAI_SOCKTYPE: return -NLE_BAD_SOCK;
            default: return -NLE_FAILURE;
            }
      }

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index