- if (getsockname(udpsock[i].fd, &a.sa, &sz))
- die(EXIT_FAILURE, "couldn't read port number: %s", strerror(errno));
- return (getport(&a));
+/* --- @p_dflttun@ --- *
+ *
+ * Arguments: ---
+ *
+ * Returns: A pointer to the current default tunnel operations, or null
+ * if no tunnels are defined.
+ */
+
+const tunnel_ops *p_dflttun(void) { return (dflttun); }
+
+/* --- @p_findtun@ --- *
+ *
+ * Arguments: @const char *name@ = tunnel name
+ *
+ * Returns: Pointer to the tunnel operations, or null.
+ *
+ * Use: Finds the operations for a named tunnel class.
+ */
+
+const tunnel_ops *p_findtun(const char *name)
+{
+ const struct tunnel_node *tn;
+
+ for (tn = tunnels; tn; tn = tn->next)
+ if (mystrieq(tn->tops->name, name) == 0) return (tn->tops);
+ return (0);
+}
+
+/* --- @p_mktuniter@ --- *
+ *
+ * Arguments: @tuniter *i@ = pointer to iterator to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a tunnel iterator.
+ */
+
+void p_mktuniter(tun_iter *i) { i->next = tunnels; }
+
+/* --- @p_nexttun@ --- *
+ *
+ * Arguments: @tuniter *i@ = pointer to iterator
+ *
+ * Returns: Pointer to the next tunnel's operations, or null.
+ */
+
+const tunnel_ops *p_nexttun(tun_iter *i)
+{
+ const struct tunnel_node *tn = i->next;
+
+ if (!tn) return (0);
+ else { i->next = tn->next; return (tn->tops); }