Skip to content

Commit

Permalink
initial release of nat64 module by Vitold (#74)
Browse files Browse the repository at this point in the history
* initial release of nat64 module by Vitold

* reworked naming, fixes

* potential fix for build system

* reworked infrastructure for pjnat64 module

* ios build import fix and removed not-needed debug flag

* fixes to nat64 module, patching R-URI, contact rewrite

* pr review fixes

* feedback changes

* Update NAT64 module

---------

Co-authored-by: Vitold Sedyshev <[email protected]>
  • Loading branch information
dshamaev-intermedia and Vitold Sedyshev authored Apr 1, 2024
1 parent 9d41209 commit 07cc148
Show file tree
Hide file tree
Showing 6 changed files with 1,556 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include build/host-$(HOST_NAME).mak
-include user.mak
include version.mak

LIB_DIRS = pjlib/build pjlib-util/build pjnath/build third_party/build pjmedia/build pjsip/build
LIB_DIRS = pjlib/build pjlib-util/build pjnath/build third_party/build pjmedia/build pjsip/build pjnat64/build
DIRS = $(LIB_DIRS) pjsip-apps/build $(EXTRA_DIRS)

ifdef MINSIZE
Expand Down
1 change: 1 addition & 0 deletions ios_framework/Sources/Headers/PJSip-umbrella.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import <PJSipIOS/pjsip_auth.h>
#import <PJSipIOS/pjsip_ua.h>
#import <PJSipIOS/pjsua.h>
#import <PJSipIOS/pjnat64/pj-nat64.h>

FOUNDATION_EXPORT double PJSipIOSVersionNumber;
FOUNDATION_EXPORT const unsigned char PJSipIOSVersionString[];
Expand Down
1 change: 1 addition & 0 deletions ios_framework/build_ios_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function copy_headers() {
cp -r ${source_dir}/pjlib-util/include/* $headers_dir
cp -r ${source_dir}/pjmedia/include/* $headers_dir
cp -r ${source_dir}/pjnath/include/* $headers_dir
cp -r ${source_dir}/pjnat64/include/* $headers_dir
#remove unneeded headers that was copied from "pjsip/include"
prev_dir=`pwd -P`
cd $headers_dir
Expand Down
88 changes: 88 additions & 0 deletions pjnat64/build/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

include ../../build.mak
include ../../version.mak
include $(PJDIR)/build/common.mak

export LIBDIR := ../lib
export BINDIR := ../bin

RULES_MAK := $(PJDIR)/build/rules.mak

PJLIB_LIB:=../../pjlib/lib/libpj-$(TARGET_NAME)$(LIBEXT)
PJSIP_LIB:=../../pjsip/lib/libpjsip-$(TARGET_NAME)$(LIBEXT)
PJMEDIA_LIB:=../../pjmedia/lib/libpjmedia-$(TARGET_NAME)$(LIBEXT)
#PJSIP_SIMPLE_LIB :=
#PJSIP_UA_LIB :=
#PJSUA_LIB_LIB :=
#PJSUA2_LIB_LIB :=

export PJNAT64_LIB:=libpjnat64-$(TARGET_NAME)$(LIBEXT)

ifeq ($(PJ_SHARED_LIBRARIES),)
else
export PJNAT64_SONAME := libpjnat64.$(SHLIB_SUFFIX)
export PJNAT64_SHLIB := $(PJNAT64_SONAME).$(PJ_VERSION_MAJOR)
endif

###############################################################################
# Gather all flags.
#
export _CFLAGS := $(CC_CFLAGS) $(OS_CFLAGS) $(HOST_CFLAGS) $(M_CFLAGS) \
$(CFLAGS) $(CC_INC)../include \
$(CC_INC)../../pjlib/include \
$(CC_INC)../../pjsip/include \
$(CC_INC)../../pjlib-util/include \
$(CC_INC)../../pjnath/include \
$(CC_INC)../../pjmedia/include
export _CXXFLAGS:= $(_CFLAGS) $(CC_CXXFLAGS) $(OS_CXXFLAGS) $(M_CXXFLAGS) \
$(HOST_CXXFLAGS) $(CXXFLAGS)
export _LDFLAGS := $(CC_LDFLAGS) $(OS_LDFLAGS) $(M_LDFLAGS) $(HOST_LDFLAGS) \
$(APP_LDFLAGS) $(LDFLAGS)

###############################################################################
# Defines for building PJNAT64 library
#
export PJNAT64_SRCDIR = ../src/pjnat64
export PJNAT64_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
pj-nat64.o
export PJNAT64_CFLAGS += $(_CFLAGS)
export PJNAT64_CXXFLAGS += $(_CXXFLAGS)
export PJNAT64_LDFLAGS += $(PJLIB_LDLIB) $(PJSIP_LDLIB) $(PJMEDIA_LDLIB) $(_LDFLAGS)

###############################################################################
# Main entry

TARGETS := $(PJNAT64_LIB) $(PJNAT64_SONAME)

all: $(TARGETS)

lib: $(TARGETS)

doc:

dep: depend
distclean: realclean

.PHONY: all dep depend clean realclean distclean
.PHONY: $(TARGETS)
.PHONY: $(PJNAT64_LIB) $(PJNAT64_SONAME)

pjnat64: $(PJNAT64_LIB)
$(PJNAT64_SONAME): $(PJNAT64_LIB)
$(PJNAT64_LIB) $(PJNAT64_SONAME): $(PJLIB_LIB) $(PJLIB_SONAME) $(PJSIP_LIB) $(PJSIP_SONAME) $(PJMEDIA_LIB) $(PJMEDIA_SONAME)
$(MAKE) -f $(RULES_MAK) APP=PJNAT64 app=pjnat64 $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)

.PHONY: pjnat64.ko
pjnat64.ko:
echo Making $@
$(MAKE) -f $(RULES_MAK) APP=PJNAT64 app=pjnat64 $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)

clean:
$(MAKE) -f $(RULES_MAK) APP=PJNAT64 app=pjnat64 $@

realclean:
$(subst @@,$(subst /,$(HOST_PSEP),.pjnat64-$(TARGET_NAME).depend),$(HOST_RMR))
$(MAKE) -f $(RULES_MAK) APP=PJNAT64 app=pjnat64 $@

depend:
$(MAKE) -f $(RULES_MAK) APP=PJNAT64 app=pjnat64 $@
61 changes: 61 additions & 0 deletions pjnat64/include/pjnat64/pj-nat64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef PJ_NAT64_H_
#define PJ_NAT64_H_

PJ_BEGIN_DECL

/**
* Enable nat64 rewriting module.
*
*/
pj_status_t pj_nat64_enable_rewrite_module();

/**
* Disable rewriting module, for instance when on a ipv4 network
*
*/
pj_status_t pj_nat64_disable_rewrite_module();

/**
* Enable/disable all IPv6 rewriting module options
*
*/
void pj_nat64_set_enable(pj_bool_t yesno);

/**
* Set HPBX server IPv4 address
*
**/
void pj_nat64_set_server_addr(pj_str_t *addr, int port);

/**
* Set HPBX server IPv6 address
*
**/
void pj_nat64_set_server_addr6(pj_str_t *addr, int port);

/**
* Set account IPv4 address
*
**/
void pj_nat64_set_client_addr(pj_str_t *addr, int port);

/**
* Set account IPv6 address
*
**/
void pj_nat64_set_client_addr6(pj_str_t *addr, int port);

/** Dump maps
*
**/
void pj_nat64_dump();

/**
* Debug options
*
*/
void pj_nat64_set_debug(pj_bool_t yesno);

PJ_END_DECL

#endif
Loading

0 comments on commit 07cc148

Please sign in to comment.