MCPcopy Create free account
hub / github.com/F-Stack/f-stack / IpPort

Function IpPort

freebsd/netinet/libalias/alias_proxy.c:171–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171static int
172IpPort(char *s, int proto, int *port)
173{
174 int n;
175
176 n = sscanf(s, "%d", port);
177 if (n != 1)
178#ifndef _KERNEL /* XXX: we accept only numeric ports in kernel */
179 {
180 struct servent *se;
181
182 if (proto == IPPROTO_TCP)
183 se = getservbyname(s, "tcp");
184 else if (proto == IPPROTO_UDP)
185 se = getservbyname(s, "udp");
186 else
187 return (-1);
188
189 if (se == NULL)
190 return (-1);
191
192 *port = (u_int) ntohs(se->s_port);
193 }
194#else
195 return (-1);
196#endif
197 return (0);
198}
199
200void
201RuleAdd(struct libalias *la, struct proxy_entry *entry)

Callers 1

LibAliasProxyRuleFunction · 0.85

Calls 1

sscanfFunction · 0.85

Tested by

no test coverage detected