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
|
||||
.codelite/
|
||||
lib/
|
||||
obj/
|
||||
bin/
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||
<Project Name="wtp" Path="wtp.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="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_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||
<BuildMatrix>
|
||||
|
@ -1,8 +1,7 @@
|
||||
include ../Config.mak
|
||||
|
||||
#Define SSL Library: OPENSSL or GNUTLS
|
||||
#SSL_LIBRARY=OPENSSL
|
||||
SSL_LIBRARY=GNUTLS
|
||||
|
||||
# Define SSL Library: OPENSSL or GNUTLS
|
||||
# SSL_LIBRARY=OPENSSL
|
||||
|
||||
SSL_LIBRARY=OPENSSL
|
||||
|
||||
|
@ -1,25 +1,37 @@
|
||||
|
||||
#
|
||||
# OpenSSL definitions
|
||||
#
|
||||
#OPENSSL_VERSION=openssl-1.0.1l # doesn't work
|
||||
#OPENSSL_VERSION=openssl-1.0.2 # doesn't work
|
||||
OPENSSL_VERSION=openssl-1.0.1i
|
||||
# OPENSSL_VERSION=openssl-1.0.1i
|
||||
USE_CONTRIB_OPENSSL=0
|
||||
|
||||
# GnuTLS definitions
|
||||
GNUTLS_VERSION=3.3.9
|
||||
# GNUTLS_VERSION=3.3.9
|
||||
|
||||
USE_CONTRIB_GNUTLS=0
|
||||
|
||||
# Compiler to use
|
||||
CC=clang
|
||||
#CC=gcc
|
||||
#CC=mips-openwrt-linux-uclibc-gcc
|
||||
#LD=mips-openwrt-linux-uclibc-ld
|
||||
#AR=mips-openwrt-linux-uclibc-ar
|
||||
|
||||
|
||||
# CC=clang
|
||||
# CC=mips-openwrt-linux-uclibc-gcc
|
||||
# LD=mips-openwrt-linux-uclibc-ld
|
||||
# AR=mips-openwrt-linux-uclibc-ar
|
||||
# CC=clang
|
||||
|
||||
COMPDEFS=-DWITH_CW_LOG
|
||||
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)
|
||||
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_LDFLAGS=-L../contrib/gnutls-${GNUTLS_VERSION}/lib/.libs/
|
||||
else
|
||||
GNUTLS_CFLAGS=
|
||||
GNUTLS_LIBS=-lgnutls -lnettle -lgmp
|
||||
GNUTLS_LDFLAGS=
|
||||
#-lgnutls -lnettle -lgmp
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
@ -1,25 +1,21 @@
|
||||
|
||||
include ../ACConfig.mak
|
||||
include ../Macros.mak
|
||||
|
||||
ifndef CC
|
||||
CC=gcc
|
||||
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}\"
|
||||
include ../Config.mak
|
||||
include ../ACConfig.mak
|
||||
-include ../Config.local.mak
|
||||
|
||||
|
||||
LIBS+=-lcapwap
|
||||
LIBS+=-lcapwap80211
|
||||
LIBS+=-lcipwap
|
||||
LIBS+=-lcisco
|
||||
LIBS+=-lfortinet
|
||||
LIBS+=-lzyxel
|
||||
LIBARCHDIR=../../lib/$(ARCH)
|
||||
|
||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L$(LIBARCHDIR)
|
||||
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
||||
|
||||
|
||||
#LIBS+=-lcapwap
|
||||
#LIBS+=-lcapwap80211
|
||||
#LIBS+=-lcipwap
|
||||
#LIBS+=-lcisco
|
||||
#LIBS+=-lfortinet
|
||||
#LIBS+=-lzyxel
|
||||
LIBS+=-lcw
|
||||
LIBS+=-lrt
|
||||
LIBS+=-lpthread
|
||||
@ -52,7 +48,7 @@ CFLAGS += -DWITH_IPV6
|
||||
|
||||
RM = /bin/rm -f
|
||||
|
||||
AC_MODULES = mod_cipwap.o
|
||||
#AC_MODULES = mod_cipwap.o
|
||||
|
||||
|
||||
# list of generated object files for AC.
|
||||
@ -78,12 +74,13 @@ AC_NAME = actube
|
||||
all: $(AC_NAME)
|
||||
|
||||
%.o:%.c
|
||||
@echo " CC "$<
|
||||
@echo " $(CC) "$<
|
||||
@$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
$(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:
|
||||
|
@ -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 ;) */
|
||||
DBGX("Attention! %s", "DBG X is ON!");
|
||||
|
||||
cw_mod_add_dynamic("../../lib/actube","capwap");
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
test_sets();
|
||||
exit(0);
|
||||
|
@ -574,7 +574,7 @@ static int conf_read_mods(cfg_t *cfg){
|
||||
|
||||
for (i=0; i < n; 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]){
|
||||
cw_log(LOG_ERR,"Can't load mod: %s",modname);
|
||||
return 0;
|
||||
|
@ -1,25 +1,16 @@
|
||||
include ../CapwapConfig.mak
|
||||
include ../Macros.mak
|
||||
|
||||
ifndef CC
|
||||
CC=gcc
|
||||
endif
|
||||
|
||||
ifndef AR
|
||||
AR = ar
|
||||
endif
|
||||
|
||||
#ifndef ARCH
|
||||
# ARCH = $(shell $(CC) -dumpmachine)
|
||||
#endif
|
||||
include ../CWConfig.mak
|
||||
-include ../Config.local.mak
|
||||
|
||||
|
||||
LIBARCHDIR := ../../lib/$(ARCH)
|
||||
OBJDIR := ../../obj/cw/$(ARCH)
|
||||
|
||||
#OPENSSLINC=$(OPENSSLINC)
|
||||
#../contrib/openssl-1.0.1i/include
|
||||
SNAME := $(LIBARCHDIR)/libcw.a
|
||||
DNAME := $(LIBARCHDIR)/libcw.so
|
||||
|
||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib
|
||||
|
||||
NAME=libcw.a
|
||||
LIBDIR=../lib/$(ARCH)
|
||||
|
||||
SOCKOBJS=\
|
||||
sock_create.o\
|
||||
@ -203,6 +194,8 @@ CAPWAP80211OBJS=\
|
||||
# SSL objects
|
||||
#
|
||||
|
||||
LIBS=
|
||||
|
||||
ifeq ($(WITH_OPENSSL),1)
|
||||
CFLAGS+=$(OPENSSL_CFLAGS)
|
||||
CFLAGS+=-DWITH_OPENSSL
|
||||
@ -211,6 +204,7 @@ DTLSOBJS += dtls_openssl.o \
|
||||
dtls_openssl_connect.o \
|
||||
dtls_openssl_get_cipher.o \
|
||||
dtls_openssl_bio.o
|
||||
LIBS+=-lssl
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_GNUTLS),1)
|
||||
@ -222,6 +216,7 @@ DTLSOBJS+= dtls_gnutls.o \
|
||||
dtls_gnutls_bio.o \
|
||||
dtls_gnutls_get_cipher.o \
|
||||
dtls_gnutls_get_peers_cert.o
|
||||
LIBS+=-lgnutls
|
||||
endif
|
||||
|
||||
DTLSOBJS+=dtls_bio.o
|
||||
@ -323,18 +318,15 @@ OBJS=$(CONNOBJS) $(FRAGOBJS) $(SOCKOBJS) $(CAPWAPOBJS) $(WTPINFOOBJS) \
|
||||
$(MBAGOBJS) \
|
||||
$(CAPWAP80211OBJS)
|
||||
|
||||
#include $(OBJS:.o=.d)
|
||||
|
||||
O:=$(OBJS);
|
||||
|
||||
OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
|
||||
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||
|
||||
|
||||
all: $(SNAME) $(DNAME)
|
||||
|
||||
|
||||
|
||||
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 = -W -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
||||
|
||||
CFLAGS += $(GNUTLS_CFLAGS) \
|
||||
-DWITH_CW_LOG \
|
||||
@ -345,22 +337,21 @@ CFLAGS += $(GNUTLS_CFLAGS) \
|
||||
-Werror
|
||||
|
||||
|
||||
|
||||
|
||||
#SRCS = $(OBJS:.o=.c)
|
||||
#MODOBJS=$(wildcard ./mod/cipwap/$(ARCH)/*.o)
|
||||
#MODOBJS+=$(wildcard ./mod/capwap/$(ARCH)/*.o)
|
||||
|
||||
$(ARCH)/%.o:%.c
|
||||
@mkdir -p $(ARCH)
|
||||
@echo " CC "$<
|
||||
$(OBJDIR)/%.o:%.c
|
||||
@mkdir -p $(OBJDIR)
|
||||
@echo " $(CC) "$<
|
||||
@$(CC) -c $(CFLAGS) $< -o $@
|
||||
# @$(CC) -MM $(CFLAGS) $< > $*.d
|
||||
|
||||
$(LIBDIR)/$(NAME) : $(OBJS) $(MODOBJS)
|
||||
@mkdir -p $(LIBDIR)
|
||||
@echo " AR $(LIBDIR)/$(NAME)"
|
||||
@$(AR) rcs $(LIBDIR)/$(NAME) $(OBJS) $(MODOBJS)
|
||||
$(SNAME) : $(OBJS) $(MODOBJS)
|
||||
@mkdir -p $(LIBARCHDIR)
|
||||
@echo " AR $(SNAME)"
|
||||
@$(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)
|
||||
@ -370,19 +361,11 @@ DEPS := $(OBJS:.o=.d)
|
||||
.PHONY: deps clean clean_libs libs
|
||||
|
||||
|
||||
# top-level rule, to compile everything.
|
||||
all: $(ARCH)/$(NAME)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
$(RM) $(ARCH)/*
|
||||
$(RM) $(LIBDIR)/$(NAME)
|
||||
# $(RM) $(OBJS)
|
||||
# $(RM) $(DEPS)
|
||||
# $(RM) $(ARCH)/$(NAME)
|
||||
$(RM) $(OBJDIR)/*
|
||||
$(RM) $(DNAME)
|
||||
$(RM) $(SNAME)
|
||||
|
||||
|
||||
clean_deps:
|
||||
|
@ -94,14 +94,15 @@ static void mbag_type_mbag_del(void *i)
|
||||
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
|
||||
};
|
||||
|
||||
const struct mbag_typedef mbag_type_mbag_dyn = {
|
||||
"mbag",mbag_type_mbag_del
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
static void mbag_del_data(struct mbag_item *i)
|
||||
{
|
||||
|
28
src/cw/mod.c
28
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;
|
||||
handle = dlopen(filename,RTLD_NOW);
|
||||
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){
|
||||
cw_log(LOG_ERROR,"Failed to load module: %s",dlerror());
|
||||
goto errX;
|
||||
}
|
||||
|
||||
void * ifu = dlsym(handle,"bstr_create");
|
||||
|
||||
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_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
|
||||
|
@ -53,3 +53,8 @@ struct cw_Mod *mod_capwap_ac()
|
||||
{
|
||||
return &capwap_ac;
|
||||
};
|
||||
|
||||
|
||||
struct cw_Mod * mod_get_interface(){
|
||||
return &capwap_ac;
|
||||
}
|
Loading…
Reference in New Issue
Block a user