mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-11 14:10:34 +00:00
Don't dlopen()/dlsym() libalias, use it in the same way
as the rest of the world uses libraries.
This commit is contained in:
parent
3f06c5995f
commit
615ad4f957
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37191
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.42 1998/06/24 19:33:30 brian Exp $
|
||||
# $Id: Makefile,v 1.43 1998/06/26 18:50:29 brian Exp $
|
||||
|
||||
PROG= ppp
|
||||
SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c \
|
||||
@ -26,10 +26,14 @@ DPADD+= ${LIBMD} ${LIBCRYPT}
|
||||
CFLAGS+=-DRELEASE_CRUNCH
|
||||
.endif
|
||||
|
||||
.if defined(NOALIAS) || defined(RELEASE_CRUNCH)
|
||||
.if defined(NOALIAS)
|
||||
CFLAGS+=-DNOALIAS
|
||||
.else
|
||||
SRCS+= alias_cmd.c loadalias.c
|
||||
.if !defined(RELEASE_CRUNCH)
|
||||
SRCS+= alias_cmd.c
|
||||
LDADD+= -lalias
|
||||
DPADD+= ${LIBALIAS}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if exists(${.CURDIR}/../../secure) && !defined(NOCRYPT) && !defined(NOSECURE) && !defined(RELEASE_CRUNCH)
|
||||
@ -43,8 +47,9 @@ DPADD+= ${LIBDES}
|
||||
.if defined(RELEASE_CRUNCH)
|
||||
# We must create these objects because the crunchgen will link them,
|
||||
# and we don't want any unused symbols to spoil the final link.
|
||||
SRCS+= alias_cmd.c loadalias.c chap_ms.c
|
||||
chap_ms.o alias_cmd.o loadalias.o:
|
||||
CFLAGS+=-DNOALIAS
|
||||
SRCS+= alias_cmd.c chap_ms.c
|
||||
chap_ms.o alias_cmd.o:
|
||||
>null_${.PREFIX}.c
|
||||
cc -c -o ${.TARGET} null_${.PREFIX}.c
|
||||
.endif
|
||||
|
@ -2,14 +2,20 @@
|
||||
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
|
||||
* who places it in the public domain without restriction.
|
||||
*
|
||||
* $Id: alias_cmd.c,v 1.13 1998/05/21 21:43:42 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.14 1998/06/15 19:05:59 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <alias.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -18,10 +24,24 @@
|
||||
#include "defs.h"
|
||||
#include "command.h"
|
||||
#include "log.h"
|
||||
#include "loadalias.h"
|
||||
#include "alias_cmd.h"
|
||||
#include "descriptor.h"
|
||||
#include "prompt.h"
|
||||
#include "timer.h"
|
||||
#include "fsm.h"
|
||||
#include "slcompress.h"
|
||||
#include "throughput.h"
|
||||
#include "iplist.h"
|
||||
#include "ipcp.h"
|
||||
#include "lqr.h"
|
||||
#include "hdlc.h"
|
||||
#include "mbuf.h"
|
||||
#include "lcp.h"
|
||||
#include "ccp.h"
|
||||
#include "link.h"
|
||||
#include "mp.h"
|
||||
#include "filter.h"
|
||||
#include "bundle.h"
|
||||
|
||||
|
||||
static int StrToAddr(const char *, struct in_addr *);
|
||||
@ -32,7 +52,7 @@ static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const cha
|
||||
int
|
||||
alias_RedirectPort(struct cmdargs const *arg)
|
||||
{
|
||||
if (!alias_IsEnabled()) {
|
||||
if (!arg->bundle->AliasEnabled) {
|
||||
prompt_Printf(arg->prompt, "Alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+3) {
|
||||
@ -76,10 +96,10 @@ alias_RedirectPort(struct cmdargs const *arg)
|
||||
}
|
||||
null_addr.s_addr = INADDR_ANY;
|
||||
|
||||
link = (*PacketAlias.RedirectPort)(local_addr, local_port,
|
||||
null_addr, 0,
|
||||
null_addr, alias_port,
|
||||
proto_constant);
|
||||
link = PacketAliasRedirectPort(local_addr, local_port,
|
||||
null_addr, 0,
|
||||
null_addr, alias_port,
|
||||
proto_constant);
|
||||
|
||||
if (link == NULL)
|
||||
prompt_Printf(arg->prompt, "port redirect: error returned by packed"
|
||||
@ -94,7 +114,7 @@ alias_RedirectPort(struct cmdargs const *arg)
|
||||
int
|
||||
alias_RedirectAddr(struct cmdargs const *arg)
|
||||
{
|
||||
if (!alias_IsEnabled()) {
|
||||
if (!arg->bundle->AliasEnabled) {
|
||||
prompt_Printf(arg->prompt, "alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+2) {
|
||||
@ -115,7 +135,7 @@ alias_RedirectAddr(struct cmdargs const *arg)
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
link = (*PacketAlias.RedirectAddr)(local_addr, alias_addr);
|
||||
link = PacketAliasRedirectAddr(local_addr, alias_addr);
|
||||
if (link == NULL) {
|
||||
prompt_Printf(arg->prompt, "address redirect: packet aliasing"
|
||||
" engine error\n");
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.c,v 1.24 1998/06/27 12:03:35 brian Exp $
|
||||
* $Id: bundle.c,v 1.25 1998/06/27 12:03:46 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -37,6 +37,9 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifndef NOALIAS
|
||||
#include <alias.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
@ -627,8 +630,8 @@ bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
struct mbuf *bp;
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.In)(tun.data, sizeof tun.data);
|
||||
if (bundle->AliasEnabled) {
|
||||
PacketAliasIn(tun.data, sizeof tun.data);
|
||||
n = ntohs(((struct ip *)tun.data)->ip_len);
|
||||
}
|
||||
#endif
|
||||
@ -668,8 +671,8 @@ bundle_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
pri = PacketCheck(bundle, tun.data, n, &bundle->filter.out);
|
||||
if (pri >= 0) {
|
||||
#ifndef NOALIAS
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.Out)(tun.data, sizeof tun.data);
|
||||
if (bundle->AliasEnabled) {
|
||||
PacketAliasOut(tun.data, sizeof tun.data);
|
||||
n = ntohs(((struct ip *)tun.data)->ip_len);
|
||||
}
|
||||
#endif
|
||||
@ -815,6 +818,7 @@ bundle_Create(const char *prefix, int type, const char **argv)
|
||||
bundle.routing_seq = 0;
|
||||
bundle.phase = PHASE_DEAD;
|
||||
bundle.CleaningUp = 0;
|
||||
bundle.AliasEnabled = 0;
|
||||
|
||||
bundle.fsm.LayerStart = bundle_LayerStart;
|
||||
bundle.fsm.LayerUp = bundle_LayerUp;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.h,v 1.7 1998/06/12 17:45:04 brian Exp $
|
||||
* $Id: bundle.h,v 1.8 1998/06/16 19:40:25 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHASE_DEAD 0 /* Link is dead */
|
||||
@ -77,6 +77,7 @@ struct bundle {
|
||||
} phys_type;
|
||||
|
||||
unsigned CleaningUp : 1; /* Going to exit.... */
|
||||
unsigned AliasEnabled : 1; /* Are we using libalias ? */
|
||||
|
||||
struct fsm_parent fsm; /* Our callback functions */
|
||||
struct datalink *links; /* Our data links */
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.c,v 1.148 1998/06/20 00:19:33 brian Exp $
|
||||
* $Id: command.c,v 1.149 1998/06/25 22:33:15 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -124,7 +124,7 @@
|
||||
#define NEG_DNS 50
|
||||
|
||||
const char Version[] = "2.0-beta";
|
||||
const char VersionDate[] = "$Date: 1998/06/20 00:19:33 $";
|
||||
const char VersionDate[] = "$Date: 1998/06/25 22:33:15 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
@ -1695,12 +1695,10 @@ AliasEnable(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
||||
if (alias_Load() == 0)
|
||||
return 0;
|
||||
log_Printf(LogWARN, "Cannot load alias library\n");
|
||||
return 1;
|
||||
arg->bundle->AliasEnabled = 1;
|
||||
return 0;
|
||||
} else if (strcasecmp(arg->argv[arg->argn], "no") == 0) {
|
||||
alias_Unload();
|
||||
arg->bundle->AliasEnabled = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1715,14 +1713,14 @@ AliasOption(struct cmdargs const *arg)
|
||||
unsigned param = (unsigned)arg->cmd->args;
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.SetMode)(param, param);
|
||||
if (arg->bundle->AliasEnabled) {
|
||||
PacketAliasSetMode(param, param);
|
||||
return 0;
|
||||
}
|
||||
log_Printf(LogWARN, "alias not enabled\n");
|
||||
} else if (strcmp(arg->argv[arg->argn], "no") == 0) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.SetMode)(0, param);
|
||||
if (arg->bundle->AliasEnabled) {
|
||||
PacketAliasSetMode(0, param);
|
||||
return 0;
|
||||
}
|
||||
log_Printf(LogWARN, "alias not enabled\n");
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ip.c,v 1.44 1998/06/16 19:40:37 brian Exp $
|
||||
* $Id: ip.c,v 1.45 1998/06/27 12:03:36 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Return ICMP message for filterd packet
|
||||
@ -398,13 +398,13 @@ ip_Input(struct bundle *bundle, struct mbuf * bp)
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (alias_IsEnabled() && pip->ip_p != IPPROTO_IGMP &&
|
||||
if (bundle->AliasEnabled && pip->ip_p != IPPROTO_IGMP &&
|
||||
(pip->ip_p != IPPROTO_IPIP || !IN_CLASSD(ntohl(piip->ip_dst.s_addr)))) {
|
||||
struct tun_data *frag;
|
||||
int iresult;
|
||||
char *fptr;
|
||||
|
||||
iresult = (*PacketAlias.In)(tun.data, sizeof tun.data);
|
||||
iresult = PacketAliasIn(tun.data, sizeof tun.data);
|
||||
nb = ntohs(((struct ip *) tun.data)->ip_len);
|
||||
|
||||
if (nb > MAX_MRU) {
|
||||
@ -436,8 +436,8 @@ ip_Input(struct bundle *bundle, struct mbuf * bp)
|
||||
}
|
||||
|
||||
if (iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
|
||||
while ((fptr = (*PacketAlias.GetFragment)(tun.data)) != NULL) {
|
||||
(*PacketAlias.FragmentIn)(tun.data, fptr);
|
||||
while ((fptr = PacketAliasGetFragment(tun.data)) != NULL) {
|
||||
PacketAliasFragmentIn(tun.data, fptr);
|
||||
nb = ntohs(((struct ip *) fptr)->ip_len);
|
||||
frag = (struct tun_data *)
|
||||
((char *)fptr - sizeof tun + sizeof tun.data);
|
||||
@ -462,7 +462,7 @@ ip_Input(struct bundle *bundle, struct mbuf * bp)
|
||||
else {
|
||||
tun_fill_header(*frag, AF_INET);
|
||||
memcpy(frag->data, tun.data, nb - sizeof tun + sizeof tun.data);
|
||||
(*PacketAlias.SaveFragment)(frag->data);
|
||||
PacketAliasSaveFragment(frag->data);
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.57 1998/06/16 19:40:38 brian Exp $
|
||||
* $Id: ipcp.c,v 1.58 1998/06/25 22:33:25 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backward compatibility
|
||||
@ -33,6 +33,9 @@
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifndef NOALIAS
|
||||
#include <alias.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <resolv.h>
|
||||
#include <stdlib.h>
|
||||
@ -706,8 +709,8 @@ ipcp_InterfaceUp(struct ipcp *ipcp)
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (alias_IsEnabled())
|
||||
(*PacketAlias.SetAddress)(ipcp->my_ip);
|
||||
if (ipcp->fsm.bundle->AliasEnabled)
|
||||
PacketAliasSetAddress(ipcp->my_ip);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.136 1998/06/24 19:33:32 brian Exp $
|
||||
* $Id: main.c,v 1.137 1998/06/27 12:03:37 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -180,23 +180,25 @@ Usage(void)
|
||||
}
|
||||
|
||||
static char *
|
||||
ProcessArgs(int argc, char **argv, int *mode)
|
||||
ProcessArgs(int argc, char **argv, int *mode, int *alias)
|
||||
{
|
||||
int optc, labelrequired, newmode;
|
||||
char *cp;
|
||||
|
||||
optc = labelrequired = 0;
|
||||
*mode = PHYS_INTERACTIVE;
|
||||
*alias = 0;
|
||||
while (argc > 0 && **argv == '-') {
|
||||
cp = *argv + 1;
|
||||
newmode = Nam2mode(cp);
|
||||
switch (newmode) {
|
||||
case PHYS_NONE:
|
||||
if (strcmp(cp, "alias") == 0) {
|
||||
#ifndef NOALIAS
|
||||
if (alias_Load() != 0)
|
||||
#ifdef NOALIAS
|
||||
log_Printf(LogWARN, "Cannot load alias library\n");
|
||||
#else
|
||||
*alias = 1;
|
||||
#endif
|
||||
log_Printf(LogWARN, "Cannot load alias library\n");
|
||||
optc--; /* this option isn't exclusive */
|
||||
} else
|
||||
Usage();
|
||||
@ -243,7 +245,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *name, *label;
|
||||
int nfds, mode;
|
||||
int nfds, mode, alias;
|
||||
struct bundle *bundle;
|
||||
struct prompt *prompt;
|
||||
|
||||
@ -260,7 +262,7 @@ main(int argc, char **argv)
|
||||
name = strrchr(argv[0], '/');
|
||||
log_Open(name ? name + 1 : argv[0]);
|
||||
|
||||
label = ProcessArgs(argc - 1, argv + 1, &mode);
|
||||
label = ProcessArgs(argc - 1, argv + 1, &mode, &alias);
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/*
|
||||
@ -324,6 +326,7 @@ main(int argc, char **argv)
|
||||
prompt_Printf(prompt, "Using interface: %s\n", bundle->ifp.Name);
|
||||
}
|
||||
SignalBundle = bundle;
|
||||
bundle->AliasEnabled = alias;
|
||||
|
||||
if (system_Select(bundle, "default", CONFFILE, prompt, NULL) < 0)
|
||||
prompt_Printf(prompt, "Warning: No default entry found in config file.\n");
|
||||
|
@ -2,14 +2,20 @@
|
||||
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
|
||||
* who places it in the public domain without restriction.
|
||||
*
|
||||
* $Id: alias_cmd.c,v 1.13 1998/05/21 21:43:42 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.14 1998/06/15 19:05:59 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <alias.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -18,10 +24,24 @@
|
||||
#include "defs.h"
|
||||
#include "command.h"
|
||||
#include "log.h"
|
||||
#include "loadalias.h"
|
||||
#include "alias_cmd.h"
|
||||
#include "descriptor.h"
|
||||
#include "prompt.h"
|
||||
#include "timer.h"
|
||||
#include "fsm.h"
|
||||
#include "slcompress.h"
|
||||
#include "throughput.h"
|
||||
#include "iplist.h"
|
||||
#include "ipcp.h"
|
||||
#include "lqr.h"
|
||||
#include "hdlc.h"
|
||||
#include "mbuf.h"
|
||||
#include "lcp.h"
|
||||
#include "ccp.h"
|
||||
#include "link.h"
|
||||
#include "mp.h"
|
||||
#include "filter.h"
|
||||
#include "bundle.h"
|
||||
|
||||
|
||||
static int StrToAddr(const char *, struct in_addr *);
|
||||
@ -32,7 +52,7 @@ static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const cha
|
||||
int
|
||||
alias_RedirectPort(struct cmdargs const *arg)
|
||||
{
|
||||
if (!alias_IsEnabled()) {
|
||||
if (!arg->bundle->AliasEnabled) {
|
||||
prompt_Printf(arg->prompt, "Alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+3) {
|
||||
@ -76,10 +96,10 @@ alias_RedirectPort(struct cmdargs const *arg)
|
||||
}
|
||||
null_addr.s_addr = INADDR_ANY;
|
||||
|
||||
link = (*PacketAlias.RedirectPort)(local_addr, local_port,
|
||||
null_addr, 0,
|
||||
null_addr, alias_port,
|
||||
proto_constant);
|
||||
link = PacketAliasRedirectPort(local_addr, local_port,
|
||||
null_addr, 0,
|
||||
null_addr, alias_port,
|
||||
proto_constant);
|
||||
|
||||
if (link == NULL)
|
||||
prompt_Printf(arg->prompt, "port redirect: error returned by packed"
|
||||
@ -94,7 +114,7 @@ alias_RedirectPort(struct cmdargs const *arg)
|
||||
int
|
||||
alias_RedirectAddr(struct cmdargs const *arg)
|
||||
{
|
||||
if (!alias_IsEnabled()) {
|
||||
if (!arg->bundle->AliasEnabled) {
|
||||
prompt_Printf(arg->prompt, "alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+2) {
|
||||
@ -115,7 +135,7 @@ alias_RedirectAddr(struct cmdargs const *arg)
|
||||
arg->cmd->syntax);
|
||||
return 1;
|
||||
}
|
||||
link = (*PacketAlias.RedirectAddr)(local_addr, alias_addr);
|
||||
link = PacketAliasRedirectAddr(local_addr, alias_addr);
|
||||
if (link == NULL) {
|
||||
prompt_Printf(arg->prompt, "address redirect: packet aliasing"
|
||||
" engine error\n");
|
||||
|
Loading…
Reference in New Issue
Block a user