Create #defines for all endpoint discriptor classes,
and allow `set enddisc mac'.
This commit is contained in:
parent
673903ec42
commit
086760227f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35412
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.c,v 1.27.2.11 1998/04/06 09:12:22 brian Exp $
|
||||
* $Id: arp.c,v 1.27.2.12 1998/04/07 00:53:14 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -64,8 +64,6 @@
|
||||
#include "bundle.h"
|
||||
#include "arp.h"
|
||||
|
||||
static int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
|
||||
|
||||
/*
|
||||
* SET_SA_FAMILY - set the sa_family field of a struct sockaddr,
|
||||
* if it exists.
|
||||
@ -226,7 +224,7 @@ cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
* the same subnet as ipaddr.
|
||||
*/
|
||||
|
||||
static int
|
||||
int
|
||||
get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
|
||||
{
|
||||
int mib[6], sa_len, skip, b;
|
||||
@ -315,8 +313,8 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
|
||||
if (ifa->sin_family == AF_INET &&
|
||||
(ifa->sin_addr.s_addr & mask->sin_addr.s_addr) ==
|
||||
(ipaddr.s_addr & mask->sin_addr.s_addr)) {
|
||||
LogPrintf(LogPHASE, "Found interface %.*s for proxy arp\n",
|
||||
dl->sdl_alen, dl->sdl_data);
|
||||
LogPrintf(LogPHASE, "Found interface %.*s for %s\n",
|
||||
dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
|
||||
memcpy(hwaddr, dl, dl->sdl_len);
|
||||
free(buf);
|
||||
return 1;
|
||||
|
@ -17,11 +17,13 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.h,v 1.7.2.4 1998/02/21 01:44:56 brian Exp $
|
||||
* $Id: arp.h,v 1.7.2.5 1998/04/07 00:53:16 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
struct sockaddr_dl;
|
||||
struct bundle;
|
||||
|
||||
extern int cifproxyarp(struct bundle *, struct in_addr, int);
|
||||
extern int sifproxyarp(struct bundle *, struct in_addr, int);
|
||||
extern int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.c,v 1.1.2.9 1998/04/23 18:58:04 brian Exp $
|
||||
* $Id: mp.c,v 1.1.2.10 1998/04/23 21:50:11 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -31,11 +31,15 @@
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "command.h"
|
||||
#include "mbuf.h"
|
||||
@ -65,6 +69,8 @@
|
||||
#include "bundle.h"
|
||||
#include "ip.h"
|
||||
#include "prompt.h"
|
||||
#include "id.h"
|
||||
#include "arp.h"
|
||||
|
||||
static u_int32_t
|
||||
inc_seq(struct mp *mp, u_int32_t seq)
|
||||
@ -580,15 +586,15 @@ mp_Enddisc(u_char c, const char *address, int len)
|
||||
int f, header;
|
||||
|
||||
switch (c) {
|
||||
case 0:
|
||||
case ENDDISC_NULL:
|
||||
sprintf(result, "Null Class");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case ENDDISC_LOCAL:
|
||||
snprintf(result, sizeof result, "Local Addr: %.*s", len, address);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case ENDDISC_IP:
|
||||
if (len == 4)
|
||||
snprintf(result, sizeof result, "IP %s",
|
||||
inet_ntoa(*(const struct in_addr *)address));
|
||||
@ -596,7 +602,7 @@ mp_Enddisc(u_char c, const char *address, int len)
|
||||
sprintf(result, "IP[%d] ???", len);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case ENDDISC_MAC:
|
||||
if (len == 6) {
|
||||
const u_char *m = (const u_char *)address;
|
||||
snprintf(result, sizeof result, "MAC %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
@ -605,7 +611,7 @@ mp_Enddisc(u_char c, const char *address, int len)
|
||||
sprintf(result, "MAC[%d] ???", len);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case ENDDISC_MAGIC:
|
||||
sprintf(result, "Magic: 0x");
|
||||
header = strlen(result);
|
||||
if (len > sizeof result - header - 1)
|
||||
@ -614,7 +620,7 @@ mp_Enddisc(u_char c, const char *address, int len)
|
||||
sprintf(result + header + 2 * f, "%02x", address[f]);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case ENDDISC_PSN:
|
||||
snprintf(result, sizeof result, "PSN: %.*s", len, address);
|
||||
break;
|
||||
|
||||
@ -645,37 +651,59 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
*mp->cfg.enddisc.address = '\0';
|
||||
mp->cfg.enddisc.len = 0;
|
||||
} else if (arg->argc > arg->argn)
|
||||
if (!strcasecmp(arg->argv[arg->argn], "ip")) {
|
||||
if (!strcasecmp(arg->argv[arg->argn], "label")) {
|
||||
mp->cfg.enddisc.class = ENDDISC_LOCAL;
|
||||
strcpy(mp->cfg.enddisc.address, arg->bundle->cfg.label);
|
||||
mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address);
|
||||
} else if (!strcasecmp(arg->argv[arg->argn], "ip")) {
|
||||
memcpy(mp->cfg.enddisc.address,
|
||||
&arg->bundle->ncp.ipcp.my_ip.s_addr,
|
||||
&arg->bundle->ncp.ipcp.cfg.my_range.ipaddr.s_addr,
|
||||
sizeof arg->bundle->ncp.ipcp.my_ip.s_addr);
|
||||
mp->cfg.enddisc.class = 2;
|
||||
mp->cfg.enddisc.class = ENDDISC_IP;
|
||||
mp->cfg.enddisc.len = sizeof arg->bundle->ncp.ipcp.my_ip.s_addr;
|
||||
} else if (!strcasecmp(arg->argv[arg->argn], "mac")) {
|
||||
struct sockaddr_dl hwaddr;
|
||||
int s;
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "set enddisc: socket(): %s\n", strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
if (get_ether_addr(s, arg->bundle->ncp.ipcp.cfg.my_range.ipaddr,
|
||||
&hwaddr)) {
|
||||
mp->cfg.enddisc.class = ENDDISC_MAC;
|
||||
memcpy(mp->cfg.enddisc.address, hwaddr.sdl_data + hwaddr.sdl_nlen,
|
||||
hwaddr.sdl_alen);
|
||||
mp->cfg.enddisc.len = hwaddr.sdl_alen;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "set enddisc: Can't locate MAC address for %s\n",
|
||||
inet_ntoa(arg->bundle->ncp.ipcp.cfg.my_range.ipaddr));
|
||||
close(s);
|
||||
return 4;
|
||||
}
|
||||
close(s);
|
||||
} else if (!strcasecmp(arg->argv[arg->argn], "magic")) {
|
||||
int f;
|
||||
|
||||
randinit();
|
||||
for (f = 0; f < 20; f += sizeof(long))
|
||||
*(long *)(mp->cfg.enddisc.address + f) = random();
|
||||
mp->cfg.enddisc.class = 4;
|
||||
mp->cfg.enddisc.class = ENDDISC_MAGIC;
|
||||
mp->cfg.enddisc.len = 20;
|
||||
} else if (!strcasecmp(arg->argv[arg->argn], "label")) {
|
||||
mp->cfg.enddisc.class = 1;
|
||||
strcpy(mp->cfg.enddisc.address, arg->bundle->cfg.label);
|
||||
mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address);
|
||||
} else if (!strcasecmp(arg->argv[arg->argn], "psn")) {
|
||||
if (arg->argc > arg->argn+1) {
|
||||
mp->cfg.enddisc.class = 5;
|
||||
mp->cfg.enddisc.class = ENDDISC_PSN;
|
||||
strcpy(mp->cfg.enddisc.address, arg->argv[arg->argn+1]);
|
||||
mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address);
|
||||
} else {
|
||||
LogPrintf(LogWARN, "PSN endpoint requires additional data\n");
|
||||
return 2;
|
||||
return 5;
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: Unrecognised endpoint type\n",
|
||||
arg->argv[arg->argn]);
|
||||
return 3;
|
||||
return 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.h,v 1.1.2.3 1998/04/23 03:23:00 brian Exp $
|
||||
* $Id: mp.h,v 1.1.2.4 1998/04/23 21:50:13 brian Exp $
|
||||
*/
|
||||
|
||||
struct mbuf;
|
||||
@ -31,6 +31,13 @@ struct physical;
|
||||
struct bundle;
|
||||
struct cmdargs;
|
||||
|
||||
#define ENDDISC_NULL 0
|
||||
#define ENDDISC_LOCAL 1
|
||||
#define ENDDISC_IP 2
|
||||
#define ENDDISC_MAC 3
|
||||
#define ENDDISC_MAGIC 4
|
||||
#define ENDDISC_PSN 5
|
||||
|
||||
struct mp {
|
||||
struct link link;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.97.2.20 1998/04/23 03:23:03 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.97.2.21 1998/04/23 18:56:00 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.Os FreeBSD
|
||||
.Dt PPP 8
|
||||
@ -2435,22 +2435,34 @@ This, of course means that it is possible to execute an entirely external
|
||||
command rather than using the internal one. See
|
||||
.Xr chat 8
|
||||
for a good alternative.
|
||||
.It set enddisc Op IP|magic|label|psn value
|
||||
.It set enddisc Op label|IP|MAC|magic|psn value
|
||||
This command sets our local endpoint discriminator. If set prior to
|
||||
LCP negotiation,
|
||||
.Nm
|
||||
will send the information to the peer using the LCP endpoint discriminator
|
||||
option. The following discriminators may be set:
|
||||
.Bd -literal -offset indent
|
||||
.It label
|
||||
The current label is used.
|
||||
.It IP
|
||||
Our local IP number is used. As LCP is negotiated prior to IPCP, it is
|
||||
possible that the IPCP layer will subsequently change this value. If
|
||||
it does, the endpoint descriminator stays at the old value unless manually
|
||||
reset.
|
||||
.It MAC
|
||||
This is similar to the
|
||||
.Ar IP
|
||||
option above, except that the MAC address associated with the local IP
|
||||
number is used. If the local IP number is not resident on any ethernet
|
||||
interface, the command will fail.
|
||||
.Pp
|
||||
As the local IP number defaults to whatever the machine host name is,
|
||||
.Dq set enddisc mac
|
||||
is usually done prior to any
|
||||
.Dq set ifaddr
|
||||
commands.
|
||||
.It magic
|
||||
A 20 digit random number is used.
|
||||
.It label
|
||||
The current label is used.
|
||||
.It psn Ar value
|
||||
The given
|
||||
.Ar value
|
||||
|
Loading…
Reference in New Issue
Block a user