summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/iface.h
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1998-10-22 02:32:50 +0000
committerbrian <brian@FreeBSD.org>1998-10-22 02:32:50 +0000
commit7056e6ac4753567be17baa0d7f36a6a96248c938 (patch)
treeed29a04b61431af78f3f8071d0b9c17ed8fe4471 /usr.sbin/ppp/iface.h
parentb8a68d9fd9fa6c7e3cbfc74355e2d40ea475df06 (diff)
downloadFreeBSD-src-7056e6ac4753567be17baa0d7f36a6a96248c938.zip
FreeBSD-src-7056e6ac4753567be17baa0d7f36a6a96248c938.tar.gz
Solve the ``first connection'' problem that occurs on
demand-dial links with dynamic IP numbers where the program that causes the dial bind()s to an interface address that is subsequently changed after ppp negotiation. The problem is defeated by adding negotiated addresses to the tun interface as additional alias addresses and providing a set of ``iface'' commands for managing the interface. Libalias is also required (and what a name clash!) - it happily IP-aliases the address so that the source is that of the primary (negotiated) interface and un-IP-aliases it on the way back. An ``enable iface-alias'' is done implicitly by the -alias command line switch. If -alias isn't given, iface-aliasing is disabled by default and can't be enabled 'till an ``alias enable yes'' is done. ``alias enable no'' silently disables iface-alias. So, for dynamic-IP-type-connections, running ``ppp -alias -auto blah'' will work for the first connection, although existing bindings will not survive a disconnect/connect as the TCP peer will be trying to send to the old IP address - the packets won't route. It's now a lot easier to add IPXCP to ppp with minor updates to the new iface.[ch] (if anyone ever gets 'round to it). It's also now possible to manually add interface aliases with something like ``iface add 1.2.3.4/24 5.6.7.8''. This allows multi-homed ppp links :-)
Diffstat (limited to 'usr.sbin/ppp/iface.h')
-rw-r--r--usr.sbin/ppp/iface.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/usr.sbin/ppp/iface.h b/usr.sbin/ppp/iface.h
new file mode 100644
index 0000000..f3b1dad
--- /dev/null
+++ b/usr.sbin/ppp/iface.h
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id:$
+ */
+
+struct iface_addr {
+ struct in_addr ifa; /* local address */
+ struct in_addr mask; /* netmask */
+ int bits; /* netmask bits - -1 if not contiguous */
+ struct in_addr brd; /* peer address */
+};
+
+struct iface {
+ char *name; /* Interface name (malloc'd) */
+ int index; /* Interface index */
+ int flags; /* Interface flags (IFF_*) */
+
+ int in_addrs; /* How many in_addr's */
+ struct iface_addr *in_addr; /* Array of addresses (malloc'd) */
+};
+
+#define IFACE_CLEAR_ALL 0 /* Nuke 'em all */
+#define IFACE_CLEAR_ALIASES 1 /* Leave the IPCP address */
+
+#define IFACE_ADD_LAST 0 /* Just another alias */
+#define IFACE_ADD_FIRST 1 /* The IPCP address */
+#define IFACE_FORCE_ADD 2 /* OR'd with IFACE_ADD_{FIRST,LAST} */
+
+#define iface_Clear iface_inClear /* Same for now */
+
+extern struct iface *iface_Create(const char *name);
+extern void iface_inClear(struct iface *, int);
+extern int iface_inAdd(struct iface *, struct in_addr, struct in_addr,
+ struct in_addr, int);
+extern int iface_inDelete(struct iface *, struct in_addr);
+extern int iface_Show(struct cmdargs const *);
+extern void iface_Destroy(struct iface *);
OpenPOWER on IntegriCloud