dynamic linking
FossilOrigin-Name: fb76bfb278b3ba6d0caf0c4a67f739c020c778623239db0efe950ae8311ca34f
This commit is contained in:
parent
f95505c0bd
commit
dbd934e9fe
3
.gitignore
vendored
3
.gitignore
vendored
@ -47,4 +47,7 @@ ssl/intermediate-ca/
|
|||||||
|
|
||||||
# other stuff
|
# other stuff
|
||||||
.codelite/
|
.codelite/
|
||||||
|
lib/
|
||||||
|
obj/
|
||||||
|
bin/
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||||
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||||
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
||||||
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
|
<Project Name="mod_capwap" Path="mod_capwap.project" Active="Yes"/>
|
||||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||||
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
|
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||||
<BuildMatrix>
|
<BuildMatrix>
|
||||||
|
@ -2,7 +2,6 @@ include ../Config.mak
|
|||||||
|
|
||||||
# Define SSL Library: OPENSSL or GNUTLS
|
# Define SSL Library: OPENSSL or GNUTLS
|
||||||
# SSL_LIBRARY=OPENSSL
|
# SSL_LIBRARY=OPENSSL
|
||||||
SSL_LIBRARY=GNUTLS
|
|
||||||
|
|
||||||
|
|
||||||
|
SSL_LIBRARY=OPENSSL
|
||||||
|
|
||||||
|
@ -1,25 +1,37 @@
|
|||||||
|
|
||||||
#
|
#
|
||||||
# OpenSSL definitions
|
# OpenSSL definitions
|
||||||
#
|
#
|
||||||
#OPENSSL_VERSION=openssl-1.0.1l # doesn't work
|
# OPENSSL_VERSION=openssl-1.0.1i
|
||||||
#OPENSSL_VERSION=openssl-1.0.2 # doesn't work
|
|
||||||
OPENSSL_VERSION=openssl-1.0.1i
|
|
||||||
USE_CONTRIB_OPENSSL=0
|
USE_CONTRIB_OPENSSL=0
|
||||||
|
|
||||||
# GnuTLS definitions
|
# GnuTLS definitions
|
||||||
GNUTLS_VERSION=3.3.9
|
# GNUTLS_VERSION=3.3.9
|
||||||
|
|
||||||
USE_CONTRIB_GNUTLS=0
|
USE_CONTRIB_GNUTLS=0
|
||||||
|
|
||||||
# Compiler to use
|
# Compiler to use
|
||||||
CC=clang
|
# CC=clang
|
||||||
#CC=gcc
|
|
||||||
# CC=mips-openwrt-linux-uclibc-gcc
|
# CC=mips-openwrt-linux-uclibc-gcc
|
||||||
# LD=mips-openwrt-linux-uclibc-ld
|
# LD=mips-openwrt-linux-uclibc-ld
|
||||||
# AR=mips-openwrt-linux-uclibc-ar
|
# AR=mips-openwrt-linux-uclibc-ar
|
||||||
|
# CC=clang
|
||||||
|
|
||||||
|
|
||||||
COMPDEFS=-DWITH_CW_LOG
|
COMPDEFS=-DWITH_CW_LOG
|
||||||
COMPDEFS+=-DWITH_CW_LOG_DEBUG
|
COMPDEFS+=-DWITH_CW_LOG_DEBUG
|
||||||
|
|
||||||
|
|
||||||
|
# LIBCW settings
|
||||||
|
|
||||||
|
# WITH_GNUTLS
|
||||||
|
# compile in support for GnuTLS
|
||||||
|
#
|
||||||
|
WITH_GNUTLS=1
|
||||||
|
|
||||||
|
# Compile in openssl support
|
||||||
|
WITH_OPENSSL=1
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
LIBDIR=lib
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,16 +9,12 @@ endif
|
|||||||
|
|
||||||
ifeq ($(USE_CONTRIB_GNUTLS),1)
|
ifeq ($(USE_CONTRIB_GNUTLS),1)
|
||||||
GNUTLS_CFLAGS=-I../contrib/gnutls-${GNUTLS_VERSION}/lib/includes
|
GNUTLS_CFLAGS=-I../contrib/gnutls-${GNUTLS_VERSION}/lib/includes
|
||||||
#GNUTLS_LIBS=-lnettle -lgmp ../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/libgnutls.a
|
|
||||||
GNUTLS_LIBS=-lgmp -lgnutls -lnettle
|
GNUTLS_LIBS=-lgmp -lgnutls -lnettle
|
||||||
|
|
||||||
GNUTLS_LDFLAGS=-L../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/
|
GNUTLS_LDFLAGS=-L../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/
|
||||||
else
|
else
|
||||||
GNUTLS_CFLAGS=
|
GNUTLS_CFLAGS=
|
||||||
GNUTLS_LIBS=-lgnutls -lnettle -lgmp
|
GNUTLS_LIBS=-lgnutls -lnettle -lgmp
|
||||||
GNUTLS_LDFLAGS=
|
GNUTLS_LDFLAGS=
|
||||||
#-lgnutls -lnettle -lgmp
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
|
|
||||||
include ../ACConfig.mak
|
|
||||||
include ../Macros.mak
|
include ../Macros.mak
|
||||||
|
include ../Config.mak
|
||||||
ifndef CC
|
include ../ACConfig.mak
|
||||||
CC=gcc
|
-include ../Config.local.mak
|
||||||
endif
|
|
||||||
#SYSARCH := $(shell uname -m)
|
|
||||||
ifndef ARCH
|
|
||||||
ARCH = $(shell $(CC) -dumpmachine)
|
|
||||||
endif
|
|
||||||
|
|
||||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L../lib/$(ARCH)
|
|
||||||
CFLAGS += -Wall -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
|
||||||
|
|
||||||
|
|
||||||
LIBS+=-lcapwap
|
LIBARCHDIR=../../lib/$(ARCH)
|
||||||
LIBS+=-lcapwap80211
|
|
||||||
LIBS+=-lcipwap
|
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L$(LIBARCHDIR)
|
||||||
LIBS+=-lcisco
|
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
||||||
LIBS+=-lfortinet
|
|
||||||
LIBS+=-lzyxel
|
|
||||||
|
#LIBS+=-lcapwap
|
||||||
|
#LIBS+=-lcapwap80211
|
||||||
|
#LIBS+=-lcipwap
|
||||||
|
#LIBS+=-lcisco
|
||||||
|
#LIBS+=-lfortinet
|
||||||
|
#LIBS+=-lzyxel
|
||||||
LIBS+=-lcw
|
LIBS+=-lcw
|
||||||
LIBS+=-lrt
|
LIBS+=-lrt
|
||||||
LIBS+=-lpthread
|
LIBS+=-lpthread
|
||||||
@ -52,7 +48,7 @@ CFLAGS += -DWITH_IPV6
|
|||||||
|
|
||||||
RM = /bin/rm -f
|
RM = /bin/rm -f
|
||||||
|
|
||||||
AC_MODULES = mod_cipwap.o
|
#AC_MODULES = mod_cipwap.o
|
||||||
|
|
||||||
|
|
||||||
# list of generated object files for AC.
|
# list of generated object files for AC.
|
||||||
@ -78,12 +74,13 @@ AC_NAME = actube
|
|||||||
all: $(AC_NAME)
|
all: $(AC_NAME)
|
||||||
|
|
||||||
%.o:%.c
|
%.o:%.c
|
||||||
@echo " CC "$<
|
@echo " $(CC) "$<
|
||||||
@$(CC) -c $(CFLAGS) $< -o $@
|
@$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
$(AC_NAME): $(AC_OBJS)
|
$(AC_NAME): $(AC_OBJS)
|
||||||
$(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
|
$(CC) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -99,10 +99,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_mod_add_dynamic("../../lib/actube/capwap.so" );
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -128,6 +124,10 @@ int main(int argc, char *argv[])
|
|||||||
developers is turned on ;) */
|
developers is turned on ;) */
|
||||||
DBGX("Attention! %s", "DBG X is ON!");
|
DBGX("Attention! %s", "DBG X is ON!");
|
||||||
|
|
||||||
|
cw_mod_add_dynamic("../../lib/actube","capwap");
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
|
||||||
test_sets();
|
test_sets();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -574,7 +574,7 @@ static int conf_read_mods(cfg_t *cfg){
|
|||||||
|
|
||||||
for (i=0; i < n; i++){
|
for (i=0; i < n; i++){
|
||||||
char *modname = cfg_getnstr(cfg, CFG_ENTRY_MODS, i);
|
char *modname = cfg_getnstr(cfg, CFG_ENTRY_MODS, i);
|
||||||
conf_mods[i] = modload_ac(modname);
|
conf_mods[i] = NULL; //modload_ac(modname);
|
||||||
if (!conf_mods[i]){
|
if (!conf_mods[i]){
|
||||||
cw_log(LOG_ERR,"Can't load mod: %s",modname);
|
cw_log(LOG_ERR,"Can't load mod: %s",modname);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,25 +1,16 @@
|
|||||||
include ../CapwapConfig.mak
|
|
||||||
include ../Macros.mak
|
include ../Macros.mak
|
||||||
|
include ../CWConfig.mak
|
||||||
ifndef CC
|
-include ../Config.local.mak
|
||||||
CC=gcc
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef AR
|
|
||||||
AR = ar
|
|
||||||
endif
|
|
||||||
|
|
||||||
#ifndef ARCH
|
|
||||||
# ARCH = $(shell $(CC) -dumpmachine)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
LIBARCHDIR := ../../lib/$(ARCH)
|
||||||
|
OBJDIR := ../../obj/cw/$(ARCH)
|
||||||
|
|
||||||
#OPENSSLINC=$(OPENSSLINC)
|
SNAME := $(LIBARCHDIR)/libcw.a
|
||||||
#../contrib/openssl-1.0.1i/include
|
DNAME := $(LIBARCHDIR)/libcw.so
|
||||||
|
|
||||||
|
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib
|
||||||
|
|
||||||
NAME=libcw.a
|
|
||||||
LIBDIR=../lib/$(ARCH)
|
|
||||||
|
|
||||||
SOCKOBJS=\
|
SOCKOBJS=\
|
||||||
sock_create.o\
|
sock_create.o\
|
||||||
@ -203,6 +194,8 @@ CAPWAP80211OBJS=\
|
|||||||
# SSL objects
|
# SSL objects
|
||||||
#
|
#
|
||||||
|
|
||||||
|
LIBS=
|
||||||
|
|
||||||
ifeq ($(WITH_OPENSSL),1)
|
ifeq ($(WITH_OPENSSL),1)
|
||||||
CFLAGS+=$(OPENSSL_CFLAGS)
|
CFLAGS+=$(OPENSSL_CFLAGS)
|
||||||
CFLAGS+=-DWITH_OPENSSL
|
CFLAGS+=-DWITH_OPENSSL
|
||||||
@ -211,6 +204,7 @@ DTLSOBJS += dtls_openssl.o \
|
|||||||
dtls_openssl_connect.o \
|
dtls_openssl_connect.o \
|
||||||
dtls_openssl_get_cipher.o \
|
dtls_openssl_get_cipher.o \
|
||||||
dtls_openssl_bio.o
|
dtls_openssl_bio.o
|
||||||
|
LIBS+=-lssl
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(WITH_GNUTLS),1)
|
ifeq ($(WITH_GNUTLS),1)
|
||||||
@ -222,6 +216,7 @@ DTLSOBJS+= dtls_gnutls.o \
|
|||||||
dtls_gnutls_bio.o \
|
dtls_gnutls_bio.o \
|
||||||
dtls_gnutls_get_cipher.o \
|
dtls_gnutls_get_cipher.o \
|
||||||
dtls_gnutls_get_peers_cert.o
|
dtls_gnutls_get_peers_cert.o
|
||||||
|
LIBS+=-lgnutls
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DTLSOBJS+=dtls_bio.o
|
DTLSOBJS+=dtls_bio.o
|
||||||
@ -323,18 +318,15 @@ OBJS=$(CONNOBJS) $(FRAGOBJS) $(SOCKOBJS) $(CAPWAPOBJS) $(WTPINFOOBJS) \
|
|||||||
$(MBAGOBJS) \
|
$(MBAGOBJS) \
|
||||||
$(CAPWAP80211OBJS)
|
$(CAPWAP80211OBJS)
|
||||||
|
|
||||||
#include $(OBJS:.o=.d)
|
|
||||||
|
|
||||||
O:=$(OBJS);
|
O:=$(OBJS);
|
||||||
|
|
||||||
OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
|
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||||
|
|
||||||
|
|
||||||
|
all: $(SNAME) $(DNAME)
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS = -W -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
||||||
CFLAGS = -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
|
||||||
#CFLAGS = -Wall -Os -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
|
|
||||||
|
|
||||||
CFLAGS += $(GNUTLS_CFLAGS) \
|
CFLAGS += $(GNUTLS_CFLAGS) \
|
||||||
-DWITH_CW_LOG \
|
-DWITH_CW_LOG \
|
||||||
@ -345,22 +337,21 @@ CFLAGS += $(GNUTLS_CFLAGS) \
|
|||||||
-Werror
|
-Werror
|
||||||
|
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o:%.c
|
||||||
|
@mkdir -p $(OBJDIR)
|
||||||
#SRCS = $(OBJS:.o=.c)
|
@echo " $(CC) "$<
|
||||||
#MODOBJS=$(wildcard ./mod/cipwap/$(ARCH)/*.o)
|
|
||||||
#MODOBJS+=$(wildcard ./mod/capwap/$(ARCH)/*.o)
|
|
||||||
|
|
||||||
$(ARCH)/%.o:%.c
|
|
||||||
@mkdir -p $(ARCH)
|
|
||||||
@echo " CC "$<
|
|
||||||
@$(CC) -c $(CFLAGS) $< -o $@
|
@$(CC) -c $(CFLAGS) $< -o $@
|
||||||
# @$(CC) -MM $(CFLAGS) $< > $*.d
|
|
||||||
|
|
||||||
$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS)
|
$(SNAME) : $(OBJS) $(MODOBJS)
|
||||||
@mkdir -p $(LIBDIR)
|
@mkdir -p $(LIBARCHDIR)
|
||||||
@echo " AR $(LIBDIR)/$(NAME)"
|
@echo " AR $(SNAME)"
|
||||||
@$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS)
|
@$(AR) rcs $(SNAME) $(OBJS) $(MODOBJS)
|
||||||
|
|
||||||
|
$(DNAME) : $(OBJS) $(MODOBJS)
|
||||||
|
@mkdir -p $(LIBARCHDIR)
|
||||||
|
@echo " AR $(DNAME)"
|
||||||
|
@$(CC) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(MODOBJS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SRCS = $(OBJS:.o=.c)
|
SRCS = $(OBJS:.o=.c)
|
||||||
@ -370,19 +361,11 @@ DEPS := $(OBJS:.o=.d)
|
|||||||
.PHONY: deps clean clean_libs libs
|
.PHONY: deps clean clean_libs libs
|
||||||
|
|
||||||
|
|
||||||
# top-level rule, to compile everything.
|
|
||||||
all: $(ARCH)/$(NAME)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(ARCH)/*
|
$(RM) $(OBJDIR)/*
|
||||||
$(RM) $(LIBDIR)/$(NAME)
|
$(RM) $(DNAME)
|
||||||
# $(RM) $(OBJS)
|
$(RM) $(SNAME)
|
||||||
# $(RM) $(DEPS)
|
|
||||||
# $(RM) $(ARCH)/$(NAME)
|
|
||||||
|
|
||||||
|
|
||||||
clean_deps:
|
clean_deps:
|
||||||
|
@ -94,14 +94,15 @@ static void mbag_type_mbag_del(void *i)
|
|||||||
mavl_destroy(x);
|
mavl_destroy(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct mbag_typedef mbag_type_mbag = {
|
/*const struct mbag_typedef mbag_type_mbag = {
|
||||||
|
# "mbag",mbag_type_mbag_del
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*const struct mbag_typedef mbag_type_mbag_dyn = {
|
||||||
"mbag",mbag_type_mbag_del
|
"mbag",mbag_type_mbag_del
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
const struct mbag_typedef mbag_type_mbag_dyn = {
|
|
||||||
"mbag",mbag_type_mbag_del
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static void mbag_del_data(struct mbag_item *i)
|
static void mbag_del_data(struct mbag_item *i)
|
||||||
{
|
{
|
||||||
|
30
src/cw/mod.c
30
src/cw/mod.c
@ -182,16 +182,32 @@ int cw_mod_add(struct cw_Mod * (*modfn)() ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cw_mod_add_dynamic(const char * filename){
|
int cw_mod_add_dynamic(const char * path, const char * mod_name){
|
||||||
|
|
||||||
|
char * filename = malloc(strlen(path)+strlen(mod_name)+8);
|
||||||
|
if (!filename)
|
||||||
|
return 0;
|
||||||
|
strcpy(filename,path);
|
||||||
|
strcat(filename,"/");
|
||||||
|
strcat(filename,mod_name);
|
||||||
|
strcat(filename,".so");
|
||||||
|
|
||||||
|
int rc=0;
|
||||||
|
|
||||||
void * handle;
|
void * handle;
|
||||||
handle = dlopen(filename,RTLD_NOW);
|
handle = dlopen(filename,RTLD_NOW);
|
||||||
if (!handle){
|
if (!handle){
|
||||||
printf("Error: %s",dlerror());
|
cw_log(LOG_ERROR,"Failed to load module: %s",dlerror());
|
||||||
|
goto errX;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Load DLL %p\n",handle);
|
void * ifu = dlsym(handle,"mod_get_interface");
|
||||||
|
if (!ifu){
|
||||||
void * ifu = dlsym(handle,"bstr_create");
|
cw_log(LOG_ERROR,"Failed to load module: %s",dlerror());
|
||||||
|
goto errX;
|
||||||
printf("IFU DLL %p\n",ifu);
|
}
|
||||||
|
|
||||||
|
errX:
|
||||||
|
free(filename);
|
||||||
|
return rc;
|
||||||
}
|
}
|
@ -84,6 +84,6 @@ extern int mod_caching;
|
|||||||
#define mod_set_caching(var) (mod_caching=var)
|
#define mod_set_caching(var) (mod_caching=var)
|
||||||
#define mod_get_caching() (mod_caching)
|
#define mod_get_caching() (mod_caching)
|
||||||
|
|
||||||
extern int cw_mod_add_dynamic(const char * filename);
|
extern int cw_mod_add_dynamic(const char * path, const char * file);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,3 +53,8 @@ struct cw_Mod *mod_capwap_ac()
|
|||||||
{
|
{
|
||||||
return &capwap_ac;
|
return &capwap_ac;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct cw_Mod * mod_get_interface(){
|
||||||
|
return &capwap_ac;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user