! \brief converts an ip_addr structure to a hostent * \return pointer to internal statical structure */
| 725 | /*! \brief converts an ip_addr structure to a hostent |
| 726 | * \return pointer to internal statical structure */ |
| 727 | static inline struct hostent* ip_addr2he(str* name, struct ip_addr* ip) |
| 728 | { |
| 729 | static struct hostent he; |
| 730 | static char hostname[256]; |
| 731 | static char* p_aliases[1]; |
| 732 | static char* p_addr[2]; |
| 733 | static char address[16]; |
| 734 | int len; |
| 735 | |
| 736 | p_aliases[0]=0; /* no aliases*/ |
| 737 | p_addr[1]=0; /* only one address*/ |
| 738 | p_addr[0]=address; |
| 739 | len = (name->len < 255) ? name->len : 255; |
| 740 | strncpy(hostname, name->s, len); |
| 741 | hostname[len] = 0; |
| 742 | if (ip->len>16) return 0; |
| 743 | memcpy(address, ip->u.addr, ip->len); |
| 744 | |
| 745 | he.h_addrtype=ip->af; |
| 746 | he.h_length=ip->len; |
| 747 | he.h_addr_list=p_addr; |
| 748 | he.h_aliases=p_aliases; |
| 749 | he.h_name=hostname; |
| 750 | return &he; |
| 751 | } |
| 752 | #endif |
no outgoing calls
no test coverage detected