Ticket #354: build PJLIB as dynamic libraries (.DSO) in Symbian

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1405 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2007-07-20 08:08:30 +00:00
parent 2157666e9d
commit 8ab968fd0d
85 changed files with 1883 additions and 339 deletions

View File

@ -1,5 +1,6 @@
rem set MWSym2Libraries=1
rem set EPOCROOT=\Symbian\9.1\S60_3rd\
rem set EPOCROOT=\Symbian\9.1\S60_3rd_MR_2\
rem set EPOCROOT=\Symbian\UIQ3SDK\
@rem set MWSym2Libraries=1
@rem set EPOCROOT=\Symbian\9.1\S60_3rd\
@rem set EPOCROOT=\Symbian\9.1\S60_3rd_MR_2\
@rem set EPOCROOT=\Symbian\UIQ3SDK\
@rem set EPOCROOT=\symbian\UIQ3.1\
bldmake bldfiles

View File

@ -1,6 +1,7 @@
rem set MWSym2Libraries=1
rem set MWSym2Libraries=\Symbian\9.1\S60_3rd\Epoc32\release\winscw\udeb
@rem call abld build -v vs6 udeb
@rem call abld build -v gcce urel
@rem call abld build winscw udeb
call abld build %1 %2 %3 %4
rem set EPOCROOT=\Symbian\9.1\S60_3rd\
rem set EPOCROOT=\Symbian\9.1\S60_3rd_MR_2\
call abld build -v vs6 udeb

View File

@ -1,10 +1,11 @@
prj_platforms
winscw
armv5
//armv5
gcce
prj_mmpfiles
pjlib.mmp
pjlib_test.mmp
pjlib_util.mmp
pjnath.mmp
pjsdp.mmp
@ -12,8 +13,8 @@ pjmedia.mmp
pjsip.mmp
pjsip_simple.mmp
pjsip_ua.mmp
//pjlib_test.mmp
//sipstateless.mmp
pjlib_test.mmp
sipstateless.mmp
pjsua_lib.mmp
null_audio.mmp
symbian_ua.mmp

56
build.symbian/makedef.sh Normal file
View File

@ -0,0 +1,56 @@
#!/bin/sh
MMP=$1
if test "$MMP" == ""; then
echo Usage: makedef.sh FILE.MMP
exit 1
fi
if test -f $MMP; then
true
else
echo "Unable to open $MMP"
exit 1
fi
TARGET=`grep -w TARGET $MMP | awk '{print $2}' | awk -F '.' '{print $1}' | head -1`
DEFFILE="${TARGET}U.def"
SOURCES=`grep -w SOURCE $MMP | awk '{print $2}' | tr '\\\\' '/'`
SOURCEPATH=`grep -w SOURCEPATH $MMP | tr '\\\\' '/' | awk '{print $2}'`
INCPATH=`grep INCLUDE $MMP | awk '{print $2}' | grep pj | tr '\\\\' '/'`
INCLUDE=""
for INC in $INCPATH; do
INCLUDE=`echo $INCLUDE -I$INC`
done
echo > tmpnames.def
for file in $SOURCES; do
#SYMBOLS=`grep PJ_DEF ${SOURCEPATH}/$file | awk -F ')' '{print $2}' | awk -F '(' '{print $1}' | awk -F '=' '{print $1}' | tr -d '[:blank:]' | sort | uniq`
SYMBOLS=`
cpp -DPJ_SYMBIAN=1 -DPJ_DLL -DPJ_EXPORTING=1 $INCLUDE ${SOURCEPATH}/$file 2>&1 |
grep EXPORT_C |
sed 's/(/;/' |
sed 's/=/;/' |
awk -F ';' '{print $1}' |
awk '{print $NF}'`
echo Processing ${SOURCEPATH}/$file..
for SYM in $SYMBOLS; do
echo $SYM >> tmpnames.def
done
done
echo "Writing $DEFFILE"
echo EXPORTS > $DEFFILE
i=0
for SYM in `cat tmpnames.def | sort | uniq`; do
echo " $SYM"
i=`expr $i + 1`
printf "\\t%-40s @ $i NONAME\\n" $SYM >> $DEFFILE
done
echo
echo "Done. Total $i symbols exported."

View File

@ -1,7 +1,22 @@
#if defined(EKA2)
// ARM ABIv2 doesn't support static libraries anymore
TARGET pjlib.dll
TARGETTYPE dll
UID 0x1000008d 0xA0004299
CAPABILITY NONE
LIBRARY esock.lib insock.lib charconv.lib euser.lib estlib.lib
MACRO PJ_DLL
MACRO PJ_EXPORTING
DEFFILE .\pjlib.def
#else
TARGET pjlib.lib
TARGETTYPE lib
UID 0x100039CE 0x10004299
VENDORID 0x70000001
//VENDORID 0x70000001
#endif
SOURCEPATH ..\pjlib\src\pj
@ -32,6 +47,7 @@ SOURCE pool_buf.c
SOURCE pool_caching.c
SOURCE rand.c
SOURCE rbtree.c
SOURCE sock_common.c
SOURCE types.c
@ -91,7 +107,7 @@ SOURCE unicode_symbian.cpp
//DOCUMENT pj\unicode.h
SYSTEMINCLUDE ..\pjlib\include
SYSTEMINCLUDE \epoc32\include
SYSTEMINCLUDE \epoc32\include\libc

290
build.symbian/pjlibU.def Normal file
View File

@ -0,0 +1,290 @@
EXPORTS
PJ_FD_CLR @ 1 NONAME
PJ_FD_COUNT @ 2 NONAME
PJ_FD_ISSET @ 3 NONAME
PJ_FD_SET @ 4 NONAME
PJ_FD_ZERO @ 5 NONAME
pj_AF_INET @ 6 NONAME
pj_AF_INET6 @ 7 NONAME
pj_AF_IRDA @ 8 NONAME
pj_AF_PACKET @ 9 NONAME
pj_AF_UNIX @ 10 NONAME
pj_IPTOS_LOWDELAY @ 11 NONAME
pj_IPTOS_MINCOST @ 12 NONAME
pj_IPTOS_RELIABILITY @ 13 NONAME
pj_IPTOS_THROUGHPUT @ 14 NONAME
pj_IP_TOS @ 15 NONAME
pj_MSG_DONTROUTE @ 16 NONAME
pj_MSG_OOB @ 17 NONAME
pj_MSG_PEEK @ 18 NONAME
pj_SOCK_DGRAM @ 19 NONAME
pj_SOCK_RAW @ 20 NONAME
pj_SOCK_RDM @ 21 NONAME
pj_SOCK_STREAM @ 22 NONAME
pj_SOL_IP @ 23 NONAME
pj_SOL_IPV6 @ 24 NONAME
pj_SOL_SOCKET @ 25 NONAME
pj_SOL_TCP @ 26 NONAME
pj_SOL_UDP @ 27 NONAME
pj_SO_RCVBUF @ 28 NONAME
pj_SO_SNDBUF @ 29 NONAME
pj_SO_TYPE @ 30 NONAME
pj_ansi_to_unicode @ 31 NONAME
pj_array_erase @ 32 NONAME
pj_array_find @ 33 NONAME
pj_array_insert @ 34 NONAME
pj_atexit @ 35 NONAME
pj_atomic_add @ 36 NONAME
pj_atomic_add_and_get @ 37 NONAME
pj_atomic_create @ 38 NONAME
pj_atomic_dec @ 39 NONAME
pj_atomic_dec_and_get @ 40 NONAME
pj_atomic_destroy @ 41 NONAME
pj_atomic_get @ 42 NONAME
pj_atomic_inc @ 43 NONAME
pj_atomic_inc_and_get @ 44 NONAME
pj_atomic_set @ 45 NONAME
pj_caching_pool_destroy @ 46 NONAME
pj_caching_pool_init @ 47 NONAME
pj_create_random_string @ 48 NONAME
pj_create_unique_string @ 49 NONAME
pj_dump_config @ 50 NONAME
pj_elapsed_cycle @ 51 NONAME
pj_elapsed_msec @ 52 NONAME
pj_elapsed_nanosec @ 53 NONAME
pj_elapsed_time @ 54 NONAME
pj_elapsed_usec @ 55 NONAME
pj_enter_critical_section @ 56 NONAME
pj_enum_ip_interface @ 57 NONAME
pj_enum_ip_route @ 58 NONAME
pj_exception_id_alloc @ 59 NONAME
pj_exception_id_free @ 60 NONAME
pj_exception_id_name @ 61 NONAME
pj_fifobuf_alloc @ 62 NONAME
pj_fifobuf_free @ 63 NONAME
pj_fifobuf_init @ 64 NONAME
pj_fifobuf_max_size @ 65 NONAME
pj_fifobuf_unalloc @ 66 NONAME
pj_file_close @ 67 NONAME
pj_file_delete @ 68 NONAME
pj_file_exists @ 69 NONAME
pj_file_flush @ 70 NONAME
pj_file_getpos @ 71 NONAME
pj_file_getstat @ 72 NONAME
pj_file_move @ 73 NONAME
pj_file_open @ 74 NONAME
pj_file_read @ 75 NONAME
pj_file_setpos @ 76 NONAME
pj_file_size @ 77 NONAME
pj_file_write @ 78 NONAME
pj_generate_unique_string @ 79 NONAME
pj_get_netos_error @ 80 NONAME
pj_get_os_error @ 81 NONAME
pj_get_timestamp @ 82 NONAME
pj_get_timestamp_freq @ 83 NONAME
pj_gethostaddr @ 84 NONAME
pj_gethostbyname @ 85 NONAME
pj_gethostip @ 86 NONAME
pj_gethostname @ 87 NONAME
pj_getpid @ 88 NONAME
pj_gettimeofday @ 89 NONAME
pj_hash_calc @ 90 NONAME
pj_hash_calc_tolower @ 91 NONAME
pj_hash_count @ 92 NONAME
pj_hash_create @ 93 NONAME
pj_hash_first @ 94 NONAME
pj_hash_get @ 95 NONAME
pj_hash_next @ 96 NONAME
pj_hash_set @ 97 NONAME
pj_hash_set_np @ 98 NONAME
pj_hash_this @ 99 NONAME
pj_htonl @ 100 NONAME
pj_htons @ 101 NONAME
pj_inet_addr @ 102 NONAME
pj_inet_addr2 @ 103 NONAME
pj_inet_aton @ 104 NONAME
pj_inet_ntoa @ 105 NONAME
pj_init @ 106 NONAME
pj_ioqueue_accept @ 107 NONAME
pj_ioqueue_connect @ 108 NONAME
pj_ioqueue_create @ 109 NONAME
pj_ioqueue_destroy @ 110 NONAME
pj_ioqueue_get_user_data @ 111 NONAME
pj_ioqueue_is_pending @ 112 NONAME
pj_ioqueue_name @ 113 NONAME
pj_ioqueue_op_key_init @ 114 NONAME
pj_ioqueue_poll @ 115 NONAME
pj_ioqueue_post_completion @ 116 NONAME
pj_ioqueue_recv @ 117 NONAME
pj_ioqueue_recvfrom @ 118 NONAME
pj_ioqueue_register_sock @ 119 NONAME
pj_ioqueue_send @ 120 NONAME
pj_ioqueue_sendto @ 121 NONAME
pj_ioqueue_set_lock @ 122 NONAME
pj_ioqueue_set_user_data @ 123 NONAME
pj_ioqueue_unregister @ 124 NONAME
pj_leave_critical_section @ 125 NONAME
pj_list_erase @ 126 NONAME
pj_list_find_node @ 127 NONAME
pj_list_insert_after @ 128 NONAME
pj_list_insert_before @ 129 NONAME
pj_list_insert_nodes_after @ 130 NONAME
pj_list_insert_nodes_before @ 131 NONAME
pj_list_merge_first @ 132 NONAME
pj_list_merge_last @ 133 NONAME
pj_list_search @ 134 NONAME
pj_list_size @ 135 NONAME
pj_lock_acquire @ 136 NONAME
pj_lock_create_null_mutex @ 137 NONAME
pj_lock_create_recursive_mutex @ 138 NONAME
pj_lock_create_semaphore @ 139 NONAME
pj_lock_create_simple_mutex @ 140 NONAME
pj_lock_destroy @ 141 NONAME
pj_lock_release @ 142 NONAME
pj_lock_tryacquire @ 143 NONAME
pj_log @ 144 NONAME
pj_log_1 @ 145 NONAME
pj_log_2 @ 146 NONAME
pj_log_3 @ 147 NONAME
pj_log_4 @ 148 NONAME
pj_log_5 @ 149 NONAME
pj_log_get_decor @ 150 NONAME
pj_log_get_level @ 151 NONAME
pj_log_get_log_func @ 152 NONAME
pj_log_set_decor @ 153 NONAME
pj_log_set_level @ 154 NONAME
pj_log_set_log_func @ 155 NONAME
pj_log_write @ 156 NONAME
pj_mutex_create @ 157 NONAME
pj_mutex_create_recursive @ 158 NONAME
pj_mutex_create_simple @ 159 NONAME
pj_mutex_destroy @ 160 NONAME
pj_mutex_lock @ 161 NONAME
pj_mutex_trylock @ 162 NONAME
pj_mutex_unlock @ 163 NONAME
pj_ntohl @ 164 NONAME
pj_ntohs @ 165 NONAME
pj_pool_alloc @ 166 NONAME
pj_pool_alloc_from_block @ 167 NONAME
pj_pool_allocate_find @ 168 NONAME
pj_pool_calloc @ 169 NONAME
pj_pool_create @ 170 NONAME
pj_pool_create_int @ 171 NONAME
pj_pool_create_on_buf @ 172 NONAME
pj_pool_destroy_int @ 173 NONAME
pj_pool_factory_default_policy @ 174 NONAME
pj_pool_factory_get_default_policy @ 175 NONAME
pj_pool_get_capacity @ 176 NONAME
pj_pool_get_used_size @ 177 NONAME
pj_pool_getobjname @ 178 NONAME
pj_pool_init_int @ 179 NONAME
pj_pool_release @ 180 NONAME
pj_pool_reset @ 181 NONAME
pj_rand @ 182 NONAME
pj_rbtree_erase @ 183 NONAME
pj_rbtree_find @ 184 NONAME
pj_rbtree_first @ 185 NONAME
pj_rbtree_init @ 186 NONAME
pj_rbtree_insert @ 187 NONAME
pj_rbtree_last @ 188 NONAME
pj_rbtree_max_height @ 189 NONAME
pj_rbtree_min_height @ 190 NONAME
pj_rbtree_next @ 191 NONAME
pj_rbtree_prev @ 192 NONAME
pj_register_strerror @ 193 NONAME
pj_rwmutex_create @ 194 NONAME
pj_rwmutex_destroy @ 195 NONAME
pj_rwmutex_lock_read @ 196 NONAME
pj_rwmutex_lock_write @ 197 NONAME
pj_rwmutex_unlock_read @ 198 NONAME
pj_rwmutex_unlock_write @ 199 NONAME
pj_sem_create @ 200 NONAME
pj_sem_destroy @ 201 NONAME
pj_sem_post @ 202 NONAME
pj_sem_trywait @ 203 NONAME
pj_sem_wait @ 204 NONAME
pj_set_netos_error @ 205 NONAME
pj_set_os_error @ 206 NONAME
pj_shutdown @ 207 NONAME
pj_sock_accept @ 208 NONAME
pj_sock_bind @ 209 NONAME
pj_sock_bind_in @ 210 NONAME
pj_sock_close @ 211 NONAME
pj_sock_connect @ 212 NONAME
pj_sock_getpeername @ 213 NONAME
pj_sock_getsockname @ 214 NONAME
pj_sock_getsockopt @ 215 NONAME
pj_sock_listen @ 216 NONAME
pj_sock_recv @ 217 NONAME
pj_sock_recvfrom @ 218 NONAME
pj_sock_select @ 219 NONAME
pj_sock_send @ 220 NONAME
pj_sock_sendto @ 221 NONAME
pj_sock_setsockopt @ 222 NONAME
pj_sock_shutdown @ 223 NONAME
pj_sock_socket @ 224 NONAME
pj_sockaddr_in_init @ 225 NONAME
pj_sockaddr_in_set_str_addr @ 226 NONAME
pj_srand @ 227 NONAME
pj_str @ 228 NONAME
pj_strassign @ 229 NONAME
pj_strcat @ 230 NONAME
pj_strcat2 @ 231 NONAME
pj_strcmp @ 232 NONAME
pj_strcmp2 @ 233 NONAME
pj_strcpy @ 234 NONAME
pj_strcpy2 @ 235 NONAME
pj_strdup @ 236 NONAME
pj_strdup2 @ 237 NONAME
pj_strdup2_with_null @ 238 NONAME
pj_strdup3 @ 239 NONAME
pj_strdup_with_null @ 240 NONAME
pj_strerror @ 241 NONAME
pj_stricmp @ 242 NONAME
pj_stricmp2 @ 243 NONAME
pj_strltrim @ 244 NONAME
pj_strncmp @ 245 NONAME
pj_strncmp2 @ 246 NONAME
pj_strncpy @ 247 NONAME
pj_strncpy_with_null @ 248 NONAME
pj_strnicmp @ 249 NONAME
pj_strnicmp2 @ 250 NONAME
pj_strrtrim @ 251 NONAME
pj_strtoul @ 252 NONAME
pj_strtoul2 @ 253 NONAME
pj_strtrim @ 254 NONAME
pj_symbianos_poll @ 255 NONAME
pj_thread_create @ 256 NONAME
pj_thread_destroy @ 257 NONAME
pj_thread_get_name @ 258 NONAME
pj_thread_join @ 259 NONAME
pj_thread_local_alloc @ 260 NONAME
pj_thread_local_free @ 261 NONAME
pj_thread_local_get @ 262 NONAME
pj_thread_local_set @ 263 NONAME
pj_thread_register @ 264 NONAME
pj_thread_resume @ 265 NONAME
pj_thread_sleep @ 266 NONAME
pj_thread_this @ 267 NONAME
pj_time_decode @ 268 NONAME
pj_time_encode @ 269 NONAME
pj_time_gmt_to_local @ 270 NONAME
pj_time_local_to_gmt @ 271 NONAME
pj_time_val_normalize @ 272 NONAME
pj_timer_entry_init @ 273 NONAME
pj_timer_heap_cancel @ 274 NONAME
pj_timer_heap_count @ 275 NONAME
pj_timer_heap_create @ 276 NONAME
pj_timer_heap_destroy @ 277 NONAME
pj_timer_heap_earliest_time @ 278 NONAME
pj_timer_heap_mem_size @ 279 NONAME
pj_timer_heap_poll @ 280 NONAME
pj_timer_heap_schedule @ 281 NONAME
pj_timer_heap_set_lock @ 282 NONAME
pj_timer_heap_set_max_timed_out_per_poll @ 283 NONAME
pj_unicode_to_ansi @ 284 NONAME
pj_utoa @ 285 NONAME
pj_utoa_pad @ 286 NONAME
platform_strerror @ 287 NONAME
snprintf @ 288 NONAME
vsnprintf @ 289 NONAME

View File

@ -8,6 +8,10 @@ SOURCEPATH ..\pjlib\src\pjlib-test
MACRO PJ_M_I386=1
MACRO PJ_SYMBIAN=1
#if defined(EKA2)
MACRO PJ_DLL
#endif
OPTION CW -lang c++
OPTION ARMCC --cpp
OPTION GCC -x c++

View File

@ -427,7 +427,7 @@ static int init(void)
for (i=0; i<2; ++i) {
pj_sockaddr_in addr;
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &g_server[i].sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &g_server[i].sock);
if (status != PJ_SUCCESS)
return -10;

View File

@ -305,7 +305,7 @@ PJ_DEF(pj_status_t) pj_dns_resolver_create( pj_pool_factory *pf,
pj_list_init(&resv->query_free_nodes);
/* Create the UDP socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &resv->udp_sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &resv->udp_sock);
if (status != PJ_SUCCESS)
goto on_error;

View File

@ -217,7 +217,7 @@ PJ_DECL(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
if (rec[i].srv[0].mapped_addr == rec[i].srv[1].mapped_addr &&
rec[i].srv[0].mapped_port == rec[i].srv[1].mapped_port)
{
mapped_addr[i].sin_family = PJ_AF_INET;
mapped_addr[i].sin_family = pj_AF_INET();
mapped_addr[i].sin_addr.s_addr = rec[i].srv[0].mapped_addr;
mapped_addr[i].sin_port = (pj_uint16_t)rec[i].srv[0].mapped_port;

View File

@ -25,8 +25,7 @@ export PJLIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
array.o config.o ctype.o errno.o except.o fifobuf.o guid.o \
hash.o ip_helper_generic.o list.o lock.o log.o os_time_common.o \
pool.o pool_buf.o pool_caching.o pool_dbg.o rand.o \
rbtree.o string.o timer.o \
types.o symbols.o
rbtree.o sock_common.o string.o timer.o types.o
export PJLIB_CFLAGS += $(_CFLAGS)
###############################################################################

View File

@ -40,6 +40,7 @@ RSC=rc.exe
# PROP Output_Dir ".\output\pjlib-i386-win32-vc6-release"
# PROP Intermediate_Dir ".\output\pjlib-i386-win32-vc6-release"
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W4 /Zi /O2 /Ob2 /I "../include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /c
# SUBTRACT CPP /YX
@ -64,6 +65,7 @@ LIB32=link.exe -lib
# PROP Output_Dir ".\output\pjlib-i386-win32-vc6-debug"
# PROP Intermediate_Dir ".\output\pjlib-i386-win32-vc6-debug"
# PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "PJ_WIN32" /D "PJ_M_I386" /FR /FD /GZ /c
# SUBTRACT CPP /YX
@ -331,6 +333,10 @@ SOURCE=..\src\pj\sock_bsd.c
# End Source File
# Begin Source File
SOURCE=..\src\pj\sock_common.c
# End Source File
# Begin Source File
SOURCE=..\src\pj\sock_select.c
# End Source File
# Begin Source File

View File

@ -915,6 +915,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\pj\sock_common.c"
>
</File>
<File
RelativePath="..\src\pj\sock_select.c"
>

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,10 @@
# define PJ_INLINE_SPECIFIER static __inline
#endif
#define PJ_EXPORT_DECL_SPECIFIER __declspec(dllexport)
#define PJ_EXPORT_DEF_SPECIFIER __declspec(dllexport)
#define PJ_IMPORT_DECL_SPECIFIER __declspec(dllimport)
#define PJ_THREAD_FUNC
#define PJ_NORETURN __declspec(noreturn)
#define PJ_ATTR_NORETURN

View File

@ -148,15 +148,11 @@ typedef unsigned int socklen_t;
#include <e32def.h>
#endif
/*
#if defined(PJ_EXPORTING)
# define PJ_EXPORT_IMPORT EXPORT_C
#elif defined(PJ_IMPORTING)
# define PJ_EXPORT_IMPORT IMPORT_C
#else
# error "Must define either PJ_EXPORTING or PJ_IMPORTING"
#endif
*/
#define PJ_EXPORT_DECL_SPECIFIER IMPORT_C
//#define PJ_EXPORT_DECL_SPECIFIER
#define PJ_EXPORT_DEF_SPECIFIER EXPORT_C
#define PJ_IMPORT_DECL_SPECIFIER IMPORT_C
#endif /* __PJ_COMPAT_OS_SYMBIAN_H__ */

View File

@ -656,6 +656,37 @@
* General macros.
*/
/**
* Guide for building dynamic link libraries (DLL).
*
* The libraries support generation of dynamic link libraries for
* Symbian ABIv2 target (.dso files, in S60 3rd Edition). Similar
* procedures may be applied for Win32 DLL too, with some modification.
*
* Macros related for building DLL/DSO files:
* - For platforms that supports dynamic link libraries generation,
* it must declare PJ_EXPORT_SPECIFIER macro which value contains
* the prefix to be added to symbol definition, to export this
* symbol in the DLL/DSO. For example, on Win32/Visual Studio, the
* value of this macro is "__declspec(dllexport)", and for ARM
* ABIv2/Symbian, the value is \a EXPORT_C.
* - For platforms that supports linking with dynamic link libraries,
* it must declare PJ_IMPORT_SPECIFIER macro which value contains
* the prefix to be added to symbol declaration, to import this
* symbol from a DLL/DSO. For example, on Win32/Visual Studio, the
* value of this macro is "__declspec(dllimport)", and for ARM
* ABIv2/Symbian, the value is \a IMPORT_C.
* - When PJLIB is built as DLL/DSO, both \a PJ_DLL and \a PJ_EXPORTING
* macros must be declared, so that PJ_EXPORT_SPECIFIER prefix will be
* added into function definition.
* - When application wants to link dynamically with PJLIB, then it
* must declare \a PJ_DLL macro when using/including PJLIB header,
* so that PJ_IMPORT_SPECIFIER is properly added into symbol
* declarations.
*
* When \a PJ_DLL macro is not declared, static linking is assumed.
*/
/**
* @def PJ_INLINE(type)
* @param type The return type of the function.
@ -663,11 +694,6 @@
*/
#define PJ_INLINE(type) PJ_INLINE_SPECIFIER type
/**
* @def PJ_DECL(type)
* @param type The return type of the function.
* Declare a function.
*/
/**
* @def PJ_DECL_NO_RETURN(type)
* @param type The return type of the function.
@ -682,38 +708,124 @@
* Mark end of declaration section in a header file.
*/
#ifdef __cplusplus
# define PJ_DECL(type) type
# define PJ_DECL_NO_RETURN(type) type PJ_NORETURN
# define PJ_IDECL_NO_RETURN(type) PJ_INLINE(type) PJ_NORETURN
# define PJ_BEGIN_DECL extern "C" {
# define PJ_END_DECL }
#else
# define PJ_DECL(type) extern type
# define PJ_DECL_NO_RETURN(type) PJ_NORETURN type
# define PJ_IDECL_NO_RETURN(type) PJ_NORETURN PJ_INLINE(type)
# define PJ_BEGIN_DECL
# define PJ_END_DECL
#endif
/**
* This macro declares platform/compiler specific specifier prefix
* to be added to symbol declaration to export the symbol when PJLIB
* is built as dynamic library.
*
* This macro should have been added by platform specific headers,
* if the platform supports building dynamic library target.
*/
#ifndef PJ_EXPORT_DECL_SPECIFIER
# define PJ_EXPORT_DECL_SPECIFIER
#endif
/**
* This macro declares platform/compiler specific specifier prefix
* to be added to symbol definition to export the symbol when PJLIB
* is built as dynamic library.
*
* This macro should have been added by platform specific headers,
* if the platform supports building dynamic library target.
*/
#ifndef PJ_EXPORT_DEF_SPECIFIER
# define PJ_EXPORT_DEF_SPECIFIER
#endif
/**
* This macro declares platform/compiler specific specifier prefix
* to be added to symbol declaration to import the symbol.
*
* This macro should have been added by platform specific headers,
* if the platform supports building dynamic library target.
*/
#ifndef PJ_IMPORT_DECL_SPECIFIER
# define PJ_IMPORT_DECL_SPECIFIER
#endif
/**
* This macro has been deprecated. It will evaluate to nothing.
*/
#ifndef PJ_EXPORT_SYMBOL
# define PJ_EXPORT_SYMBOL(x)
#endif
/**
* @def PJ_DECL(type)
* @param type The return type of the function.
* Declare a function.
*/
#if defined(PJ_DLL)
# if defined(PJ_EXPORTING)
# define PJ_DECL(type) PJ_EXPORT_DECL_SPECIFIER type
# else
# define PJ_DECL(type) PJ_IMPORT_DECL_SPECIFIER type
# endif
#elif !defined(PJ_DECL)
# if defined(__cplusplus)
# define PJ_DECL(type) type
# else
# define PJ_DECL(type) extern type
# endif
#endif
/**
* @def PJ_DEF(type)
* @param type The return type of the function.
* Define a function.
*/
#define PJ_DEF(type) type
#if defined(PJ_DLL) && defined(PJ_EXPORTING)
# define PJ_DEF(type) PJ_EXPORT_DEF_SPECIFIER type
#elif !defined(PJ_DEF)
# define PJ_DEF(type) type
#endif
/**
* @def PJ_EXPORT_SYMBOL(sym)
* @param sym The symbol to export.
* Export the specified symbol in compilation type that requires export
* (e.g. Linux kernel).
*/
#ifdef __PJ_EXPORT_SYMBOL
# define PJ_EXPORT_SYMBOL(sym) __PJ_EXPORT_SYMBOL(sym)
#else
# define PJ_EXPORT_SYMBOL(sym)
* @def PJ_DECL_DATA(type)
* @param type The data type.
* Declare a global data.
*/
#if defined(PJ_DLL)
# if defined(PJ_EXPORTING)
# define PJ_DECL_DATA(type) PJ_EXPORT_DECL_SPECIFIER extern type
# else
# define PJ_DECL_DATA(type) PJ_IMPORT_DECL_SPECIFIER extern type
# endif
#elif !defined(PJ_DECL_DATA)
# define PJ_DECL_DATA(type) extern type
#endif
/**
* @def PJ_DEF_DATA(type)
* @param type The data type.
* Define a global data.
*/
#if defined(PJ_DLL) && defined(PJ_EXPORTING)
# define PJ_DEF_DATA(type) PJ_EXPORT_DEF_SPECIFIER type
#elif !defined(PJ_DEF_DATA)
# define PJ_DEF_DATA(type) type
#endif
/**
* @def PJ_IDECL(type)
* @param type The function's return type.
@ -733,6 +845,7 @@
# define PJ_IDEF(type) PJ_DEF(type)
#endif
/**
* @def PJ_UNUSED_ARG(arg)
* @param arg The argument name.

View File

@ -352,11 +352,10 @@ PJ_DECL(pj_status_t) pj_register_strerror(pj_status_t start_code,
* - PJNATH_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
*/
PJ_END_DECL
/* Internal */
void pj_errno_clear_handlers(void);
PJ_END_DECL
#endif /* __PJ_ERRNO_H__ */

View File

@ -478,6 +478,9 @@ PJ_DECL(pj_status_t) pj_ioqueue_connect( pj_ioqueue_key_t *key,
/**
* Poll the I/O Queue for completed events.
*
* Note: polling the ioqueue is not necessary in Symbian. Please see
* @ref PJ_SYMBIAN_OS for more info.
*
* @param ioque the I/O Queue.
* @param timeout polling timeout, or NULL if the thread wishes to wait
* indefinetely for the event.

View File

@ -19,27 +19,13 @@
/* Internal */
PJ_IDEF(void) pj_link_node(pj_list_type *prev, pj_list_type *next)
PJ_INLINE(void) pj_link_node(pj_list_type *prev, pj_list_type *next)
{
((pj_list*)prev)->next = next;
((pj_list*)next)->prev = prev;
}
/*
PJ_IDEF(void)
pj_list_init(pj_list_type * node)
{
((pj_list*)node)->next = ((pj_list*)node)->prev = node;
}
PJ_IDEF(int) pj_list_empty(const pj_list_type * node)
{
return ((pj_list*)node)->next == node;
}
*/
PJ_IDEF(void)
pj_list_insert_after(pj_list_type *pos, pj_list_type *node)
PJ_IDEF(void) pj_list_insert_after(pj_list_type *pos, pj_list_type *node)
{
((pj_list*)node)->prev = pos;
((pj_list*)node)->next = ((pj_list*)pos)->next;
@ -48,15 +34,13 @@ pj_list_insert_after(pj_list_type *pos, pj_list_type *node)
}
PJ_IDEF(void)
pj_list_insert_before(pj_list_type *pos, pj_list_type *node)
PJ_IDEF(void) pj_list_insert_before(pj_list_type *pos, pj_list_type *node)
{
pj_list_insert_after(((pj_list*)pos)->prev, node);
}
PJ_IDEF(void)
pj_list_insert_nodes_after(pj_list_type *pos, pj_list_type *lst)
PJ_IDEF(void) pj_list_insert_nodes_after(pj_list_type *pos, pj_list_type *lst)
{
pj_list *lst_last = (pj_list *) ((pj_list*)lst)->prev;
pj_list *pos_next = (pj_list *) ((pj_list*)pos)->next;
@ -65,14 +49,12 @@ pj_list_insert_nodes_after(pj_list_type *pos, pj_list_type *lst)
pj_link_node(lst_last, pos_next);
}
PJ_IDEF(void)
pj_list_insert_nodes_before(pj_list_type *pos, pj_list_type *lst)
PJ_IDEF(void) pj_list_insert_nodes_before(pj_list_type *pos, pj_list_type *lst)
{
pj_list_insert_nodes_after(((pj_list*)pos)->prev, lst);
}
PJ_IDEF(void)
pj_list_merge_last(pj_list_type *lst1, pj_list_type *lst2)
PJ_IDEF(void) pj_list_merge_last(pj_list_type *lst1, pj_list_type *lst2)
{
if (!pj_list_empty(lst2)) {
pj_link_node(((pj_list*)lst1)->prev, ((pj_list*)lst2)->next);
@ -81,8 +63,7 @@ pj_list_merge_last(pj_list_type *lst1, pj_list_type *lst2)
}
}
PJ_IDEF(void)
pj_list_merge_first(pj_list_type *lst1, pj_list_type *lst2)
PJ_IDEF(void) pj_list_merge_first(pj_list_type *lst1, pj_list_type *lst2)
{
if (!pj_list_empty(lst2)) {
pj_link_node(((pj_list*)lst2)->prev, ((pj_list*)lst1)->next);
@ -91,15 +72,13 @@ pj_list_merge_first(pj_list_type *lst1, pj_list_type *lst2)
}
}
PJ_IDEF(void)
pj_list_erase(pj_list_type *node)
PJ_IDEF(void) pj_list_erase(pj_list_type *node)
{
pj_link_node( ((pj_list*)node)->prev, ((pj_list*)node)->next);
}
PJ_IDEF(pj_list_type*)
pj_list_find_node(pj_list_type *list, pj_list_type *node)
PJ_IDEF(pj_list_type*) pj_list_find_node(pj_list_type *list, pj_list_type *node)
{
pj_list *p = (pj_list *) ((pj_list*)list)->next;
while (p != list && p != node)
@ -109,9 +88,8 @@ pj_list_find_node(pj_list_type *list, pj_list_type *node)
}
PJ_IDEF(pj_list_type*)
pj_list_search(pj_list_type *list, void *value,
int (*comp)(void *value, const pj_list_type *node))
PJ_IDEF(pj_list_type*) pj_list_search(pj_list_type *list, void *value,
int (*comp)(void *value, const pj_list_type *node))
{
pj_list *p = (pj_list *) ((pj_list*)list)->next;
while (p != list && (*comp)(value, p) != 0)

View File

@ -174,10 +174,10 @@ PJ_DECL(void) pj_log_set_level(int level);
*
* @return Current log maximum level.
*/
#if 0
#if 1
PJ_DECL(int) pj_log_get_level(void);
#else
extern int pj_log_max_level;
PJ_DECL_DATA(int) pj_log_max_level;
#define pj_log_get_level() pj_log_max_level
#endif

View File

@ -234,6 +234,69 @@ PJ_DECL(pj_status_t) pj_thread_get_stack_info(pj_thread_t *thread,
* @}
*/
/* **************************************************************************/
/**
* @defgroup PJ_SYMBIAN_OS Symbian OS Specific
* @ingroup PJ_OS
* @{
* Functionalities specific to Symbian OS.
*
* Symbian OS strongly discourages the use of polling since this wastes
* CPU power, and instead provides Active Object and Active Scheduler
* pattern to allow application (in this case, PJLIB) to register asynchronous
* tasks. PJLIB port for Symbian complies to this recommended behavior.
* As the result, few things have been changed in PJLIB for Symbian:
* - the timer heap (see @ref PJ_TIMER) is implemented with active
* object framework, and each timer entry registered to the timer
* heap will register an Active Object to the Active Scheduler.
* Because of this, polling the timer heap with pj_timer_heap_poll()
* is no longer necessary, and this function will just evaluate
* to nothing.
* - the ioqueue (see @ref PJ_IOQUEUE) is also implemented with
* active object framework, with each asynchronous operation will
* register an Active Object to the Active Scheduler. Because of
* this, polling the ioqueue with pj_ioqueue_poll() is no longer
* necessary, and this function will just evaluate to nothing.
*
* Since timer heap and ioqueue polling are no longer necessary, Symbian
* application can now poll for all events by calling
* \a User::WaitForAnyRequest() and \a CActiveScheduler::RunIfReady().
* PJLIB provides a thin wrapper which calls these two functions,
* called pj_symbianos_poll().
*/
/**
* Wait the completion of any Symbian active objects. When the timeout
* value is not specified (the \a ms_timeout argument is -1), this
* function is a thin wrapper which calls \a User::WaitForAnyRequest()
* and \a CActiveScheduler::RunIfReady(). If the timeout value is
* specified, this function will schedule a timer entry to the timer
* heap (which is an Active Object), to limit the wait time for event
* occurences. Scheduling a timer entry is an expensive operation,
* therefore application should only specify a timeout value when it's
* really necessary (for example, when it's not sure there are other
* Active Objects currently running in the application).
*
* @param priority The minimum priority of the Active Objects to
* poll, which values are from CActive::TPriority
* constants. If -1 is given, CActive::EPriorityStandard.
* priority will be used.
* @param ms_timeout Optional timeout to wait. Application should
* specify -1 to let the function wait indefinitely
* for any events.
*
* @return PJ_TRUE if there have been any events executed
* during the polling. This function will only return
* PJ_FALSE if \a ms_timeout argument is specified
* (i.e. the value is not -1) and there was no event
* executed when the timeout timer elapsed.
*/
PJ_DECL(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout);
/**
* @}
*/
/* **************************************************************************/
/**
* @defgroup PJ_TLS Thread Local Storage.
@ -405,7 +468,7 @@ PJ_DECL(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
* Mutex types:
* - PJ_MUTEX_DEFAULT: default mutex type, which is system dependent.
* - PJ_MUTEX_SIMPLE: non-recursive mutex.
* - PJ_MUTEX_RECURSIVE: recursive mutex.
* - PJ_MUTEX_RECURSE: recursive mutex.
*/
typedef enum pj_mutex_type_e
{

View File

@ -227,9 +227,9 @@ PJ_BEGIN_DECL
return 1;
}
// Create the pool factory, in this case, a caching pool.
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy,
1024*1024 );
// Create the pool factory, in this case, a caching pool,
// using default pool policy.
pj_caching_pool_init(&cp, NULL, 1024*1024 );
// Do a demo
pool_demo_1(&cp.factory);
@ -505,8 +505,14 @@ PJ_INLINE(void*) pj_pool_zalloc(pj_pool_t *pool, pj_size_t size)
#define PJ_POOL_ZALLOC_T(pool,type) \
((type*)pj_pool_zalloc(pool, sizeof(type)))
/*
* Internal functions
*/
PJ_IDECL(void*) pj_pool_alloc_from_block(pj_pool_block *block, pj_size_t size);
PJ_DECL(void*) pj_pool_allocate_find(pj_pool_t *pool, unsigned size);
/**
* @} // PJ_POOL
*/
@ -617,8 +623,19 @@ extern int PJ_NO_MEMORY_EXCEPTION;
* - block allocation and deallocation use malloc() and free().
* - callback will raise PJ_NO_MEMORY_EXCEPTION exception.
* - access to pool factory is not serialized (i.e. not thread safe).
*
* @see pj_pool_factory_get_default_policy
*/
extern pj_pool_factory_policy pj_pool_factory_default_policy;
PJ_DECL_DATA(pj_pool_factory_policy) pj_pool_factory_default_policy;
/**
* Get the default pool factory policy.
*
* @return the pool policy.
*/
PJ_DECL(const pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void);
/**
* This structure contains the declaration for pool factory interface.

View File

@ -20,7 +20,6 @@
#include <pj/string.h>
PJ_DECL(void*) pj_pool_allocate_find(pj_pool_t *pool, unsigned size);
PJ_IDEF(pj_size_t) pj_pool_get_capacity( pj_pool_t *pool )
{

View File

@ -59,12 +59,18 @@ PJ_BEGIN_DECL
* APPLICATION MUST USE THESE VALUES INSTEAD OF NORMAL AF_*, BECAUSE
* THE LIBRARY WILL DO TRANSLATION TO THE NATIVE VALUE.
*/
extern const pj_uint16_t PJ_AF_UNIX; /**< Unix domain socket. */
#define PJ_AF_LOCAL PJ_AF_UNIX; /**< POSIX name for AF_UNIX */
extern const pj_uint16_t PJ_AF_INET; /**< Internet IP protocol. */
extern const pj_uint16_t PJ_AF_INET6; /**< IP version 6. */
extern const pj_uint16_t PJ_AF_PACKET; /**< Packet family. */
extern const pj_uint16_t PJ_AF_IRDA; /**< IRDA sockets. */
extern const pj_uint16_t PJ_AF_UNIX; /**< Unix domain socket. */
#define PJ_AF_LOCAL PJ_AF_UNIX; /**< POSIX name for AF_UNIX */
extern const pj_uint16_t PJ_AF_INET; /**< Internet IP protocol. */
extern const pj_uint16_t PJ_AF_INET6;/**< IP version 6. */
extern const pj_uint16_t PJ_AF_PACKET;/**< Packet family. */
extern const pj_uint16_t PJ_AF_IRDA; /**< IRDA sockets. */
PJ_DECL(pj_uint16_t) pj_AF_UNIX(void);
PJ_DECL(pj_uint16_t) pj_AF_INET(void);
PJ_DECL(pj_uint16_t) pj_AF_INET6(void);
PJ_DECL(pj_uint16_t) pj_AF_PACKET(void);
PJ_DECL(pj_uint16_t) pj_AF_IRDA(void);
/**
@ -74,14 +80,20 @@ extern const pj_uint16_t PJ_AF_IRDA; /**< IRDA sockets. */
*/
extern const pj_uint16_t PJ_SOCK_STREAM; /**< Sequenced, reliable, connection-
based byte streams. */
based byte streams. */
extern const pj_uint16_t PJ_SOCK_DGRAM; /**< Connectionless, unreliable
datagrams of fixed maximum
lengths. */
datagrams of fixed maximum
lengths. */
extern const pj_uint16_t PJ_SOCK_RAW; /**< Raw protocol interface. */
extern const pj_uint16_t PJ_SOCK_RDM; /**< Reliably-delivered messages. */
PJ_DECL(int) pj_SOCK_STREAM(void);
PJ_DECL(int) pj_SOCK_DGRAM(void);
PJ_DECL(int) pj_SOCK_RAW(void);
PJ_DECL(int) pj_SOCK_RDM(void);
/**
* Socket level specified in #pj_sock_setsockopt() or #pj_sock_getsockopt().
* APPLICATION MUST USE THESE VALUES INSTEAD OF NORMAL SOL_*, BECAUSE
@ -93,6 +105,12 @@ extern const pj_uint16_t PJ_SOL_TCP; /**< TCP level. */
extern const pj_uint16_t PJ_SOL_UDP; /**< UDP level. */
extern const pj_uint16_t PJ_SOL_IPV6; /**< IP version 6 */
PJ_DECL(pj_uint16_t) pj_SOL_SOCKET(void);
PJ_DECL(pj_uint16_t) pj_SOL_IP(void);
PJ_DECL(pj_uint16_t) pj_SOL_TCP(void);
PJ_DECL(pj_uint16_t) pj_SOL_UDP(void);
PJ_DECL(pj_uint16_t) pj_SOL_IPV6(void);
/* IP_TOS
*
@ -102,6 +120,7 @@ extern const pj_uint16_t PJ_SOL_IPV6; /**< IP version 6 */
*/
extern const pj_uint16_t PJ_IP_TOS; /**< IP_TOS optname in setsockopt() */
PJ_DECL(int) pj_IP_TOS(void);
/*
* IP TOS related constats.
@ -114,24 +133,37 @@ extern const pj_uint16_t PJ_IPTOS_LOWDELAY; /**< Minimize delays */
extern const pj_uint16_t PJ_IPTOS_THROUGHPUT; /**< Optimize throughput */
extern const pj_uint16_t PJ_IPTOS_RELIABILITY; /**< Optimize for reliability*/
extern const pj_uint16_t PJ_IPTOS_MINCOST; /**< "filler data" where slow
transmission does't matter */
transmission does't matter */
PJ_DECL(int) pj_IPTOS_LOWDELAY(void);
PJ_DECL(int) pj_IPTOS_THROUGHPUT(void);
PJ_DECL(int) pj_IPTOS_RELIABILITY(void);
PJ_DECL(int) pj_IPTOS_MINCOST(void);
/**
* Values to be specified as \c optname when calling #pj_sock_setsockopt()
* or #pj_sock_getsockopt().
*/
extern const pj_uint16_t PJ_SO_TYPE; /**< Socket type. */
extern const pj_uint16_t PJ_SO_RCVBUF; /**< Buffer size for receive. */
extern const pj_uint16_t PJ_SO_SNDBUF; /**< Buffer size for send. */
extern const pj_uint16_t PJ_SO_TYPE; /**< Socket type. */
extern const pj_uint16_t PJ_SO_RCVBUF;/**< Buffer size for receive. */
extern const pj_uint16_t PJ_SO_SNDBUF;/**< Buffer size for send. */
PJ_DECL(pj_uint16_t) pj_SO_TYPE(void);
PJ_DECL(pj_uint16_t) pj_SO_RCVBUF(void);
PJ_DECL(pj_uint16_t) pj_SO_SNDBUF(void);
/*
* Flags to be specified in #pj_sock_recv, #pj_sock_send, etc.
*/
extern const int PJ_MSG_OOB; /**< Out-of-band messages. */
extern const int PJ_MSG_PEEK; /**< Peek, don't remove from buffer. */
extern const int PJ_MSG_DONTROUTE; /**< Don't route. */
extern const int PJ_MSG_OOB; /**< Out-of-band messages. */
extern const int PJ_MSG_PEEK; /**< Peek, don't remove from buffer*/
extern const int PJ_MSG_DONTROUTE;/**< Don't route. */
PJ_DECL(int) pj_MSG_OOB(void);
PJ_DECL(int) pj_MSG_PEEK(void);
PJ_DECL(int) pj_MSG_DONTROUTE(void);
/**

View File

@ -66,6 +66,21 @@ typedef struct pj_fd_set_t
PJ_DECL(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp);
/**
* This is an internal function, application shouldn't use this.
*
* Get the number of descriptors in the set. This is defined in sock_select.c
* This function will only return the number of sockets set from PJ_FD_SET
* operation. When the set is modified by other means (such as by select()),
* the count will not be reflected here.
*
* @param fdsetp The descriptor set.
*
* @return Number of descriptors in the set.
*/
PJ_DECL(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp);
/**
* Add the file descriptor fd to the set pointed to by fdsetp.
* If the file descriptor fd is already in this set, there shall be no effect

View File

@ -253,6 +253,9 @@ PJ_DECL(pj_status_t) pj_timer_heap_earliest_time( pj_timer_heap_t *ht,
* Poll the timer heap, check for expired timers and call the callback for
* each of the expired timers.
*
* Note: polling the timer heap is not necessary in Symbian. Please see
* @ref PJ_SYMBIAN_OS for more info.
*
* @param ht The timer heap.
* @param next_delay If this parameter is not NULL, it will be filled up with
* the time delay until the next timer elapsed, or -1 in

View File

@ -302,7 +302,11 @@ PJ_DECL(pj_status_t) pj_init(void);
*/
PJ_DECL(void) pj_shutdown(void);
/**
* Type of callback to register to pj_atexit().
*/
typedef void (*pj_exit_callback)(void);
/**
* Register cleanup function to be called by PJLIB when pj_shutdown() is
* called.

View File

@ -83,7 +83,7 @@ PJ_DEF(pj_status_t) pj_gethostip(pj_in_addr *addr)
pj_sockaddr_in a;
int len;
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &fd);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &fd);
if (status != PJ_SUCCESS) {
return status;
}

View File

@ -76,7 +76,7 @@ PJ_DEF(pj_status_t) pj_gethostbyname(const pj_str_t *name, pj_hostent *he)
// Return hostent
he->h_name = resolved_name;
he->h_aliases = no_aliases;
he->h_addrtype = PJ_AF_INET;
he->h_addrtype = pj_AF_INET();
he->h_length = 4;
he->h_addr_list = (char**) addr_list;
@ -85,7 +85,7 @@ PJ_DEF(pj_status_t) pj_gethostbyname(const pj_str_t *name, pj_hostent *he)
/* Resolve the IP address of local machine */
pj_status_t pj_gethostip(pj_in_addr *addr)
PJ_DEF(pj_status_t) pj_gethostip(pj_in_addr *addr)
{
const pj_str_t *hostname = pj_gethostname();
struct pj_hostent he;
@ -111,7 +111,7 @@ pj_status_t pj_gethostip(pj_in_addr *addr)
pj_sockaddr_in a;
int len;
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &fd);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &fd);
if (status != PJ_SUCCESS) {
return status;
}

View File

@ -101,7 +101,7 @@ static int pjlib_error(pj_status_t code, char *buf, pj_size_t size)
#define IN_RANGE(val,start,end) ((val)>=(start) && (val)<(end))
/* Register strerror handle. */
PJ_DECL(pj_status_t) pj_register_strerror(pj_status_t start,
PJ_DEF(pj_status_t) pj_register_strerror( pj_status_t start,
pj_status_t space,
pjsip_error_callback f)
{

View File

@ -25,8 +25,7 @@
#define SZ sizeof(unsigned)
PJ_DEF(void)
pj_fifobuf_init (pj_fifobuf_t *fifobuf, void *buffer, unsigned size)
PJ_DEF(void) pj_fifobuf_init (pj_fifobuf_t *fifobuf, void *buffer, unsigned size)
{
PJ_CHECK_STACK();
@ -40,8 +39,7 @@ pj_fifobuf_init (pj_fifobuf_t *fifobuf, void *buffer, unsigned size)
fifobuf->full = 0;
}
PJ_DEF(unsigned)
pj_fifobuf_max_size (pj_fifobuf_t *fifobuf)
PJ_DEF(unsigned) pj_fifobuf_max_size (pj_fifobuf_t *fifobuf)
{
unsigned s1, s2;
@ -57,8 +55,7 @@ pj_fifobuf_max_size (pj_fifobuf_t *fifobuf)
return s1<s2 ? s2 : s1;
}
PJ_DEF(void*)
pj_fifobuf_alloc (pj_fifobuf_t *fifobuf, unsigned size)
PJ_DEF(void*) pj_fifobuf_alloc (pj_fifobuf_t *fifobuf, unsigned size)
{
unsigned available;
char *start;
@ -115,8 +112,7 @@ pj_fifobuf_alloc (pj_fifobuf_t *fifobuf, unsigned size)
return NULL;
}
PJ_DEF(pj_status_t)
pj_fifobuf_unalloc (pj_fifobuf_t *fifobuf, void *buf)
PJ_DEF(pj_status_t) pj_fifobuf_unalloc (pj_fifobuf_t *fifobuf, void *buf)
{
char *ptr = (char*)buf;
char *endptr;
@ -146,8 +142,7 @@ pj_fifobuf_unalloc (pj_fifobuf_t *fifobuf, void *buf)
return 0;
}
PJ_DEF(pj_status_t)
pj_fifobuf_free (pj_fifobuf_t *fifobuf, void *buf)
PJ_DEF(pj_status_t) pj_fifobuf_free (pj_fifobuf_t *fifobuf, void *buf)
{
char *ptr = (char*)buf;
char *end;

View File

@ -109,11 +109,13 @@ PJ_DEF(pj_status_t) pj_file_read( pj_oshandle_t fd,
return PJ_SUCCESS;
}
/*
PJ_DEF(pj_bool_t) pj_file_eof(pj_oshandle_t fd, enum pj_file_access access)
{
PJ_UNUSED_ARG(access);
return feof((FILE*)fd) ? PJ_TRUE : 0;
}
*/
PJ_DEF(pj_status_t) pj_file_setpos( pj_oshandle_t fd,
pj_off_t offset,

View File

@ -100,10 +100,10 @@ static pj_status_t ioqueue_init_key( pj_pool_t *pool,
* will be performed during send to allow parallel send operations.
*/
optlen = sizeof(key->fd_type);
rc = pj_sock_getsockopt(sock, PJ_SOL_SOCKET, PJ_SO_TYPE,
rc = pj_sock_getsockopt(sock, pj_SOL_SOCKET(), pj_SO_TYPE(),
&key->fd_type, &optlen);
if (rc != PJ_SUCCESS)
key->fd_type = PJ_SOCK_STREAM;
key->fd_type = pj_SOCK_STREAM();
/* Create mutex for the key. */
#if !PJ_IOQUEUE_HAS_SAFE_UNREG
@ -269,7 +269,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
/* For datagrams, we can remove the write_op from the list
* so that send() can work in parallel.
*/
if (h->fd_type == PJ_SOCK_DGRAM) {
if (h->fd_type == pj_SOCK_DGRAM()) {
pj_list_erase(write_op);
if (pj_list_empty(&h->write_list))
@ -315,12 +315,12 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h)
/* Are we finished with this buffer? */
if (send_rc!=PJ_SUCCESS ||
write_op->written == (pj_ssize_t)write_op->size ||
h->fd_type == PJ_SOCK_DGRAM)
h->fd_type == pj_SOCK_DGRAM())
{
write_op->op = PJ_IOQUEUE_OP_NONE;
if (h->fd_type != PJ_SOCK_DGRAM) {
if (h->fd_type != pj_SOCK_DGRAM()) {
/* Write completion of the whole stream. */
pj_list_erase(write_op);

View File

@ -64,22 +64,6 @@
# error "Error reporting must be enabled for this function to work!"
#endif
/**
* Get the number of descriptors in the set. This is defined in sock_select.c
* This function will only return the number of sockets set from PJ_FD_SET
* operation. When the set is modified by other means (such as by select()),
* the count will not be reflected here.
*
* That's why don't export this function in the header file, to avoid
* misunderstanding.
*
* @param fdsetp The descriptor set.
*
* @return Number of descriptors in the set.
*/
PJ_DECL(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp);
/*
* During debugging build, VALIDATE_FD_SET is set.
* This will check the validity of the fd_sets.

View File

@ -1106,7 +1106,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_accept( pj_ioqueue_key_t *key,
*/
op_key_rec = (union operation_key*)op_key->internal__;
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0,
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0,
&op_key_rec->accept.newsock);
if (status != PJ_SUCCESS)
return status;

View File

@ -24,7 +24,11 @@
#if PJ_LOG_MAX_LEVEL >= 1
PJ_DEF(int) pj_log_max_level = PJ_LOG_MAX_LEVEL;
#if 0
PJ_DEF_DATA(int) pj_log_max_level = PJ_LOG_MAX_LEVEL;
#else
static int pj_log_max_level = PJ_LOG_MAX_LEVEL;
#endif
static pj_log_func *log_writer = &pj_log_write;
static unsigned log_decor = PJ_LOG_HAS_TIME | PJ_LOG_HAS_MICRO_SEC |
PJ_LOG_HAS_SENDER | PJ_LOG_HAS_NEWLINE;
@ -48,7 +52,7 @@ PJ_DEF(void) pj_log_set_level(int level)
pj_log_max_level = level;
}
#if 0
#if 1
PJ_DEF(int) pj_log_get_level(void)
{
return pj_log_max_level;
@ -169,6 +173,7 @@ PJ_DEF(void) pj_log( const char *sender, int level,
(*log_writer)(level, log_buffer, len);
}
/*
PJ_DEF(void) pj_log_0(const char *obj, const char *format, ...)
{
va_list arg;
@ -176,6 +181,7 @@ PJ_DEF(void) pj_log_0(const char *obj, const char *format, ...)
pj_log(obj, 0, format, arg);
va_end(arg);
}
*/
PJ_DEF(void) pj_log_1(const char *obj, const char *format, ...)
{

View File

@ -260,8 +260,6 @@ PJ_DEF(pj_uint32_t) pj_getpid(void)
}
PJ_DECL(void) pj_shutdown(void);
/*
* pj_init(void).
* Init PJLIB!
@ -333,6 +331,94 @@ PJ_DEF(void) pj_shutdown(void)
os->Shutdown();
}
/////////////////////////////////////////////////////////////////////////////
class CPollTimeoutTimer : public CActive
{
public:
static CPollTimeoutTimer* NewL(int msec, TInt prio);
~CPollTimeoutTimer();
virtual void RunL();
virtual void DoCancel();
private:
RTimer rtimer_;
explicit CPollTimeoutTimer(TInt prio);
void ConstructL(int msec);
};
CPollTimeoutTimer::CPollTimeoutTimer(TInt prio)
: CActive(prio)
{
}
CPollTimeoutTimer::~CPollTimeoutTimer()
{
rtimer_.Close();
}
void CPollTimeoutTimer::ConstructL(int msec)
{
rtimer_.CreateLocal();
CActiveScheduler::Add(this);
rtimer_.After(iStatus, msec*1000);
SetActive();
}
CPollTimeoutTimer* CPollTimeoutTimer::NewL(int msec, TInt prio)
{
CPollTimeoutTimer *self = new CPollTimeoutTimer(prio);
CleanupStack::PushL(self);
self->ConstructL(msec);
CleanupStack::Pop(self);
return self;
}
void CPollTimeoutTimer::RunL()
{
}
void CPollTimeoutTimer::DoCancel()
{
rtimer_.Cancel();
}
/*
* Wait the completion of any Symbian active objects.
*/
PJ_DEF(pj_bool_t) pj_symbianos_poll(int priority, int ms_timeout)
{
CPollTimeoutTimer *timer = NULL;
if (priority==-1)
priority = CActive::EPriorityStandard;
if (ms_timeout >= 0) {
timer = CPollTimeoutTimer::NewL(ms_timeout, priority);
}
PjSymbianOS::Instance()->WaitForActiveObjects(priority);
if (timer) {
bool timer_is_active = timer->IsActive();
if (timer_is_active)
timer->Cancel();
delete timer;
return timer_is_active ? PJ_TRUE : PJ_FALSE;
} else {
return PJ_TRUE;
}
}
/*
* pj_thread_register(..)

View File

@ -220,7 +220,7 @@ public:
pj_sockaddr_in &pj_addr)
{
pj_bzero(&pj_addr, sizeof(pj_sockaddr_in));
pj_addr.sin_family = PJ_AF_INET;
pj_addr.sin_family = pj_AF_INET();
pj_addr.sin_addr.s_addr = pj_htonl(sym_addr.Address());
pj_addr.sin_port = pj_htons((pj_uint16_t) sym_addr.Port());
}

View File

@ -18,6 +18,8 @@
*/
#include <pj/os.h>
#include <pj/compat/time.h>
#include <pj/errno.h>
///////////////////////////////////////////////////////////////////////////////
@ -65,11 +67,19 @@ PJ_DEF(pj_status_t) pj_time_encode(const pj_parsed_time *pt, pj_time_val *tv)
/**
* Convert local time to GMT.
*/
PJ_DEF(pj_status_t) pj_time_local_to_gmt(pj_time_val *tv);
PJ_DEF(pj_status_t) pj_time_local_to_gmt(pj_time_val *tv)
{
PJ_UNUSED_ARG(tv);
return PJ_EBUG;
}
/**
* Convert GMT to local time.
*/
PJ_DEF(pj_status_t) pj_time_gmt_to_local(pj_time_val *tv);
PJ_DEF(pj_status_t) pj_time_gmt_to_local(pj_time_val *tv)
{
PJ_UNUSED_ARG(tv);
return PJ_EBUG;
}

View File

@ -65,6 +65,10 @@ PJ_DEF(void) pj_caching_pool_init( pj_caching_pool *cp,
for (i=0; i<PJ_CACHING_POOL_ARRAY_SIZE; ++i)
pj_list_init(&cp->free_list[i]);
if (policy == NULL) {
policy = &pj_pool_factory_default_policy;
}
pj_memcpy(&cp->factory.policy, policy, sizeof(pj_pool_factory_policy));
cp->factory.create_pool = &cpool_create_pool;
cp->factory.release_pool = &cpool_release_pool;

View File

@ -56,3 +56,8 @@ pj_pool_factory_policy pj_pool_factory_default_policy =
0
};
PJ_DEF(const pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void)
{
return &pj_pool_factory_default_policy;
}

View File

@ -86,7 +86,7 @@ static void default_pool_callback(pj_pool_t *pool, pj_size_t size)
PJ_THROW(PJ_NO_MEMORY_EXCEPTION);
}
pj_pool_factory_policy pj_pool_factory_default_policy =
PJ_DECL_DATA(pj_pool_factory_policy) pj_pool_factory_default_policy =
{
&default_block_alloc,
&default_block_free,
@ -94,4 +94,10 @@ pj_pool_factory_policy pj_pool_factory_default_policy =
0
};
PJ_DEF(const pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void)
{
return &pj_pool_factory_default_policy;
}
#endif /* PJ_HAS_POOL_ALT_API */

View File

@ -77,19 +77,19 @@ static void default_pool_callback(pj_pool_t *pool, pj_size_t size)
PJ_THROW(PJ_NO_MEMORY_EXCEPTION);
}
pj_pool_factory_policy pj_pool_factory_default_policy =
PJ_DEF_DATA(pj_pool_factory_policy) pj_pool_factory_default_policy =
{
&operator_new,
&operator_delete,
&default_pool_callback,
0
};
PJ_DEF(pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void)
PJ_DEF(const pj_pool_factory_policy*) pj_pool_factory_get_default_policy(void)
{
return &pj_pool_factory_default_policy;
}
#endif /* PJ_HAS_POOL_ALT_API */

145
pjlib/src/pj/sock_common.c Normal file
View File

@ -0,0 +1,145 @@
/* $Id$ */
/*
* Copyright (C)2003-2007 Benny Prijono <benny@prijono.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pj/sock.h>
PJ_DEF(pj_uint16_t) pj_AF_UNIX(void)
{
return PJ_AF_UNIX;
}
PJ_DEF(pj_uint16_t) pj_AF_INET(void)
{
return PJ_AF_INET;
}
PJ_DEF(pj_uint16_t) pj_AF_INET6(void)
{
return PJ_AF_INET6;
}
PJ_DEF(pj_uint16_t) pj_AF_PACKET(void)
{
return PJ_AF_PACKET;
}
PJ_DEF(pj_uint16_t) pj_AF_IRDA(void)
{
return PJ_AF_IRDA;
}
PJ_DEF(int) pj_SOCK_STREAM(void)
{
return PJ_SOCK_STREAM;
}
PJ_DEF(int) pj_SOCK_DGRAM(void)
{
return PJ_SOCK_DGRAM;
}
PJ_DEF(int) pj_SOCK_RAW(void)
{
return PJ_SOCK_RAW;
}
PJ_DEF(int) pj_SOCK_RDM(void)
{
return PJ_SOCK_RDM;
}
PJ_DEF(pj_uint16_t) pj_SOL_SOCKET(void)
{
return PJ_SOL_SOCKET;
}
PJ_DEF(pj_uint16_t) pj_SOL_IP(void)
{
return PJ_SOL_IP;
}
PJ_DEF(pj_uint16_t) pj_SOL_TCP(void)
{
return PJ_SOL_TCP;
}
PJ_DEF(pj_uint16_t) pj_SOL_UDP(void)
{
return PJ_SOL_UDP;
}
PJ_DEF(pj_uint16_t) pj_SOL_IPV6(void)
{
return PJ_SOL_IPV6;
}
PJ_DEF(int) pj_IP_TOS(void)
{
return PJ_IP_TOS;
}
PJ_DEF(int) pj_IPTOS_LOWDELAY(void)
{
return PJ_IPTOS_LOWDELAY;
}
PJ_DEF(int) pj_IPTOS_THROUGHPUT(void)
{
return PJ_IPTOS_THROUGHPUT;
}
PJ_DEF(int) pj_IPTOS_RELIABILITY(void)
{
return PJ_IPTOS_RELIABILITY;
}
PJ_DEF(int) pj_IPTOS_MINCOST(void)
{
return PJ_IPTOS_MINCOST;
}
PJ_DEF(pj_uint16_t) pj_SO_TYPE(void)
{
return PJ_SO_TYPE;
}
PJ_DEF(pj_uint16_t) pj_SO_RCVBUF(void)
{
return PJ_SO_RCVBUF;
}
PJ_DEF(pj_uint16_t) pj_SO_SNDBUF(void)
{
return PJ_SO_SNDBUF;
}
PJ_DEF(int) pj_MSG_OOB(void)
{
return PJ_MSG_OOB;
}
PJ_DEF(int) pj_MSG_PEEK(void)
{
return PJ_MSG_PEEK;
}
PJ_DEF(int) pj_MSG_DONTROUTE(void)
{
return PJ_MSG_DONTROUTE;
}

View File

@ -52,11 +52,22 @@ const pj_uint16_t PJ_SOL_TCP = 0xFFFF;
const pj_uint16_t PJ_SOL_UDP = 0xFFFF;
const pj_uint16_t PJ_SOL_IPV6 = 0xFFFF;
/* TOS */
const pj_uint16_t PJ_IP_TOS = 0;
const pj_uint16_t PJ_IPTOS_LOWDELAY = 0;
const pj_uint16_t PJ_IPTOS_THROUGHPUT = 0;
const pj_uint16_t PJ_IPTOS_RELIABILITY = 0;
const pj_uint16_t PJ_IPTOS_MINCOST = 0;
/* ioctl() is also not supported. */
const pj_uint16_t PJ_SO_TYPE = 0xFFFF;
const pj_uint16_t PJ_SO_RCVBUF = 0xFFFF;
const pj_uint16_t PJ_SO_SNDBUF = 0xFFFF;
/* Flags */
const int PJ_MSG_OOB = 0;
const int PJ_MSG_PEEK = KSockReadPeek;
const int PJ_MSG_DONTROUTE = 0;
/////////////////////////////////////////////////////////////////////////////
//
@ -455,9 +466,9 @@ PJ_DEF(pj_status_t) pj_sock_socket(int af,
/* Set proto if none is specified. */
if (proto == 0) {
if (type == PJ_SOCK_STREAM)
if (type == pj_SOCK_STREAM())
proto = KProtocolInetTcp;
else if (type == PJ_SOCK_DGRAM)
else if (type == pj_SOCK_DGRAM())
proto = KProtocolInetUdp;
}

View File

@ -19,7 +19,7 @@
#include <pj/types.h>
#include <pj/os.h>
void pj_time_val_normalize(pj_time_val *t)
PJ_DEF(void) pj_time_val_normalize(pj_time_val *t)
{
PJ_CHECK_STACK();

View File

@ -65,7 +65,7 @@ static int echo_client_thread(void *arg)
pj_status_t last_recv_err = PJ_SUCCESS, last_send_err = PJ_SUCCESS;
unsigned counter = 0;
rc = app_socket(PJ_AF_INET, client->sock_type, 0, -1, &sock);
rc = app_socket(pj_AF_INET(), client->sock_type, 0, -1, &sock);
if (rc != PJ_SUCCESS) {
app_perror("...unable to create socket", rc);
return -10;

View File

@ -275,7 +275,7 @@ static int perform_test(int sock_type, const char *type_name,
/* Create socket pair. */
TRACE_((THIS_FILE, " calling socketpair.."));
rc = app_socketpair(PJ_AF_INET, sock_type, 0,
rc = app_socketpair(pj_AF_INET(), sock_type, 0,
&items[i].server_fd, &items[i].client_fd);
if (rc != PJ_SUCCESS) {
app_perror("...error: unable to create socket pair", rc);
@ -451,49 +451,49 @@ int ioqueue_perf_test(void)
int sockpair_cnt;
} test_param[] =
{
{ PJ_SOCK_DGRAM, "udp", 1, 1},
{ PJ_SOCK_DGRAM, "udp", 1, 2},
{ PJ_SOCK_DGRAM, "udp", 1, 4},
{ PJ_SOCK_DGRAM, "udp", 1, 8},
{ PJ_SOCK_DGRAM, "udp", 2, 1},
{ PJ_SOCK_DGRAM, "udp", 2, 2},
{ PJ_SOCK_DGRAM, "udp", 2, 4},
{ PJ_SOCK_DGRAM, "udp", 2, 8},
{ PJ_SOCK_DGRAM, "udp", 4, 1},
{ PJ_SOCK_DGRAM, "udp", 4, 2},
{ PJ_SOCK_DGRAM, "udp", 4, 4},
{ PJ_SOCK_DGRAM, "udp", 4, 8},
{ PJ_SOCK_DGRAM, "udp", 4, 16},
{ PJ_SOCK_STREAM, "tcp", 1, 1},
{ PJ_SOCK_STREAM, "tcp", 1, 2},
{ PJ_SOCK_STREAM, "tcp", 1, 4},
{ PJ_SOCK_STREAM, "tcp", 1, 8},
{ PJ_SOCK_STREAM, "tcp", 2, 1},
{ PJ_SOCK_STREAM, "tcp", 2, 2},
{ PJ_SOCK_STREAM, "tcp", 2, 4},
{ PJ_SOCK_STREAM, "tcp", 2, 8},
{ PJ_SOCK_STREAM, "tcp", 4, 1},
{ PJ_SOCK_STREAM, "tcp", 4, 2},
{ PJ_SOCK_STREAM, "tcp", 4, 4},
{ PJ_SOCK_STREAM, "tcp", 4, 8},
{ PJ_SOCK_STREAM, "tcp", 4, 16},
{ pj_SOCK_DGRAM(), "udp", 1, 1},
{ pj_SOCK_DGRAM(), "udp", 1, 2},
{ pj_SOCK_DGRAM(), "udp", 1, 4},
{ pj_SOCK_DGRAM(), "udp", 1, 8},
{ pj_SOCK_DGRAM(), "udp", 2, 1},
{ pj_SOCK_DGRAM(), "udp", 2, 2},
{ pj_SOCK_DGRAM(), "udp", 2, 4},
{ pj_SOCK_DGRAM(), "udp", 2, 8},
{ pj_SOCK_DGRAM(), "udp", 4, 1},
{ pj_SOCK_DGRAM(), "udp", 4, 2},
{ pj_SOCK_DGRAM(), "udp", 4, 4},
{ pj_SOCK_DGRAM(), "udp", 4, 8},
{ pj_SOCK_DGRAM(), "udp", 4, 16},
{ pj_SOCK_STREAM(), "tcp", 1, 1},
{ pj_SOCK_STREAM(), "tcp", 1, 2},
{ pj_SOCK_STREAM(), "tcp", 1, 4},
{ pj_SOCK_STREAM(), "tcp", 1, 8},
{ pj_SOCK_STREAM(), "tcp", 2, 1},
{ pj_SOCK_STREAM(), "tcp", 2, 2},
{ pj_SOCK_STREAM(), "tcp", 2, 4},
{ pj_SOCK_STREAM(), "tcp", 2, 8},
{ pj_SOCK_STREAM(), "tcp", 4, 1},
{ pj_SOCK_STREAM(), "tcp", 4, 2},
{ pj_SOCK_STREAM(), "tcp", 4, 4},
{ pj_SOCK_STREAM(), "tcp", 4, 8},
{ pj_SOCK_STREAM(), "tcp", 4, 16},
/*
{ PJ_SOCK_DGRAM, "udp", 32, 1},
{ PJ_SOCK_DGRAM, "udp", 32, 1},
{ PJ_SOCK_DGRAM, "udp", 32, 1},
{ PJ_SOCK_DGRAM, "udp", 32, 1},
{ PJ_SOCK_DGRAM, "udp", 1, 32},
{ PJ_SOCK_DGRAM, "udp", 1, 32},
{ PJ_SOCK_DGRAM, "udp", 1, 32},
{ PJ_SOCK_DGRAM, "udp", 1, 32},
{ PJ_SOCK_STREAM, "tcp", 32, 1},
{ PJ_SOCK_STREAM, "tcp", 32, 1},
{ PJ_SOCK_STREAM, "tcp", 32, 1},
{ PJ_SOCK_STREAM, "tcp", 32, 1},
{ PJ_SOCK_STREAM, "tcp", 1, 32},
{ PJ_SOCK_STREAM, "tcp", 1, 32},
{ PJ_SOCK_STREAM, "tcp", 1, 32},
{ PJ_SOCK_STREAM, "tcp", 1, 32},
{ pj_SOCK_DGRAM(), "udp", 32, 1},
{ pj_SOCK_DGRAM(), "udp", 32, 1},
{ pj_SOCK_DGRAM(), "udp", 32, 1},
{ pj_SOCK_DGRAM(), "udp", 32, 1},
{ pj_SOCK_DGRAM(), "udp", 1, 32},
{ pj_SOCK_DGRAM(), "udp", 1, 32},
{ pj_SOCK_DGRAM(), "udp", 1, 32},
{ pj_SOCK_DGRAM(), "udp", 1, 32},
{ pj_SOCK_STREAM(), "tcp", 32, 1},
{ pj_SOCK_STREAM(), "tcp", 32, 1},
{ pj_SOCK_STREAM(), "tcp", 32, 1},
{ pj_SOCK_STREAM(), "tcp", 32, 1},
{ pj_SOCK_STREAM(), "tcp", 1, 32},
{ pj_SOCK_STREAM(), "tcp", 1, 32},
{ pj_SOCK_STREAM(), "tcp", 1, 32},
{ pj_SOCK_STREAM(), "tcp", 1, 32},
*/
};
pj_size_t best_bandwidth;

View File

@ -50,6 +50,7 @@ static pj_ssize_t callback_read_size,
callback_write_size,
callback_accept_status,
callback_connect_status;
static unsigned callback_call_count;
static pj_ioqueue_key_t *callback_read_key,
*callback_write_key,
*callback_accept_key,
@ -65,6 +66,7 @@ static void on_ioqueue_read(pj_ioqueue_key_t *key,
callback_read_key = key;
callback_read_op = op_key;
callback_read_size = bytes_read;
callback_call_count++;
}
static void on_ioqueue_write(pj_ioqueue_key_t *key,
@ -74,6 +76,7 @@ static void on_ioqueue_write(pj_ioqueue_key_t *key,
callback_write_key = key;
callback_write_op = op_key;
callback_write_size = bytes_written;
callback_call_count++;
}
static void on_ioqueue_accept(pj_ioqueue_key_t *key,
@ -96,6 +99,7 @@ static void on_ioqueue_accept(pj_ioqueue_key_t *key,
callback_accept_key = key;
callback_accept_op = op_key;
callback_accept_status = status;
callback_call_count++;
}
}
@ -103,6 +107,7 @@ static void on_ioqueue_connect(pj_ioqueue_key_t *key, int status)
{
callback_connect_key = key;
callback_connect_status = status;
callback_call_count++;
}
static pj_ioqueue_callback test_cb =
@ -168,7 +173,12 @@ static int send_recv_test(pj_ioqueue_t *ioque,
status = 0;
while (pending_op > 0) {
timeout.sec = 1; timeout.msec = 0;
#ifdef PJ_SYMBIAN
PJ_UNUSED_ARG(ioque);
status = pj_symbianos_poll(-1, 1000);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status > 0) {
if (callback_read_size) {
if (callback_read_size != bufsize)
@ -197,7 +207,11 @@ static int send_recv_test(pj_ioqueue_t *ioque,
// Pending op is zero.
// Subsequent poll should yield zero too.
timeout.sec = timeout.msec = 0;
#ifdef PJ_SYMBIAN
status = pj_symbianos_poll(-1, 1);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status != 0)
return -173;
@ -226,7 +240,7 @@ static int compliance_test_0(void)
pj_pool_t *pool = NULL;
char *send_buf, *recv_buf;
pj_ioqueue_t *ioque = NULL;
pj_ioqueue_key_t *skey, *ckey0, *ckey1;
pj_ioqueue_key_t *skey=NULL, *ckey0=NULL, *ckey1=NULL;
pj_ioqueue_op_key_t accept_op;
int bufsize = BUF_MIN_SIZE;
pj_ssize_t status = -1;
@ -243,13 +257,13 @@ static int compliance_test_0(void)
recv_buf = (char*)pj_pool_alloc(pool, bufsize);
// Create server socket and client socket for connecting
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &ssock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &ssock);
if (rc != PJ_SUCCESS) {
app_perror("...error creating socket", rc);
status=-1; goto on_error;
}
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &csock1);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &csock1);
if (rc != PJ_SUCCESS) {
app_perror("...error creating socket", rc);
status=-1; goto on_error;
@ -321,6 +335,7 @@ static int compliance_test_0(void)
// Poll until connected
callback_read_size = callback_write_size = 0;
callback_accept_status = callback_connect_status = -2;
callback_call_count = 0;
callback_read_key = callback_write_key =
callback_accept_key = callback_connect_key = NULL;
@ -329,7 +344,13 @@ static int compliance_test_0(void)
while (pending_op) {
pj_time_val timeout = {1, 0};
status=pj_ioqueue_poll(ioque, &timeout);
#ifdef PJ_SYMBIAN
callback_call_count = 0;
pj_symbianos_poll(-1, 1000);
status = callback_call_count;
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status > 0) {
if (callback_accept_status != -2) {
if (callback_accept_status != 0) {
@ -373,7 +394,11 @@ static int compliance_test_0(void)
// When we poll the ioqueue, there must not be events.
if (pending_op == 0) {
pj_time_val timeout = {1, 0};
#ifdef PJ_SYMBIAN
status = pj_symbianos_poll(-1, 1000);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status != 0) {
status=-60; goto on_error;
}
@ -407,12 +432,21 @@ static int compliance_test_0(void)
status = 0;
on_error:
if (ssock != PJ_INVALID_SOCKET)
if (skey != NULL)
pj_ioqueue_unregister(skey);
else if (ssock != PJ_INVALID_SOCKET)
pj_sock_close(ssock);
if (csock1 != PJ_INVALID_SOCKET)
if (ckey1 != NULL)
pj_ioqueue_unregister(ckey1);
else if (csock1 != PJ_INVALID_SOCKET)
pj_sock_close(csock1);
if (csock0 != PJ_INVALID_SOCKET)
if (ckey0 != NULL)
pj_ioqueue_unregister(ckey0);
else if (csock0 != PJ_INVALID_SOCKET)
pj_sock_close(csock0);
if (ioque != NULL)
pj_ioqueue_destroy(ioque);
pj_pool_release(pool);
@ -426,11 +460,11 @@ on_error:
*/
static int compliance_test_1(void)
{
pj_sock_t csock1=-1;
pj_sock_t csock1=PJ_INVALID_SOCKET;
pj_sockaddr_in addr;
pj_pool_t *pool = NULL;
pj_ioqueue_t *ioque = NULL;
pj_ioqueue_key_t *ckey1;
pj_ioqueue_key_t *ckey1 = NULL;
pj_ssize_t status = -1;
int pending_op = 0;
pj_str_t s;
@ -446,7 +480,7 @@ static int compliance_test_1(void)
}
// Create client socket
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &csock1);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &csock1);
if (rc != PJ_SUCCESS) {
app_perror("...ERROR in pj_sock_socket()", rc);
status=-1; goto on_error;
@ -483,7 +517,13 @@ static int compliance_test_1(void)
while (pending_op) {
pj_time_val timeout = {1, 0};
status=pj_ioqueue_poll(ioque, &timeout);
#ifdef PJ_SYMBIAN
callback_call_count = 0;
pj_symbianos_poll(-1, 1000);
status = callback_call_count;
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status > 0) {
if (callback_connect_key==ckey1) {
if (callback_connect_status == 0) {
@ -512,7 +552,11 @@ static int compliance_test_1(void)
// When we poll the ioqueue, there must not be events.
if (pending_op == 0) {
pj_time_val timeout = {1, 0};
#ifdef PJ_SYMBIAN
status = pj_symbianos_poll(-1, 1000);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status != 0) {
status=-60; goto on_error;
}
@ -522,8 +566,11 @@ static int compliance_test_1(void)
status = 0;
on_error:
if (csock1 != PJ_INVALID_SOCKET)
if (ckey1 != NULL)
pj_ioqueue_unregister(ckey1);
else if (csock1 != PJ_INVALID_SOCKET)
pj_sock_close(csock1);
if (ioque != NULL)
pj_ioqueue_destroy(ioque);
pj_pool_release(pool);
@ -576,6 +623,19 @@ static int compliance_test_2(void)
pj_str_t s;
pj_status_t rc;
listener.sock = PJ_INVALID_SOCKET;
listener.key = NULL;
for (i=0; i<MAX_PAIR; ++i) {
server[i].sock = PJ_INVALID_SOCKET;
server[i].key = NULL;
}
for (i=0; i<MAX_PAIR; ++i) {
client[i].sock = PJ_INVALID_SOCKET;
client[i].key = NULL;
}
// Create pool.
pool = pj_pool_create(mem, NULL, POOL_SIZE, 4000, NULL);
@ -593,7 +653,7 @@ static int compliance_test_2(void)
recv_buf = (char*)pj_pool_alloc(pool, bufsize);
// Create listener socket
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &listener.sock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &listener.sock);
if (rc != PJ_SUCCESS) {
app_perror("...error creating socket", rc);
status=-20; goto on_error;
@ -635,7 +695,7 @@ static int compliance_test_2(void)
for (test_loop=0; test_loop < TEST_LOOP; ++test_loop) {
// Client connect and server accept.
for (i=0; i<MAX_PAIR; ++i) {
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &client[i].sock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &client[i].sock);
if (rc != PJ_SUCCESS) {
app_perror("...error creating socket", rc);
status=-70; goto on_error;
@ -683,7 +743,11 @@ static int compliance_test_2(void)
while (pending_op) {
pj_time_val timeout = {1, 0};
status=pj_ioqueue_poll(ioque, &timeout);
#ifdef PJ_SYMBIAN
status = pj_symbianos_poll(-1, 1000);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status > 0) {
if (status > pending_op) {
PJ_LOG(3,(THIS_FILE,
@ -704,7 +768,11 @@ static int compliance_test_2(void)
// When we poll the ioqueue, there must not be events.
if (pending_op == 0) {
pj_time_val timeout = {1, 0};
#ifdef PJ_SYMBIAN
status = pj_symbianos_poll(-1, 1000);
#else
status = pj_ioqueue_poll(ioque, &timeout);
#endif
if (status != 0) {
status=-120; goto on_error;
}
@ -719,7 +787,7 @@ static int compliance_test_2(void)
}
// Check addresses
if (server[i].local_addr.sin_family != PJ_AF_INET ||
if (server[i].local_addr.sin_family != pj_AF_INET() ||
server[i].local_addr.sin_addr.s_addr == 0 ||
server[i].local_addr.sin_port == 0)
{
@ -728,7 +796,7 @@ static int compliance_test_2(void)
goto on_error;
}
if (server[i].rem_addr.sin_family != PJ_AF_INET ||
if (server[i].rem_addr.sin_family != pj_AF_INET() ||
server[i].rem_addr.sin_addr.s_addr == 0 ||
server[i].rem_addr.sin_port == 0)
{

View File

@ -133,7 +133,7 @@ static int compliance_test(void)
pj_pool_t *pool = NULL;
char *send_buf, *recv_buf;
pj_ioqueue_t *ioque = NULL;
pj_ioqueue_key_t *skey, *ckey;
pj_ioqueue_key_t *skey = NULL, *ckey = NULL;
pj_ioqueue_op_key_t read_op, write_op;
int bufsize = BUF_MIN_SIZE;
pj_ssize_t bytes, status = -1;
@ -152,9 +152,9 @@ static int compliance_test(void)
// Allocate sockets for sending and receiving.
TRACE_("creating sockets...");
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &ssock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &ssock);
if (rc==PJ_SUCCESS)
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &csock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &csock);
else
csock = PJ_INVALID_SOCKET;
if (rc != PJ_SUCCESS) {
@ -165,7 +165,7 @@ static int compliance_test(void)
// Bind server socket.
TRACE_("bind socket...");
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_port = pj_htons(PORT);
if (pj_sock_bind(ssock, &addr, sizeof(addr))) {
status=-10; goto on_error;
@ -258,7 +258,11 @@ static int compliance_test(void)
pj_time_val timeout = { 5, 0 };
TRACE_("poll...");
#ifdef PJ_SYMBIAN
rc = pj_symbianos_poll(-1, 5000);
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
if (rc == 0) {
PJ_LOG(1,(THIS_FILE, "...ERROR: timed out..."));
@ -285,7 +289,7 @@ static int compliance_test(void)
if (addrlen != sizeof(pj_sockaddr_in)) {
status=-68; goto on_error;
}
if (addr.sin_family != PJ_AF_INET) {
if (addr.sin_family != pj_AF_INET()) {
status=-69; goto on_error;
}
@ -312,10 +316,16 @@ static int compliance_test(void)
status = 0;
on_error:
if (ssock)
if (skey)
pj_ioqueue_unregister(skey);
else if (ssock != -1)
pj_sock_close(ssock);
if (csock)
if (ckey)
pj_ioqueue_unregister(ckey);
else if (csock != -1)
pj_sock_close(csock);
if (ioque != NULL)
pj_ioqueue_destroy(ioque);
pj_pool_release(pool);
@ -372,14 +382,14 @@ static int unregister_test(void)
}
/* Create sender socket */
status = app_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, SPORT, &ssock);
status = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, SPORT, &ssock);
if (status != PJ_SUCCESS) {
app_perror("Error initializing socket", status);
return -120;
}
/* Create receiver socket. */
status = app_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, RPORT, &rsock);
status = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, RPORT, &rsock);
if (status != PJ_SUCCESS) {
app_perror("Error initializing socket", status);
return -130;
@ -435,7 +445,11 @@ static int unregister_test(void)
/* Check if packet is received. */
timeout.sec = 1; timeout.msec = 0;
#ifdef PJ_SYMBIAN
pj_symbianos_poll(-1, 1000);
#else
pj_ioqueue_poll(ioqueue, &timeout);
#endif
if (packet_cnt != 1) {
return -180;
@ -469,8 +483,12 @@ static int unregister_test(void)
pj_ioqueue_unregister(key);
/* Poll ioqueue. */
#ifdef PJ_SYMBIAN
pj_symbianos_poll(-1, 1000);
#else
timeout.sec = 1; timeout.msec = 0;
pj_ioqueue_poll(ioqueue, &timeout);
#endif
/* Must NOT receive any packets after socket is closed! */
if (packet_cnt > 0) {
@ -524,7 +542,7 @@ static int many_handles_test(void)
/* Register as many sockets. */
for (count=0; count<MAX; ++count) {
sock[count] = PJ_INVALID_SOCKET;
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[count]);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock[count]);
if (rc != PJ_SUCCESS || sock[count] == PJ_INVALID_SOCKET) {
PJ_LOG(3,(THIS_FILE, "....unable to create %d-th socket, rc=%d",
count, rc));
@ -591,7 +609,7 @@ static int bench_test(int bufsize, int inactive_sock_count)
pj_ioqueue_op_key_t *inactive_read_op;
char *send_buf, *recv_buf;
pj_ioqueue_t *ioque = NULL;
pj_ioqueue_key_t *skey, *ckey, *key;
pj_ioqueue_key_t *skey, *ckey, *keys[SOCK_INACTIVE_MAX+2];
pj_timestamp t1, t2, t_elapsed;
int rc=0, i; /* i must be signed */
pj_str_t temp;
@ -607,9 +625,9 @@ static int bench_test(int bufsize, int inactive_sock_count)
recv_buf = (char*)pj_pool_alloc(pool, bufsize);
// Allocate sockets for sending and receiving.
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &ssock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &ssock);
if (rc == PJ_SUCCESS) {
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &csock);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &csock);
} else
csock = PJ_INVALID_SOCKET;
if (rc != PJ_SUCCESS) {
@ -619,7 +637,7 @@ static int bench_test(int bufsize, int inactive_sock_count)
// Bind server socket.
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_port = pj_htons(PORT);
if (pj_sock_bind(ssock, &addr, sizeof(addr)))
goto on_error;
@ -640,11 +658,11 @@ static int bench_test(int bufsize, int inactive_sock_count)
inactive_read_op = (pj_ioqueue_op_key_t*)pj_pool_alloc(pool,
inactive_sock_count*sizeof(pj_ioqueue_op_key_t));
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
for (i=0; i<inactive_sock_count; ++i) {
pj_ssize_t bytes;
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &inactive_sock[i]);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &inactive_sock[i]);
if (rc != PJ_SUCCESS || inactive_sock[i] < 0) {
app_perror("...error: pj_sock_socket()", rc);
goto on_error;
@ -656,7 +674,7 @@ static int bench_test(int bufsize, int inactive_sock_count)
goto on_error;
}
rc = pj_ioqueue_register_sock(pool, ioque, inactive_sock[i],
NULL, &test_cb, &key);
NULL, &test_cb, &keys[i]);
if (rc != PJ_SUCCESS) {
pj_sock_close(inactive_sock[i]);
inactive_sock[i] = PJ_INVALID_SOCKET;
@ -665,7 +683,7 @@ static int bench_test(int bufsize, int inactive_sock_count)
goto on_error;
}
bytes = bufsize;
rc = pj_ioqueue_recv(key, &inactive_read_op[i], recv_buf, &bytes, 0);
rc = pj_ioqueue_recv(keys[i], &inactive_read_op[i], recv_buf, &bytes, 0);
if (rc != PJ_EPENDING) {
pj_sock_close(inactive_sock[i]);
inactive_sock[i] = PJ_INVALID_SOCKET;
@ -735,7 +753,11 @@ static int bench_test(int bufsize, int inactive_sock_count)
TRACE__((THIS_FILE, " waiting for key = %p", skey));
do {
pj_time_val timeout = { 1, 0 };
#ifdef PJ_SYMBIAN
rc = pj_symbianos_poll(-1, 1000);
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
TRACE__((THIS_FILE, " poll rc=%d", rc));
} while (rc >= 0 && callback_read_key != skey);
@ -760,7 +782,11 @@ static int bench_test(int bufsize, int inactive_sock_count)
// Poll until all events are exhausted, before we start the next loop.
do {
pj_time_val timeout = { 0, 10 };
#ifdef PJ_SYMBIAN
rc = pj_symbianos_poll(-1, 100);
#else
rc = pj_ioqueue_poll(ioque, &timeout);
#endif
} while (rc>0);
rc = 0;
@ -784,11 +810,11 @@ static int bench_test(int bufsize, int inactive_sock_count)
// Cleaning up.
for (i=inactive_sock_count-1; i>=0; --i) {
pj_sock_close(inactive_sock[i]);
pj_ioqueue_unregister(keys[i]);
}
pj_sock_close(ssock);
pj_sock_close(csock);
pj_ioqueue_unregister(skey);
pj_ioqueue_unregister(ckey);
pj_ioqueue_destroy(ioque);

View File

@ -159,7 +159,7 @@ static int perform_unreg_test(pj_ioqueue_t *ioqueue,
* will return from the poll early.
*/
if (other_socket) {
status = app_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, 56127, &osd.sock);
status = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, 56127, &osd.sock);
if (status != PJ_SUCCESS) {
app_perror("Error creating other socket", status);
return -12;
@ -200,7 +200,7 @@ static int perform_unreg_test(pj_ioqueue_t *ioqueue,
}
/* Create pair of client/server sockets */
status = app_socketpair(PJ_AF_INET, PJ_SOCK_DGRAM, 0,
status = app_socketpair(pj_AF_INET(), pj_SOCK_DGRAM(), 0,
&sock_data.sock, &sock_data.csock);
if (status != PJ_SUCCESS) {
app_perror("app_socketpair error", status);

View File

@ -81,9 +81,9 @@ int main(int argc, char *argv[])
pj_str_t type = pj_str(argv[--argc]);
if (pj_stricmp2(&type, "tcp")==0)
param_echo_sock_type = PJ_SOCK_STREAM;
param_echo_sock_type = pj_SOCK_STREAM();
else if (pj_stricmp2(&type, "udp")==0)
param_echo_sock_type = PJ_SOCK_DGRAM;
param_echo_sock_type = pj_SOCK_DGRAM();
else {
PJ_LOG(3,("", "error: unknown socket type %s", type.ptr));
return 1;

View File

@ -112,12 +112,12 @@ int select_test()
PJ_LOG(3, (THIS_FILE, "...Testing simple UDP select()"));
// Create two UDP sockets.
rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_DGRAM, 0, &udp1);
rc = pj_sock_socket( pj_AF_INET(), pj_SOCK_DGRAM(), 0, &udp1);
if (rc != PJ_SUCCESS) {
app_perror("...error: unable to create socket", rc);
status=-10; goto on_return;
}
rc = pj_sock_socket( PJ_AF_INET, PJ_SOCK_DGRAM, 0, &udp2);
rc = pj_sock_socket( pj_AF_INET(), pj_SOCK_DGRAM(), 0, &udp2);
if (udp2 == PJ_INVALID_SOCKET) {
app_perror("...error: unable to create socket", rc);
status=-20; goto on_return;
@ -125,7 +125,7 @@ int select_test()
// Bind one of the UDP socket.
pj_bzero(&udp_addr, sizeof(udp_addr));
udp_addr.sin_family = PJ_AF_INET;
udp_addr.sin_family = pj_AF_INET();
udp_addr.sin_port = UDP_PORT;
udp_addr.sin_addr = pj_inet_addr(pj_cstr(&s, "127.0.0.1"));

View File

@ -77,12 +77,7 @@ static int format_test(void)
char zero[64];
pj_sockaddr_in addr2;
const pj_str_t *hostname;
#if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0
/* Symbian IP address is saved in host order */
unsigned char A[] = {1, 0, 0, 127};
#else
unsigned char A[] = {127, 0, 0, 1};
#endif
const unsigned char A[] = {127, 0, 0, 1};
PJ_LOG(3,("test", "...format_test()"));
@ -136,16 +131,16 @@ static int simple_sock_test(void)
int i;
pj_status_t rc = PJ_SUCCESS;
types[0] = PJ_SOCK_STREAM;
types[1] = PJ_SOCK_DGRAM;
types[0] = pj_SOCK_STREAM();
types[1] = pj_SOCK_DGRAM();
PJ_LOG(3,("test", "...simple_sock_test()"));
for (i=0; i<(int)(sizeof(types)/sizeof(types[0])); ++i) {
rc = pj_sock_socket(PJ_AF_INET, types[i], 0, &sock);
rc = pj_sock_socket(pj_AF_INET(), types[i], 0, &sock);
if (rc != PJ_SUCCESS) {
app_perror("...error: unable to create socket type %d", rc);
app_perror("...error: unable to create socket", rc);
break;
} else {
rc = pj_sock_close(sock);
@ -237,7 +232,7 @@ static int send_recv_test(int sock_type,
rc = -156; goto on_error;
}
if (received != DATA_LEN-total_received) {
if (sock_type != PJ_SOCK_STREAM) {
if (sock_type != pj_SOCK_STREAM()) {
PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes",
DATA_LEN-total_received, received));
rc = -157; goto on_error;
@ -295,7 +290,7 @@ static int send_recv_test(int sock_type,
rc = -173; goto on_error;
}
if (received != BIG_DATA_LEN-total_received) {
if (sock_type != PJ_SOCK_STREAM) {
if (sock_type != pj_SOCK_STREAM()) {
PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes",
BIG_DATA_LEN-total_received, received));
rc = -176; goto on_error;
@ -325,19 +320,19 @@ static int udp_test(void)
PJ_LOG(3,("test", "...udp_test()"));
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &ss);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &ss);
if (rc != 0) {
app_perror("...error: unable to create socket", rc);
return -100;
}
rc = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &cs);
rc = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &cs);
if (rc != 0)
return -110;
/* Bind server socket. */
pj_bzero(&dstaddr, sizeof(dstaddr));
dstaddr.sin_family = PJ_AF_INET;
dstaddr.sin_family = pj_AF_INET();
dstaddr.sin_port = pj_htons(UDP_PORT);
dstaddr.sin_addr = pj_inet_addr(pj_cstr(&s, ADDRESS));
@ -348,7 +343,7 @@ static int udp_test(void)
/* Bind client socket. */
pj_bzero(&srcaddr, sizeof(srcaddr));
srcaddr.sin_family = PJ_AF_INET;
srcaddr.sin_family = pj_AF_INET();
srcaddr.sin_port = pj_htons(UDP_PORT-1);
srcaddr.sin_addr = pj_inet_addr(pj_cstr(&s, ADDRESS));
@ -358,13 +353,13 @@ static int udp_test(void)
}
/* Test send/recv, with sendto */
rc = send_recv_test(PJ_SOCK_DGRAM, ss, cs, &dstaddr, NULL,
rc = send_recv_test(pj_SOCK_DGRAM(), ss, cs, &dstaddr, NULL,
sizeof(dstaddr));
if (rc != 0)
goto on_error;
/* Test send/recv, with sendto and recvfrom */
rc = send_recv_test(PJ_SOCK_DGRAM, ss, cs, &dstaddr,
rc = send_recv_test(pj_SOCK_DGRAM(), ss, cs, &dstaddr,
&srcaddr, sizeof(dstaddr));
if (rc != 0)
goto on_error;
@ -382,12 +377,12 @@ static int udp_test(void)
}
/* Test send/recv with send() */
rc = send_recv_test(PJ_SOCK_DGRAM, ss, cs, NULL, NULL, 0);
rc = send_recv_test(pj_SOCK_DGRAM(), ss, cs, NULL, NULL, 0);
if (rc != 0)
goto on_error;
/* Test send/recv with send() and recvfrom */
rc = send_recv_test(PJ_SOCK_DGRAM, ss, cs, NULL, &srcaddr,
rc = send_recv_test(pj_SOCK_DGRAM(), ss, cs, NULL, &srcaddr,
sizeof(srcaddr));
if (rc != 0)
goto on_error;
@ -420,14 +415,14 @@ static int tcp_test(void)
PJ_LOG(3,("test", "...tcp_test()"));
rc = app_socketpair(PJ_AF_INET, PJ_SOCK_STREAM, 0, &ss, &cs);
rc = app_socketpair(pj_AF_INET(), pj_SOCK_STREAM(), 0, &ss, &cs);
if (rc != PJ_SUCCESS) {
app_perror("...error: app_socketpair():", rc);
return -2000;
}
/* Test send/recv with send() and recv() */
retval = send_recv_test(PJ_SOCK_STREAM, ss, cs, NULL, NULL, 0);
retval = send_recv_test(pj_SOCK_STREAM(), ss, cs, NULL, NULL, 0);
rc = pj_sock_close(cs);
if (rc != PJ_SUCCESS) {

View File

@ -62,7 +62,7 @@ static int sock_producer_consumer(int sock_type,
return -10;
/* Create producer-consumer pair. */
rc = app_socketpair(PJ_AF_INET, sock_type, 0, &consumer, &producer);
rc = app_socketpair(pj_AF_INET(), sock_type, 0, &consumer, &producer);
if (rc != PJ_SUCCESS) {
app_perror("...error: create socket pair", rc);
return -20;
@ -105,7 +105,7 @@ static int sock_producer_consumer(int sock_type,
return -73;
}
if ((pj_size_t)part_received != buf_size-received) {
if (sock_type != PJ_SOCK_STREAM) {
if (sock_type != pj_SOCK_STREAM()) {
PJ_LOG(3,("", "...error: expecting %u bytes, got %u bytes",
buf_size-received, part_received));
return -76;
@ -165,13 +165,13 @@ int sock_perf_test(void)
*/
#if !defined(PJ_SYMBIAN) || PJ_SYMBIAN==0
/* Benchmarking UDP */
rc = sock_producer_consumer(PJ_SOCK_DGRAM, 512, LOOP, &bandwidth);
rc = sock_producer_consumer(pj_SOCK_DGRAM(), 512, LOOP, &bandwidth);
if (rc != 0) return rc;
PJ_LOG(3,("", "....bandwidth UDP = %d KB/s", bandwidth));
#endif
/* Benchmarking TCP */
rc = sock_producer_consumer(PJ_SOCK_STREAM, 512, LOOP, &bandwidth);
rc = sock_producer_consumer(pj_SOCK_STREAM(), 512, LOOP, &bandwidth);
if (rc != 0) return rc;
PJ_LOG(3,("", "....bandwidth TCP = %d KB/s", bandwidth));

View File

@ -64,7 +64,7 @@ int test_inner(void)
}
//pj_dump_config();
pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 );
pj_caching_pool_init( &caching_pool, NULL, 0 );
#if INCLUDE_ERRNO_TEST
DO_TEST( errno_test() );
@ -165,7 +165,7 @@ int test_inner(void)
#elif INCLUDE_ECHO_CLIENT
if (param_echo_sock_type == 0)
param_echo_sock_type = PJ_SOCK_DGRAM;
param_echo_sock_type = pj_SOCK_DGRAM();
echo_client( param_echo_sock_type,
param_echo_server,
@ -191,10 +191,15 @@ on_return:
return 0;
}
#include <pj/sock.h>
int test_main(void)
{
int i;
PJ_USE_EXCEPTION;
i = pj_AF_INET();
PJ_TRY {
return test_inner();
}

View File

@ -176,7 +176,7 @@ int udp_echo_srv_ioqueue(void)
return -20;
}
rc = app_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0,
rc = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0,
ECHO_SERVER_START_PORT, &sock);
if (rc != PJ_SUCCESS) {
app_perror("...app_socket error", rc);

View File

@ -77,7 +77,7 @@ int echo_srv_sync(void)
return -6;
}
rc = app_socket(PJ_AF_INET, PJ_SOCK_DGRAM,0, ECHO_SERVER_START_PORT, &sock);
rc = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(),0, ECHO_SERVER_START_PORT, &sock);
if (rc != PJ_SUCCESS) {
app_perror("...socket error", rc);
return -10;

View File

@ -53,7 +53,7 @@ pj_status_t app_socket(int family, int type, int proto, int port,
return rc;
#if PJ_HAS_TCP
if (type == PJ_SOCK_STREAM) {
if (type == pj_SOCK_STREAM()) {
rc = pj_sock_listen(sock, 5);
if (rc != PJ_SUCCESS)
return rc;
@ -86,7 +86,7 @@ pj_status_t app_socketpair(int family, int type, int protocol,
/* Retry bind */
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
for (i=0; i<5; ++i) {
addr.sin_port = pj_htons(port++);
rc = pj_sock_bind(sock[SERVER], &addr, sizeof(addr));
@ -99,7 +99,7 @@ pj_status_t app_socketpair(int family, int type, int protocol,
/* For TCP, listen the socket. */
#if PJ_HAS_TCP
if (type == PJ_SOCK_STREAM) {
if (type == pj_SOCK_STREAM()) {
rc = pj_sock_listen(sock[SERVER], PJ_SOMAXCONN);
if (rc != PJ_SUCCESS)
goto on_error;
@ -114,7 +114,7 @@ pj_status_t app_socketpair(int family, int type, int protocol,
/* For TCP, must accept(), and get the new socket. */
#if PJ_HAS_TCP
if (type == PJ_SOCK_STREAM) {
if (type == pj_SOCK_STREAM()) {
pj_sock_t newserver;
rc = pj_sock_accept(sock[SERVER], &newserver, NULL, NULL);

View File

@ -162,7 +162,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_udp_create2(pjmedia_endpt *endpt,
si.rtp_sock = si.rtcp_sock = PJ_INVALID_SOCKET;
/* Create RTP socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &si.rtp_sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &si.rtp_sock);
if (status != PJ_SUCCESS)
goto on_error;
@ -175,7 +175,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_udp_create2(pjmedia_endpt *endpt,
/* Create RTCP socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &si.rtcp_sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &si.rtcp_sock);
if (status != PJ_SUCCESS)
goto on_error;

View File

@ -264,7 +264,7 @@ static int create_ses_by_remote_sdp(int local_port, char *sdp)
}
pj_bzero(&skinfo, sizeof(skinfo));
skinfo.rtp_sock = skinfo.rtcp_sock = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, 0);
skinfo.rtp_sock = skinfo.rtcp_sock = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, 0);
if (skinfo.rtp_sock == PJ_INVALID_SOCKET) {
PJ_LOG(1,(THIS_FILE, "Unable to create socket"));
goto on_error;

View File

@ -726,7 +726,7 @@ static const char *dump_check(char *buffer, unsigned bufsize,
pj_ansi_strcpy(laddr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr));
if (lcand->addr.addr.sa_family == PJ_AF_INET) {
if (lcand->addr.addr.sa_family == pj_AF_INET()) {
len = pj_ansi_snprintf(buffer, bufsize,
"%d: [%d] %s:%d-->%s:%d",
GET_CHECK_ID(clist, check),
@ -834,10 +834,10 @@ static int sockaddr_cmp(const pj_sockaddr *a1, const pj_sockaddr *a2)
if (a1->addr.sa_family != a2->addr.sa_family)
return SOCKADDR_NOT_EQUAL;
if (a1->addr.sa_family == PJ_AF_INET) {
if (a1->addr.sa_family == pj_AF_INET()) {
return !(a1->ipv4.sin_addr.s_addr == a2->ipv4.sin_addr.s_addr &&
a1->ipv4.sin_port == a2->ipv4.sin_port);
} else if (a1->addr.sa_family == PJ_AF_INET6) {
} else if (a1->addr.sa_family == pj_AF_INET6()) {
return pj_memcmp(&a1->ipv6, &a2->ipv6, sizeof(a1->ipv6));
} else {
pj_assert(!"Invalid address family!");

View File

@ -285,7 +285,7 @@ static pj_status_t create_component(pj_ice_strans *ice_st,
pj_memcpy(comp->ka_tsx_id, &tsx_id, sizeof(comp->ka_tsx_id));
/* Create socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &comp->sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &comp->sock);
if (status != PJ_SUCCESS)
return status;

View File

@ -769,7 +769,7 @@ static pj_status_t encode_sockaddr_attr(const void *a, pj_uint8_t *buf,
*buf++ = '\0';
/* Family (IPv4 only for now) */
PJ_ASSERT_RETURN(ca->sockaddr.addr.sa_family == PJ_AF_INET, PJ_EINVAL);
PJ_ASSERT_RETURN(ca->sockaddr.addr.sa_family == pj_AF_INET(), PJ_EINVAL);
*buf++ = 1;
if (ca->xor_ed) {

View File

@ -83,13 +83,13 @@ static int print_attr(char *buffer, unsigned length,
attr = (const pj_stun_sockaddr_attr*)ahdr;
if (attr->sockaddr.addr.sa_family == PJ_AF_INET) {
if (attr->sockaddr.addr.sa_family == pj_AF_INET()) {
len = pj_ansi_snprintf(p, end-p,
", IPv4 addr=%s:%d\n",
pj_inet_ntoa(attr->sockaddr.ipv4.sin_addr),
pj_ntohs(attr->sockaddr.ipv4.sin_port));
} else if (attr->sockaddr.addr.sa_family == PJ_AF_INET6) {
} else if (attr->sockaddr.addr.sa_family == pj_AF_INET6()) {
len = pj_ansi_snprintf(p, end-p,
", IPv6 addr present\n");
} else {

View File

@ -562,10 +562,10 @@ static void dump_tx_msg(pj_stun_session *sess, const pj_stun_msg *msg,
const pj_sockaddr *dst = (const pj_sockaddr*)addr;
char buf[512];
if (dst->addr.sa_family == PJ_AF_INET) {
if (dst->addr.sa_family == pj_AF_INET()) {
dst_name = pj_inet_ntoa(dst->ipv4.sin_addr);
dst_port = pj_ntohs(dst->ipv4.sin_port);
} else if (dst->addr.sa_family == PJ_AF_INET6) {
} else if (dst->addr.sa_family == pj_AF_INET6()) {
dst_name = "IPv6";
dst_port = pj_ntohs(dst->ipv6.sin6_port);
} else {

View File

@ -270,13 +270,13 @@ static int init()
pj_stun_config_init(&g.stun_config, &g.cp.factory, 0, NULL, g.th);
pj_assert(status == PJ_SUCCESS);
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &g.peer_sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &g.peer_sock);
pj_assert(status == PJ_SUCCESS);
status = pj_sock_bind_in(g.peer_sock, 0, 0);
pj_assert(status == PJ_SUCCESS);
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &g.sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &g.sock);
pj_assert(status == PJ_SUCCESS);
status = pj_sockaddr_in_init(&addr, NULL, 0);

View File

@ -74,7 +74,7 @@ PJ_DEF(pj_status_t) pj_stun_bind_usage_create(pj_stun_server *srv,
usage_cb.on_destroy = &usage_on_destroy;
status = pj_stun_usage_create(srv, "bind%p", &usage_cb,
PJ_AF_INET, PJ_SOCK_DGRAM, 0,
pj_AF_INET(), pj_SOCK_DGRAM(), 0,
&local_addr, sizeof(local_addr),
&bu->usage);
if (status != PJ_SUCCESS) {

View File

@ -131,7 +131,7 @@ int main(int argc, char *argv[])
}
*/
status = pj_stun_turn_usage_create(srv, PJ_SOCK_DGRAM, NULL,
status = pj_stun_turn_usage_create(srv, pj_SOCK_DGRAM(), NULL,
3478, o.use_fingerprint, &turn);
if (status != PJ_SUCCESS) {
pj_stun_perror(THIS_FILE, "Unable to create bind usage", status);

View File

@ -159,7 +159,7 @@ PJ_DEF(pj_status_t) pj_stun_turn_usage_create(pj_stun_server *srv,
pj_sockaddr_in local_addr;
pj_status_t status;
PJ_ASSERT_RETURN(srv && (type==PJ_SOCK_DGRAM||type==PJ_SOCK_STREAM),
PJ_ASSERT_RETURN(srv && (type==pj_SOCK_DGRAM()||type==pj_SOCK_STREAM()),
PJ_EINVAL);
si = pj_stun_server_get_info(srv);
@ -185,7 +185,7 @@ PJ_DEF(pj_status_t) pj_stun_turn_usage_create(pj_stun_server *srv,
usage_cb.on_rx_data = &tu_on_rx_data;
usage_cb.on_destroy = &tu_on_destroy;
status = pj_stun_usage_create(srv, "turn%p", &usage_cb,
PJ_AF_INET, tu->type, 0,
pj_AF_INET(), tu->type, 0,
&local_addr, sizeof(local_addr),
&tu->usage);
if (status != PJ_SUCCESS) {
@ -297,7 +297,7 @@ static void tu_on_rx_data(pj_stun_usage *usage,
/* STUN message decoding flag */
flags = 0;
if (tu->type == PJ_SOCK_DGRAM)
if (tu->type == pj_SOCK_DGRAM())
flags |= PJ_STUN_IS_DATAGRAM;
@ -361,7 +361,7 @@ static pj_status_t tu_alloc_port(struct turn_usage *tu,
*err_code = PJ_STUN_SC_INVALID_PORT;
/* Allocate specific port */
status = pj_sock_socket(PJ_AF_INET, type, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), type, 0, &sock);
if (status != PJ_SUCCESS)
return status;
@ -400,7 +400,7 @@ static pj_status_t tu_alloc_port(struct turn_usage *tu,
break;
}
status = pj_sock_socket(PJ_AF_INET, type, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), type, 0, &sock);
if (status != PJ_SUCCESS)
return status;
@ -510,7 +510,7 @@ static pj_status_t tu_sess_on_send_msg(pj_stun_session *sess,
sd = (struct session_data*) pj_stun_session_get_user_data(sess);
if (sd->tu->type == PJ_SOCK_DGRAM) {
if (sd->tu->type == pj_SOCK_DGRAM()) {
return pj_stun_usage_sendto(sd->tu->usage, pkt, pkt_size, 0,
dst_addr, addr_len);
} else {
@ -546,9 +546,9 @@ static struct peer* client_add_peer(struct turn_client *client,
static const char *get_tp_type(int type)
{
if (type==PJ_SOCK_DGRAM)
if (type==pj_SOCK_DGRAM())
return "udp";
else if (type==PJ_SOCK_STREAM)
else if (type==pj_SOCK_STREAM())
return "tcp";
else
return "???";
@ -594,7 +594,7 @@ static pj_status_t client_sess_on_send_msg(pj_stun_session *sess,
sd = (struct session_data*) pj_stun_session_get_user_data(sess);
if (sd->tu->type == PJ_SOCK_DGRAM) {
if (sd->tu->type == pj_SOCK_DGRAM()) {
return pj_stun_usage_sendto(sd->tu->usage, pkt, pkt_size, 0,
dst_addr, addr_len);
} else {
@ -951,13 +951,13 @@ static pj_status_t client_handle_allocate_req(struct turn_client *client,
src_addr, src_addr_len);
return PJ_SUCCESS;
} else if (a_rt) {
client->sock_type = a_rt->value ? PJ_SOCK_STREAM : PJ_SOCK_DGRAM;
client->sock_type = a_rt->value ? pj_SOCK_STREAM() : pj_SOCK_DGRAM();
} else {
client->sock_type = client->tu->type;;
}
/* Process REQUESTED-IP attribute */
if (a_rip && a_rip->sockaddr.addr.sa_family != PJ_AF_INET) {
if (a_rip && a_rip->sockaddr.addr.sa_family != pj_AF_INET()) {
client_respond(client, msg, PJ_STUN_SC_INVALID_IP_ADDR, NULL,
src_addr, src_addr_len);
return PJ_SUCCESS;
@ -1130,7 +1130,7 @@ static pj_status_t client_handle_sad(struct turn_client *client,
/* Remote active destination needs to be cleared */
client->active_peer = NULL;
} else if (a_raddr->sockaddr.addr.sa_family != PJ_AF_INET) {
} else if (a_raddr->sockaddr.addr.sa_family != pj_AF_INET()) {
/* Bad request (not IPv4) */
client_respond(client, msg, PJ_STUN_SC_BAD_REQUEST, NULL,
src_addr, src_addr_len);
@ -1196,7 +1196,7 @@ static pj_status_t client_handle_send_ind(struct turn_client *client,
/* REMOTE-ADDRESS not present, discard packet */
return PJ_SUCCESS;
} else if (a_raddr->sockaddr.addr.sa_family != PJ_AF_INET) {
} else if (a_raddr->sockaddr.addr.sa_family != pj_AF_INET()) {
/* REMOTE-ADDRESS present but not IPv4, discard packet */
return PJ_SUCCESS;
@ -1209,7 +1209,7 @@ static pj_status_t client_handle_send_ind(struct turn_client *client,
data = (const pj_uint8_t *)a_data->data;
datalen = a_data->length;
} else if (client->sock_type == PJ_SOCK_STREAM) {
} else if (client->sock_type == pj_SOCK_STREAM()) {
/* Discard if no Data and Allocation type is TCP */
return PJ_SUCCESS;

View File

@ -225,7 +225,7 @@ int main(int argc, char *argv[])
{
pj_sockaddr_in addr;
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons(PORT);

View File

@ -760,7 +760,7 @@ static pj_status_t init_sip()
const char *transport_type = NULL;
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)app.local_port);

View File

@ -212,7 +212,7 @@ static pj_status_t init_stack(void)
{
pj_sockaddr_in addr;
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)global.port);

View File

@ -181,7 +181,7 @@ int main(int argc, char *argv[])
{
pj_sockaddr_in addr;
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons(5060);

View File

@ -305,7 +305,7 @@ static pj_status_t init_sip()
pjsip_transport *tp;
pj_bzero(&addr, sizeof(addr));
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)app.sip_port);

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[])
{
pj_sockaddr_in addr;
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons(5060);
@ -148,7 +148,7 @@ int main(int argc, char *argv[])
{
pj_sockaddr_in addr;
addr.sin_family = PJ_AF_INET;
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons(5060);

View File

@ -560,7 +560,7 @@ PJ_DEF(pj_status_t) pjsip_transport_send( pjsip_transport *tr,
tdata->tp_info.transport = tr;
pj_memcpy(&tdata->tp_info.dst_addr, addr, addr_len);
tdata->tp_info.dst_addr_len = addr_len;
if (((pj_sockaddr*)addr)->addr.sa_family == PJ_AF_INET) {
if (((pj_sockaddr*)addr)->addr.sa_family == pj_AF_INET()) {
const char *str_addr;
str_addr = pj_inet_ntoa(((pj_sockaddr_in*)addr)->sin_addr);
pj_ansi_strcpy(tdata->tp_info.dst_name, str_addr);
@ -1471,12 +1471,12 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport(pjsip_tpmgr *mgr,
/* For datagram INET transports, try lookup with zero address.
*/
else if ((flag & PJSIP_TRANSPORT_DATAGRAM) &&
(remote_addr->addr.sa_family == PJ_AF_INET))
(remote_addr->addr.sa_family == pj_AF_INET()))
{
pj_sockaddr_in *addr = (pj_sockaddr_in*)&key.rem_addr;
pj_bzero(addr, sizeof(pj_sockaddr_in));
addr->sin_family = PJ_AF_INET;
addr->sin_family = pj_AF_INET();
key_len = sizeof(key.type) + sizeof(pj_sockaddr_in);
transport = (pjsip_transport*)

View File

@ -367,7 +367,7 @@ PJ_DEF(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,
if (status != PJ_SUCCESS)
goto on_error;
loop->base.key.type = PJSIP_TRANSPORT_LOOP_DGRAM;
//loop->base.key.rem_addr.sa_family = PJ_AF_INET;
//loop->base.key.rem_addr.sa_family = pj_AF_INET();
loop->base.type_name = "LOOP-DGRAM";
loop->base.info = "LOOP-DGRAM";
loop->base.flag = PJSIP_TRANSPORT_DATAGRAM;

View File

@ -239,7 +239,8 @@ PJ_DEF(pj_status_t) pjsip_tcp_transport_start2(pjsip_endpoint *endpt,
/* Create and bind socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &listener->sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0,
&listener->sock);
if (status != PJ_SUCCESS)
goto on_error;
@ -787,7 +788,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,
addr_len && p_transport, PJ_EINVAL);
/* Check that address is a sockaddr_in */
PJ_ASSERT_RETURN(rem_addr->addr.sa_family == PJ_AF_INET &&
PJ_ASSERT_RETURN(rem_addr->addr.sa_family == pj_AF_INET() &&
addr_len == sizeof(pj_sockaddr_in), PJ_EINVAL);
@ -795,7 +796,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,
/* Create socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &sock);
if (status != PJ_SUCCESS)
return status;

View File

@ -937,7 +937,7 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_start( pjsip_endpoint *endpt,
/* Create and bind socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &listener->sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &listener->sock);
if (status != PJ_SUCCESS)
goto on_error;
@ -1526,7 +1526,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,
addr_len && p_transport, PJ_EINVAL);
/* Check that address is a sockaddr_in */
PJ_ASSERT_RETURN(rem_addr->addr.sa_family == PJ_AF_INET &&
PJ_ASSERT_RETURN(rem_addr->addr.sa_family == pj_AF_INET() &&
addr_len == sizeof(pj_sockaddr_in), PJ_EINVAL);
@ -1534,7 +1534,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,
/* Create socket */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_STREAM, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, &sock);
if (status != PJ_SUCCESS)
return status;

View File

@ -419,7 +419,7 @@ static pj_status_t create_socket(const pj_sockaddr_in *local_a,
pj_sockaddr_in tmp_addr;
pj_status_t status;
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock);
if (status != PJ_SUCCESS)
return status;
@ -508,7 +508,7 @@ static void udp_set_socket(struct udp_transport *tp,
/* Adjust socket rcvbuf size */
sobuf_size = PJSIP_UDP_SO_RCVBUF_SIZE;
status = pj_sock_setsockopt(sock, PJ_SOL_SOCKET, PJ_SO_RCVBUF,
status = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_RCVBUF(),
&sobuf_size, sizeof(sobuf_size));
if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
@ -519,7 +519,7 @@ static void udp_set_socket(struct udp_transport *tp,
/* Adjust socket sndbuf size */
sobuf_size = PJSIP_UDP_SO_SNDBUF_SIZE;
status = pj_sock_setsockopt(sock, PJ_SOL_SOCKET, PJ_SO_SNDBUF,
status = pj_sock_setsockopt(sock, pj_SOL_SOCKET(), pj_SO_SNDBUF(),
&sobuf_size, sizeof(sobuf_size));
if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
@ -639,7 +639,7 @@ PJ_DEF(pj_status_t) pjsip_udp_transport_attach( pjsip_endpoint *endpt,
tp->base.key.type = PJSIP_TRANSPORT_UDP;
/* Remote address is left zero (except the family) */
tp->base.key.rem_addr.addr.sa_family = PJ_AF_INET;
tp->base.key.rem_addr.addr.sa_family = pj_AF_INET();
/* Type name. */
tp->base.type_name = "UDP";

View File

@ -1080,7 +1080,7 @@ static pj_status_t create_sip_udp_sock(pj_in_addr bound_addr,
return status;
}
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "socket() error", status);
return status;
@ -1151,7 +1151,7 @@ static pj_status_t create_sip_udp_sock(pj_in_addr bound_addr,
return status;
}
p_pub_addr->sin_family = PJ_AF_INET;
p_pub_addr->sin_family = pj_AF_INET();
p_pub_addr->sin_port = pj_htons((pj_uint16_t)port);
}

View File

@ -243,7 +243,7 @@ static pj_status_t create_rtp_rtcp_sock(const pjsua_transport_config *cfg,
for (i=0; i<RTP_RETRY; ++i, next_rtp_port += 2) {
/* Create and bind RTP socket. */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[0]);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock[0]);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "socket() error", status);
return status;
@ -258,7 +258,7 @@ static pj_status_t create_rtp_rtcp_sock(const pjsua_transport_config *cfg,
}
/* Create and bind RTCP socket. */
status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[1]);
status = pj_sock_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, &sock[1]);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "socket() error", status);
pj_sock_close(sock[0]);

View File

@ -483,7 +483,7 @@ static void add_ref(pjsip_server_addresses *r,
r->entry[r->count].addr_len = sizeof(pj_sockaddr_in);
a = (pj_sockaddr_in *)&r->entry[r->count].addr;
a->sin_family = PJ_AF_INET;
a->sin_family = pj_AF_INET();
tmp = pj_str(addr);
a->sin_addr = pj_inet_addr(&tmp);
a->sin_port = pj_htons((pj_uint16_t)port);