MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / getaddrinfo

Function getaddrinfo

lib/getaddrinfo.c:61–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 */
60#ifndef HAVE_GETADDRINFO
61int getaddrinfo(const char *node, const char *service,
62 const struct addrinfo *hints, struct addrinfo **res)
63{
64 struct addrinfo *p;
65 int ai_family, ai_socktype, ai_protocol, ai_flags;
66
67 /* limitation: service must be non null */
68 if (!service)
69 {
70 return -1;
71 }
72
73 if (hints == NULL)
74 {
75 ai_family = AF_UNSPEC;
76 ai_socktype = 0;
77 ai_protocol = 0;
78 ai_flags = 0;
79 }
80 else
81 {
82 ai_family = hints->ai_family;
83 ai_socktype = hints->ai_socktype;
84 ai_protocol = hints->ai_protocol;
85 ai_flags = hints->ai_flags;
86 }
87
88 /* limitation: this replacement function only for IPv4 */
89 if (ai_family == AF_UNSPEC)
90 {
91 ai_family = AF_INET;
92 }
93
94 if (ai_family != AF_INET)
95 {
96 return -1;
97 }
98
99 p = calloc(1, sizeof(struct addrinfo));
100
101 if (!p)
102 {
103 return -1;
104 }
105
106 memset(p, 0, sizeof(struct addrinfo));
107 p->ai_family = ai_family;
108 p->ai_socktype = ai_socktype;
109 p->ai_protocol = ai_protocol;
110 p->ai_addrlen = sizeof(struct sockaddr_in);
111 p->ai_addr = calloc(1, p->ai_addrlen);
112
113 if (!p->ai_addr)
114 {
115 free(p);
116 return -1;
117 }
118

Callers 6

network_openFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
rig_network_addrFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

rig_network_addrFunction · 0.68