summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/route.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-12-13 02:37:33 +0000
committerbrian <brian@FreeBSD.org>1997-12-13 02:37:33 +0000
commitb51dc6a0ad3ce435d5255b72124d2220a345c748 (patch)
tree01ae43c4ae528f7d4f3a9b7aaad7063e4c34bc05 /usr.sbin/ppp/route.c
parent982ed8caa2c928574b4adcc4149fb11f323b0f46 (diff)
downloadFreeBSD-src-b51dc6a0ad3ce435d5255b72124d2220a345c748.zip
FreeBSD-src-b51dc6a0ad3ce435d5255b72124d2220a345c748.tar.gz
Allow random IP number allocation to peer.
Validate the peers suggested IP by attempting to make a routing table entry. Give up IPCP negotiation if the peer NAKs us with an unusable IP. Always SIOCDIFADDR then SIOCAIFADDR when configuring the tun device. Using SIOCSIFDSTADDR allows duplicate dst addresses (which we don't want)!!! Allow up to 200 interface names (was 50) (now that ppp can play server properly). Up the version number (1.5 -> 1.6). Cosmetic: Log unexpected CCP packets in the CCP log rather than the ERROR log. Log unexpected Config Reqs in the appropriate LCP/IPCP/CCP log rather than the ERROR log. Log failed route additions and deletions with WARN, not TCPIP. Log the option id and length for unrecognised IPCP options. Change some .Sq to .Ar in the man page.
Diffstat (limited to 'usr.sbin/ppp/route.c')
-rw-r--r--usr.sbin/ppp/route.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index c1c0b33..3132937 100644
--- a/usr.sbin/ppp/route.c
+++ b/usr.sbin/ppp/route.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: route.c,v 1.29 1997/12/04 18:49:39 brian Exp $
+ * $Id: route.c,v 1.30 1997/12/07 04:09:15 brian Exp $
*
*/
@@ -48,6 +48,9 @@
#include "defs.h"
#include "vars.h"
#include "id.h"
+#include "os.h"
+#include "ipcp.h"
+#include "iplist.h"
#include "route.h"
static int IfIndex;
@@ -142,17 +145,19 @@ OsSetRoute(int cmd,
LogPrintf(LogTCPIP, "OsSetRoute: Mask = %s\n", inet_ntoa(mask));
switch (rtmes.m_rtm.rtm_errno) {
case EEXIST:
- LogPrintf(LogTCPIP, "Add route failed: Already exists\n");
+ LogPrintf(LogWARN, "Add route failed: %s already exists\n",
+ inet_ntoa(dst));
break;
case ESRCH:
- LogPrintf(LogTCPIP, "Del route failed: Non-existent\n");
+ LogPrintf(LogWARN, "Del route failed: %s: Non-existent\n",
+ inet_ntoa(dst));
break;
case 0:
- LogPrintf(LogTCPIP, "%s route failed: %s\n", cmdstr, strerror(errno));
+ LogPrintf(LogWARN, "%s route failed: %s\n", cmdstr, strerror(errno));
break;
case ENOBUFS:
default:
- LogPrintf(LogTCPIP, "%s route failed: %s\n",
+ LogPrintf(LogWARN, "%s route failed: %s\n",
cmdstr, strerror(rtmes.m_rtm.rtm_errno));
break;
}
@@ -283,7 +288,7 @@ p_flags(u_long f, const char *format)
static const char *
Index2Nam(int idx)
{
- static char ifs[50][6];
+ static char ifs[200][6]; /* We could have 256 tun devices ! */
static int nifs, debug_done;
if (!nifs) {
@@ -493,3 +498,28 @@ GetIfIndex(char *name)
idx++;
return -1;
}
+
+struct in_addr
+ChooseHisAddr(const struct in_addr gw)
+{
+ struct in_addr try;
+ int f;
+
+ for (f = 0; f < DefHisChoice.nItems; f++) {
+ try = iplist_next(&DefHisChoice);
+ LogPrintf(LogDEBUG, "ChooseHisAddr: Check item %d (%s)\n",
+ f, inet_ntoa(try));
+ if (OsTrySetIpaddress(gw, try) == 0) {
+ LogPrintf(LogIPCP, "ChooseHisAddr: Selected IP address %s\n",
+ inet_ntoa(try));
+ break;
+ }
+ }
+
+ if (f == DefHisChoice.nItems) {
+ LogPrintf(LogDEBUG, "ChooseHisAddr: All addresses in use !\n");
+ try.s_addr = INADDR_ANY;
+ }
+
+ return try;
+}
OpenPOWER on IntegriCloud