From eeb50099d935e9dea1e0dd3fd1af81e4ec617115 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Fri, 7 Apr 2017 14:08:09 -0600 Subject: [PATCH 1/4] initial Nucleus port with PB changes --- src/internal.c | 10 ++++ wolfcrypt/src/random.c | 15 ++++++ wolfcrypt/src/sha.c | 8 +++ wolfcrypt/src/wc_port.c | 98 ++++++++++++++++++++++++++++++++++++ wolfssl/internal.h | 2 + wolfssl/wolfcrypt/integer.h | 5 ++ wolfssl/wolfcrypt/settings.h | 23 +++++++++ wolfssl/wolfcrypt/wc_port.h | 19 +++++++ wolfssl/wolfio.h | 14 ++++++ 9 files changed, 194 insertions(+) diff --git a/src/internal.c b/src/internal.c index 77a09ba6f..ac00f30d1 100644 --- a/src/internal.c +++ b/src/internal.c @@ -6067,6 +6067,16 @@ ProtocolVersion MakeDTLSv1_2(void) return (word32)(uTaskerSystemTick / TICK_RESOLUTION); } +#elif defined(WOLFSSL_NUCLEUS) + + #define NU_TICKS_PER_SECOND 100 + + word32 LowResTimer(void) + { + /* returns number of 10ms ticks, so 100 ticks/sec */ + return NU_Retrieve_Clock() / NU_TICKS_PER_SECOND; + } + #else /* Posix style time */ #ifndef USER_TIME diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 9b097b74d..9424accb7 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -142,6 +142,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b) #elif defined(WOLFSSL_ROWLEY_ARM) #elif defined(WOLFSSL_EMBOS) #elif defined(MICRIUM) +#elif defined(WOLFSSL_NUCLEUS) #else /* include headers that may be needed to get good seed */ #include @@ -1613,6 +1614,20 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) return 0; } + +#elif defined(WOLFSSL_PB) + + int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) + { + word32 i; + for (i = 0; i < sz; i++) + output[i] = UTL_Rand(); + + (void)os; + + return 0; + } + #elif defined(WOLFSSL_NUCLEUS) #include "nucleus.h" #include "kernel/plus_common.h" diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 65e8a375c..9aaad94c0 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -287,6 +287,14 @@ static WC_INLINE void AddLength(wc_Sha* sha, word32 len) #define f3(x,y,z) (((x)&(y))|((z)&((x)|(y)))) #define f4(x,y,z) ((x)^(y)^(z)) + #ifdef WOLFSSL_NUCLEUS + /* nucleus.h also defines R1-R4 */ + #undef R1 + #undef R2 + #undef R3 + #undef R4 + #endif + /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) (z)+= f1((w),(x),(y)) + blk0((i)) + 0x5A827999+ \ rotlFixed((v),5); (w) = rotlFixed((w),30); diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index ab1d1e73d..94797d6ee 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -1255,6 +1255,44 @@ int wolfSSL_CryptHwMutexUnLock(void) { return ret; } +#elif defined(WOLFSSL_NUCLEUS) + + int wc_InitMutex(wolfSSL_Mutex* m) + { + /* Call the Nucleus function to create the semaphore */ + if (NU_Create_Semaphore(m, "WOLFSSL_MTX", 1, + NU_PRIORITY) == NU_SUCCESS) { + return 0; + } + + return BAD_MUTEX_E; + } + + int wc_FreeMutex(wolfSSL_Mutex* m) + { + if (NU_Delete_Semaphore(m) == NU_SUCCESS) + return 0; + + return BAD_MUTEX_E; + } + + int wc_LockMutex(wolfSSL_Mutex* m) + { + /* passing suspend task option */ + if (NU_Obtain_Semaphore(m, NU_SUSPEND) == NU_SUCCESS) + return 0; + + return BAD_MUTEX_E; + } + + int wc_UnLockMutex(wolfSSL_Mutex* m) + { + if (NU_Release_Semaphore(m) == NU_SUCCESS) + return 0; + + return BAD_MUTEX_E; + } + #else #warning No mutex handling defined @@ -1487,6 +1525,66 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n) } #endif +/* custom memory wrappers */ +#ifdef WOLFSSL_NUCLEUS + + /* system memory pool */ + extern NU_MEMORY_POOL System_Memory; + + void* nucleus_malloc(unsigned long size, void* heap, int type) + { + STATUS status; + void* stack_ptr; + + status = NU_Allocate_Memory(&System_Memory, &stack_ptr, size, + NU_NO_SUSPEND); + if (status == NU_SUCCESS) { + return 0; + } else { + return stack_ptr; + } + } + + void* nucleus_realloc(void* ptr, unsigned long size, void* heap, int type) + { + STATUS status; + DM_HEADER* old_header; + word32 old_size, copy_size; + void* new_mem; + + /* if ptr is NULL, behave like malloc */ + new_mem = nucleus_malloc(size, NULL, 0); + if (new_mem == 0 || ptr == 0) { + return new_mem; + } + + /* calculate old memory block size */ + /* mem pointers stored in block headers (ref dm_defs.h) */ + old_header = (DM_HEADER*) ((byte*)ptr - DM_OVERHEAD); + old_size = (byte*)old_header->dm_next_memory - (byte*)ptr; + + /* copy old to new */ + if (old_size < size) { + copy_size = old_size; + } else { + copy_size = size; + } + XMEMCPY(new_mem, ptr, copy_size); + + /* free old */ + nucleus_free(ptr, NULL, 0); + + return new_mem; + } + + void nucleus_free(void* ptr, void* heap, int type) + { + if (ptr != NULL) + NU_Deallocate_Memory(ptr); + } + +#endif /* WOLFSSL_NUCLEUS */ + #if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH) #include /* initialize and Mutex for TI Crypt Engine */ #include /* md5, sha1, sha224, sha256 */ diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 93a3ba4a0..8157c5229 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -159,6 +159,8 @@ /* do nothing */ #elif defined(INTIME_RTOS) #include +#elif defined(WOLFSSL_NUCLEUS) + /* do nothing */ #else #ifndef SINGLE_THREADED #define WOLFSSL_PTHREADS diff --git a/wolfssl/wolfcrypt/integer.h b/wolfssl/wolfcrypt/integer.h index 14767b9ab..0f9c925b2 100644 --- a/wolfssl/wolfcrypt/integer.h +++ b/wolfssl/wolfcrypt/integer.h @@ -71,6 +71,11 @@ extern "C" { /* C++ compilers don't like assigning void * to mp_digit * */ #define OPT_CAST(x) (x *) +#elif defined(_SH3) + +/* SuperH SH3 compiler doesn't like assigning voi* to mp_digit* */ +#define OPT_CAST(x) (x *) + #else /* C on the other hand doesn't care */ diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 1dbcdc949..61be3fba9 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -162,6 +162,9 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ +/* Uncomment next line if building for Nucleus */ +/* #define WOLFSSL_NUCLEUS */ + #include #ifdef WOLFSSL_USER_SETTINGS @@ -447,6 +450,26 @@ #include "wolfssl_chibios.h" #endif +#ifdef WOLFSSL_NUCLEUS + #define NO_WRITEV + #define NO_WOLFSSL_DIR + + #ifndef USER_TIME + #error User must define XTIME, see manual + #endif + + #if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER) + extern void* nucleus_malloc(unsigned long size, void* heap, int type); + extern void* nucleus_realloc(void* ptr, unsigned long size, void* heap, + int type); + extern void nucleus_free(void* ptr, void* heap, int type); + + #define XMALLOC(s, h, type) nucleus_malloc + #define XREALLOC(p, n, h, t) nucleus_realloc + #define XFREE(p, h, type) nucleus_free + #endif +#endif + #ifdef WOLFSSL_NRF5x #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 9a6333a1f..2999aa756 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -97,6 +97,11 @@ #elif defined(INTIME_RTOS) #include #include +#elif defined(WOLFSSL_NUCLEUS) + /* NU_DEBUG needed struct access in nucleus_realloc */ + #define NU_DEBUG + #include "plus/nucleus.h" + #include "nucleus.h" #else #ifndef SINGLE_THREADED #define WOLFSSL_PTHREADS @@ -168,6 +173,8 @@ typedef mutex_t * wolfSSL_Mutex; #elif defined(INTIME_RTOS) typedef RTHANDLE wolfSSL_Mutex; + #elif defined(WOLFSSL_NUCLEUS) + typedef NU_SEMAPHORE wolfSSL_Mutex; #else #error Need a mutex type in multithreaded mode #endif /* USE_WINDOWS_API */ @@ -273,6 +280,18 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define XSEEK_END FS_SEEK_END #define XBADFILE NULL #define XFGETS(b,s,f) -2 /* Not ported yet */ +#elif defined(WOLFSSL_NUCLEUS) + #include "fal/inc/fal.h" + #define XFILE FILE* + #define XFOPEN fopen + #define XFSEEK fseek + #define XFTELL ftell + #define XREWIND rewind + #define XFREAD fread + #define XFWRITE fwrite + #define XFCLOSE fclose + #define XSEEK_END PSEEK_END + #define XBADFILE NULL #else /* stdio, default case */ #include diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index d60bdbe7a..a022cd4e9 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -80,6 +80,9 @@ #elif defined(WOLFSSL_VXWORKS) #include #include + #elif defined(WOLFSSL_NUCLEUS) + #include + #include #elif defined(WOLFSSL_ATMEL) #include "socket/include/socket.h" #elif defined(INTIME_RTOS) @@ -198,6 +201,14 @@ #define SOCKET_EPIPE FREERTOS_SOCKET_ERROR #define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR #define SOCKET_ECONNABORTED FREERTOS_SOCKET_ERROR +#elif defined(WOLFSSL_NUCLEUS) + #define SOCKET_EWOULDBLOCK NU_WOULD_BLOCK + #define SOCKET_EAGAIN NU_WOULD_BLOCK + #define SOCKET_ECONNRESET NU_NOT_CONNECTED + #define SOCKET_EINTR NU_NOT_CONNECTED + #define SOCKET_EPIPE NU_NOT_CONNECTED + #define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED + #define SOCKET_ECONNABORTED NU_NOT_CONNECTED #else #define SOCKET_EWOULDBLOCK EWOULDBLOCK #define SOCKET_EAGAIN EAGAIN @@ -244,6 +255,9 @@ #elif defined(WOLFSSL_VXWORKS) #define SEND_FUNCTION send #define RECV_FUNCTION recv +#elif defined(WOLFSSL_NUCLEUS) + #define SEND_FUNCTION NU_Send + #define RECV_FUNCTION NU_Recv #else #define SEND_FUNCTION send #define RECV_FUNCTION recv From f59fb0df8eae09b8f4cefb34bfa96548062738c4 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Fri, 7 Apr 2017 14:10:28 -0600 Subject: [PATCH 2/4] add custom print to test.c for PB --- wolfcrypt/test/test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index fbe4e290e..97eb5e56a 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -201,6 +201,11 @@ void BSP_Ser_Printf (CPU_CHAR* format, ...); #undef printf #define printf BSP_Ser_Printf +#elif defined(WOLFSSL_PB) + #include + int wolfssl_pb_print(const char*, ...); + #undef printf + #define printf wolfssl_pb_print #endif #include "wolfcrypt/test/test.h" @@ -400,6 +405,23 @@ static void myFipsCb(int ok, int err, const char* hash) #endif #endif +#ifdef WOLFSSL_PB +int wolfssl_pb_print(const char* msg, ...) +{ + int ret; + va_list args; + char tmpBuf[80]; + + va_start(args, msg); + ret = vsprint(tmpBuf, msg, args); + va_end(args); + + fnDumpStringToSystemLog(tmpBuf); + + return ret; +} +#endif /* WOLFSSL_PB */ + #ifdef HAVE_STACK_SIZE THREAD_RETURN WOLFSSL_THREAD wolfcrypt_test(void* args) #else From 213f79f06f89974e360495987472e71879ed6bbc Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 19 Jul 2018 10:47:37 -0600 Subject: [PATCH 3/4] only require Nucleus XTIME when NO_ASN_TIME is not defined --- wolfssl/wolfcrypt/settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 61be3fba9..ef158d50b 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -454,7 +454,7 @@ #define NO_WRITEV #define NO_WOLFSSL_DIR - #ifndef USER_TIME + #if !defined(NO_ASN_TIME) && !defined(USER_TIME) #error User must define XTIME, see manual #endif From 7f19f914c0353de01e814d26bf5af72694b5cc2c Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 19 Jul 2018 11:43:48 -0600 Subject: [PATCH 4/4] create WOLFSSL_NUCLEUS_1_2 for older 1.2 version --- src/internal.c | 2 +- wolfcrypt/src/random.c | 1 + wolfcrypt/src/sha.c | 2 +- wolfcrypt/src/wc_port.c | 8 ++++---- wolfssl/internal.h | 2 +- wolfssl/wolfcrypt/settings.h | 12 +++++++++--- wolfssl/wolfcrypt/wc_port.h | 11 ++++++----- wolfssl/wolfio.h | 6 +++--- 8 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/internal.c b/src/internal.c index ac00f30d1..725c0aaaa 100644 --- a/src/internal.c +++ b/src/internal.c @@ -6067,7 +6067,7 @@ ProtocolVersion MakeDTLSv1_2(void) return (word32)(uTaskerSystemTick / TICK_RESOLUTION); } -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) #define NU_TICKS_PER_SECOND 100 diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 9424accb7..c7a3bee56 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -143,6 +143,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b) #elif defined(WOLFSSL_EMBOS) #elif defined(MICRIUM) #elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_PB) #else /* include headers that may be needed to get good seed */ #include diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 9aaad94c0..38b14f557 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -287,7 +287,7 @@ static WC_INLINE void AddLength(wc_Sha* sha, word32 len) #define f3(x,y,z) (((x)&(y))|((z)&((x)|(y)))) #define f4(x,y,z) ((x)^(y)^(z)) - #ifdef WOLFSSL_NUCLEUS + #ifdef WOLFSSL_NUCLEUS_1_2 /* nucleus.h also defines R1-R4 */ #undef R1 #undef R2 diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 94797d6ee..f89ca07ac 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -221,7 +221,7 @@ int wolfCrypt_Cleanup(void) } #if !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR) && \ - !defined(WOLFSSL_NUCLEUS) + !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) /* File Handling Helpers */ /* returns 0 if file found, -1 if no files or negative error */ @@ -1255,7 +1255,7 @@ int wolfSSL_CryptHwMutexUnLock(void) { return ret; } -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) int wc_InitMutex(wolfSSL_Mutex* m) { @@ -1526,7 +1526,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n) #endif /* custom memory wrappers */ -#ifdef WOLFSSL_NUCLEUS +#ifdef WOLFSSL_NUCLEUS_1_2 /* system memory pool */ extern NU_MEMORY_POOL System_Memory; @@ -1583,7 +1583,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n) NU_Deallocate_Memory(ptr); } -#endif /* WOLFSSL_NUCLEUS */ +#endif /* WOLFSSL_NUCLEUS_1_2 */ #if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH) #include /* initialize and Mutex for TI Crypt Engine */ diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 8157c5229..669723af6 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -159,7 +159,7 @@ /* do nothing */ #elif defined(INTIME_RTOS) #include -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) /* do nothing */ #else #ifndef SINGLE_THREADED diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index ef158d50b..42813dce7 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -162,8 +162,8 @@ /* Uncomment next line if building for using XILINX */ /* #define WOLFSSL_XILINX */ -/* Uncomment next line if building for Nucleus */ -/* #define WOLFSSL_NUCLEUS */ +/* Uncomment next line if building for Nucleus 1.2 */ +/* #define WOLFSSL_NUCLEUS_1_2 */ #include @@ -450,7 +450,13 @@ #include "wolfssl_chibios.h" #endif -#ifdef WOLFSSL_NUCLEUS +#ifdef WOLFSSL_PB + /* PB is using older 1.2 version of Nucleus */ + #undef WOLFSSL_NUCLEUS + #define WOLFSSL_NUCLEUS_1_2 +#endif + +#ifdef WOLFSSL_NUCLEUS_1_2 #define NO_WRITEV #define NO_WOLFSSL_DIR diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 2999aa756..138be8c80 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -97,7 +97,7 @@ #elif defined(INTIME_RTOS) #include #include -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) /* NU_DEBUG needed struct access in nucleus_realloc */ #define NU_DEBUG #include "plus/nucleus.h" @@ -173,7 +173,7 @@ typedef mutex_t * wolfSSL_Mutex; #elif defined(INTIME_RTOS) typedef RTHANDLE wolfSSL_Mutex; - #elif defined(WOLFSSL_NUCLEUS) + #elif defined(WOLFSSL_NUCLEUS_1_2) typedef NU_SEMAPHORE wolfSSL_Mutex; #else #error Need a mutex type in multithreaded mode @@ -280,7 +280,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define XSEEK_END FS_SEEK_END #define XBADFILE NULL #define XFGETS(b,s,f) -2 /* Not ported yet */ -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) #include "fal/inc/fal.h" #define XFILE FILE* #define XFOPEN fopen @@ -313,7 +313,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define XFGETS fgets #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)\ - && !defined(WOLFSSL_NUCLEUS) + && !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) #include #include #include @@ -327,7 +327,8 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #define MAX_PATH 256 #endif -#if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) +#if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) && \ + !defined(WOLFSSL_NUCLEUS_1_2) typedef struct ReadDirCtx { #ifdef USE_WINDOWS_API WIN32_FIND_DATAA FindFileData; diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index a022cd4e9..cafaaad5e 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -80,7 +80,7 @@ #elif defined(WOLFSSL_VXWORKS) #include #include - #elif defined(WOLFSSL_NUCLEUS) + #elif defined(WOLFSSL_NUCLEUS_1_2) #include #include #elif defined(WOLFSSL_ATMEL) @@ -201,7 +201,7 @@ #define SOCKET_EPIPE FREERTOS_SOCKET_ERROR #define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR #define SOCKET_ECONNABORTED FREERTOS_SOCKET_ERROR -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) #define SOCKET_EWOULDBLOCK NU_WOULD_BLOCK #define SOCKET_EAGAIN NU_WOULD_BLOCK #define SOCKET_ECONNRESET NU_NOT_CONNECTED @@ -255,7 +255,7 @@ #elif defined(WOLFSSL_VXWORKS) #define SEND_FUNCTION send #define RECV_FUNCTION recv -#elif defined(WOLFSSL_NUCLEUS) +#elif defined(WOLFSSL_NUCLEUS_1_2) #define SEND_FUNCTION NU_Send #define RECV_FUNCTION NU_Recv #else