| 169 | } |
| 170 | |
| 171 | static int |
| 172 | IpPort(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 | |
| 200 | void |
| 201 | RuleAdd(struct libalias *la, struct proxy_entry *entry) |
no test coverage detected