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

int nl_addr_fill_sockaddr ( struct nl_addr *  addr,
struct sockaddr *  sa,
socklen_t *  salen 

Fill out sockaddr structure with values from abstract address object.

  • addr Abstract address object.
  • sa Destination sockaddr structure buffer.
  • salen Length of sockaddr structure buffer.
Fills out the specified sockaddr structure with the data found in the specified abstract address. The salen argument needs to be set to the size of sa but will be modified to the actual size used during before the function exits.

0 on success or a negative error code

Definition at line 628 of file addr.c.

Referenced by nl_addr_resolve().

      switch (addr->a_family) {
      case AF_INET: {
            struct sockaddr_in *sai = (struct sockaddr_in *) sa;

            if (*salen < sizeof(*sai))
                  return -NLE_INVAL;

            sai->sin_family = addr->a_family;
            memcpy(&sai->sin_addr, addr->a_addr, 4);
            *salen = sizeof(*sai);

      case AF_INET6: {
            struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) sa;

            if (*salen < sizeof(*sa6))
                  return -NLE_INVAL;

            sa6->sin6_family = addr->a_family;
            memcpy(&sa6->sin6_addr, addr->a_addr, 16);
            *salen = sizeof(*sa6);

            return -NLE_INVAL;

      return 0;

Generated by  Doxygen 1.6.0   Back to index