* Find the protox corresponding to name. */
| 959 | * Find the protox corresponding to name. |
| 960 | */ |
| 961 | static struct protox * |
| 962 | name2protox(const char *name) |
| 963 | { |
| 964 | struct protox *tp; |
| 965 | char **alias; /* alias from p->aliases */ |
| 966 | struct protoent *p; |
| 967 | |
| 968 | /* |
| 969 | * Try to find the name in the list of "well-known" names. If that |
| 970 | * fails, check if name is an alias for an Internet protocol. |
| 971 | */ |
| 972 | if ((tp = knownname(name)) != NULL) |
| 973 | return (tp); |
| 974 | |
| 975 | setprotoent(1); /* make protocol lookup cheaper */ |
| 976 | while ((p = getprotoent()) != NULL) { |
| 977 | /* assert: name not same as p->name */ |
| 978 | for (alias = p->p_aliases; *alias; alias++) |
| 979 | if (strcmp(name, *alias) == 0) { |
| 980 | endprotoent(); |
| 981 | return (knownname(p->p_name)); |
| 982 | } |
| 983 | } |
| 984 | endprotoent(); |
| 985 | return (NULL); |
| 986 | } |
| 987 | |
| 988 | static void |
| 989 | usage(void) |