+
+/*
+ * Find the protox for the given "well-known" name.
+ */
+struct protox *
+knownname(name)
+ char *name;
+{
+ struct protox *tp;
+
+ for (tp = protox; tp->pr_name; tp++)
+ if (strcmp(tp->pr_name, name) == 0)
+ return(tp);
+ for (tp = nsprotox; tp->pr_name; tp++)
+ if (strcmp(tp->pr_name, name) == 0)
+ return(tp);
+ return(NULLPROTOX);
+}
+
+/*
+ * Find the protox corresponding to name.
+ */
+struct protox *
+name2protox(name)
+ char *name;
+{
+ struct protox *tp;
+ char **alias; /* alias from p->aliases */
+ struct protoent *p;
+
+ /*
+ * Try to find the name in the list of "well-known" names. If that
+ * fails, check if name is an alias for an Internet protocol.
+ */
+ if (tp = knownname(name))
+ return(tp);
+
+ setprotoent(1); /* make protocol lookup cheaper */
+ while (p = getprotoent()) {
+ /* assert: name not same as p->name */
+ for (alias = p->p_aliases; *alias; alias++)
+ if (strcmp(name, *alias) == 0) {
+ endprotoent();
+ return(knownname(p->p_name));
+ }
+ }
+ endprotoent();
+ return(NULLPROTOX);
+}
+
+usage()
+{
+ fputs("usage: netstat [-Aan] [-f address_family] [system] [core]\n [-himnrs] [-f address_family] [system] [core]\n [-n] [-I interface] interval [system] [core]\n", stderr);
+ exit(1);
+}