original files of m241
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_port.mk,v $ $Revision: 1.39.10.2 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/port/gmake/ipcom_port.mk,v $
|
||||
# $Author: svc-cmnet $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
###########################################################################
|
||||
|
||||
# start
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPOBJECTS += ipcom_$(IPPORT).o
|
||||
|
||||
# port/<ipport>/src
|
||||
IPLIBOBJECTS += ipcom_debug.o
|
||||
IPLIBOBJECTS += ipcom_errno.o
|
||||
IPLIBOBJECTS += ipcom_malloc.o
|
||||
IPLIBOBJECTS += ipcom_normpath.o
|
||||
IPLIBOBJECTS += ipcom_os.o
|
||||
IPLIBOBJECTS += ipcom_time.o
|
||||
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
IPLIBOBJECTS += simpleMemLib.o
|
||||
endif
|
||||
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_pkt.o
|
||||
IPLIBOBJECTS += ipcom_drv_eth.o
|
||||
IPLIBOBJECTS += ipcom_drv_ppp.o
|
||||
IPLIBOBJECTS += ipcom_random.o
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# port/src
|
||||
IPLIBOBJECTS += ipcom_checksum.o
|
||||
IPLIBOBJECTS += ipcom_strerror.o
|
||||
IPLIBOBJECTS += ipcom_strtok_r.o
|
||||
IPLIBOBJECTS += ipcom_strdup.o
|
||||
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipcom_access.o
|
||||
IPLIBOBJECTS += ipcom_array.o
|
||||
IPLIBOBJECTS += ipcom_ctime.o
|
||||
IPLIBOBJECTS += ipcom_ctype.o
|
||||
IPLIBOBJECTS += ipcom_dns.o
|
||||
IPLIBOBJECTS += ipcom_exit.o
|
||||
IPLIBOBJECTS += ipcom_ffs.o
|
||||
IPLIBOBJECTS += ipcom_getenv.o
|
||||
IPLIBOBJECTS += ipcom_gethostby.o
|
||||
IPLIBOBJECTS += ipcom_getinfo.o
|
||||
IPLIBOBJECTS += ipcom_getinfo2.o
|
||||
IPLIBOBJECTS += ipcom_getput.o
|
||||
IPLIBOBJECTS += ipcom_getservby.o
|
||||
IPLIBOBJECTS += ipcom_getuid.o
|
||||
IPLIBOBJECTS += ipcom_gmtime.o
|
||||
IPLIBOBJECTS += ipcom_hostname.o
|
||||
IPLIBOBJECTS += ipcom_ifaddrs.o
|
||||
IPLIBOBJECTS += ipcom_job_queue_pipe.o
|
||||
IPLIBOBJECTS += ipcom_mktime.o
|
||||
IPLIBOBJECTS += ipcom_perror.o
|
||||
IPLIBOBJECTS += ipcom_setvbuf.o
|
||||
IPLIBOBJECTS += ipcom_signal.o
|
||||
IPLIBOBJECTS += ipcom_snprintf.o
|
||||
IPLIBOBJECTS += ipcom_strcasecmp.o
|
||||
IPLIBOBJECTS += ipcom_strftime.o
|
||||
IPLIBOBJECTS += ipcom_string_mem.o
|
||||
IPLIBOBJECTS += ipcom_strl.o
|
||||
IPLIBOBJECTS += ipcom_strsep.o
|
||||
IPLIBOBJECTS += ipcom_strto.o
|
||||
IPLIBOBJECTS += ipcom_strtok_r.o
|
||||
IPLIBOBJECTS += ipcom_termios.o
|
||||
IPLIBOBJECTS += ipcom_times.o
|
||||
IPLIBOBJECTS += ipcom_uname.o
|
||||
IPLIBOBJECTS += ipcom_vr.o
|
||||
IPLIBOBJECTS += ipcom_xtime.o
|
||||
IPLIBOBJECTS += ipcom_xtoyz.o
|
||||
endif
|
||||
ifneq ($(IPPORT),las)
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipcom_printf.o
|
||||
IPLIBOBJECTS += ipcom_stdio.o
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# Generic implementation of features that should be re-implemented
|
||||
# OS specific for increased performance if possble
|
||||
ifneq ($(IPPORT),las)
|
||||
IPLIBOBJECTS += ipcom_generic_pipe.o
|
||||
IPLIBOBJECTS += ipcom_generic_llpipe.o
|
||||
ifneq ($(IPPORT),lkm)
|
||||
IPLIBOBJECTS += ipcom_generic_slab.o
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(IPPORT),lkm)
|
||||
ifneq ($(IPPORT),vxworks)
|
||||
ifneq ($(IPCOMPILER),gcc)
|
||||
IPLIBOBJECTS += ipcom_generic_atomic.o
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# VPATH
|
||||
###########################################################################
|
||||
|
||||
IPSRCDIRS += $(IPCOM_ROOT)/port/src $(IPCOM_ROOT)/port/$(IPPORT)/src
|
||||
|
||||
|
||||
#############################################################################
|
||||
# LIB
|
||||
###########################################################################
|
||||
|
||||
# Library
|
||||
IPLIBS += $(IPLIBROOT)/libipcom_$(IPPORT).a
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_PORT.MK
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_access.c,v $ $Revision: 1.12 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_access.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE && \
|
||||
(defined(IP_PORT_OSE) || defined(IP_PORT_OSE5) || defined(IP_PORT_WIN32) || defined(IP_PORT_UNIX))
|
||||
#define IPCOM_USE_FILE_ACCESS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_file.h"
|
||||
|
||||
#ifdef IPCOM_USE_FILE_ACCESS
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef IP_PORT_WIN32
|
||||
#include "io.h"
|
||||
#else
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IPCOM_USE_FILE_ACCESS) && defined(IP_PORT_UNIX)
|
||||
/* Has to add per-task cwd to all paths */
|
||||
IP_PUBLIC char *ipcom_pfile_cwd(const char *path);
|
||||
IP_PUBLIC void ipcom_pfile_free(void *buf);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_access
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_access(const char *path, int amode)
|
||||
{
|
||||
#ifdef IPCOM_USE_FILE_ACCESS
|
||||
#if defined(IP_PORT_UNIX)
|
||||
char *p;
|
||||
int ret;
|
||||
|
||||
ret = access(p = ipcom_pfile_cwd(path), amode);
|
||||
ipcom_pfile_free(p);
|
||||
|
||||
return ret;
|
||||
|
||||
#elif defined (IP_PORT_WIN32)
|
||||
return _access(path, amode);
|
||||
|
||||
#else
|
||||
return access(path, amode);
|
||||
#endif
|
||||
|
||||
#else
|
||||
(void)path;
|
||||
(void)amode;
|
||||
return 0; /* access ok. */
|
||||
#endif /* IPCOM_USE_FILE_ACCESS */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_umask
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_mode_t
|
||||
ipcom_umask(Ip_mode_t cmask)
|
||||
{
|
||||
#ifdef IPCOM_USE_FILE_ACCESS
|
||||
#ifdef IP_PORT_WIN32
|
||||
return (Ip_mode_t)_umask((int)cmask);
|
||||
#else
|
||||
return (Ip_mode_t)umask((mode_t)cmask);
|
||||
#endif
|
||||
#else
|
||||
return cmask;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_chmod
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_chmod(const char *path, Ip_mode_t mode)
|
||||
{
|
||||
#ifdef IPCOM_USE_FILE_ACCESS
|
||||
#if defined(IP_PORT_UNIX)
|
||||
char *p;
|
||||
int ret;
|
||||
|
||||
ret = chmod(p = ipcom_pfile_cwd(path), mode);
|
||||
ipcom_pfile_free(p);
|
||||
|
||||
return ret;
|
||||
|
||||
#elif defined(IP_PORT_WIN32)
|
||||
return _chmod(path, (int)mode);
|
||||
|
||||
#else
|
||||
return chmod(path, (mode_t)mode);
|
||||
#endif
|
||||
|
||||
#else
|
||||
(void)path;
|
||||
(void)mode;
|
||||
return 0;
|
||||
#endif /* IPCOM_USE_FILE_ACCESS */
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_access_empty_file;
|
||||
#endif /* IPCOM_USE_FILE == IPCOM_FILE_NATIVE */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_array.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_array.c,v $
|
||||
* $Author: ulf $ $Date: 2008-10-13 11:09:39 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
#if !defined(IP_PORT_LKM)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_qsort
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_QSORT) && IPCOM_QSORT == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_qsort(void *base, Ip_size_t nel, Ip_size_t width, int (*compar)(const void *, const void *))
|
||||
{
|
||||
#ifdef IP_PORT_RTCORE
|
||||
ip_assert("ipcom_qsort() is not implemented" == 0);
|
||||
#else
|
||||
qsort(base, (size_t) nel, (size_t) width, compar);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_bsearch
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_BSEARCH) && IPCOM_BSEARCH == 1
|
||||
IP_PUBLIC void *
|
||||
ipcom_bsearch(const void *key, const void *base, Ip_size_t nel, Ip_size_t size,
|
||||
int (*compar)(const void *,const void *))
|
||||
{
|
||||
#ifdef IP_PORT_RTCORE
|
||||
ip_assert("ipcom_bsearch() is not implemented" == 0);
|
||||
return IP_NULL;
|
||||
#else
|
||||
return (void *)bsearch(key, base, (size_t)nel, (size_t)size, compar);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,475 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_checksum.c,v $ $Revision: 1.28.10.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_checksum.c,v $
|
||||
* $Author: hxie $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_inet.h"
|
||||
#include "ipcom_sock.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_CPY_32_BITS_ALIGNED
|
||||
*===========================================================================
|
||||
* Description: Copies 32-bits of data where the source and destination
|
||||
* addresses both are aligned on a 32-bit boundary.
|
||||
*
|
||||
*/
|
||||
#define IPCOM_CPY_32_BITS_ALIGNED \
|
||||
data = *dst_u32++ = *src_u32++; \
|
||||
chksum += (Ip_u16) data + (data >> 16); \
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_CPY_32_BITS_UNALIGNED
|
||||
*===========================================================================
|
||||
* Description: Copies 32-bits of data where the source and destination
|
||||
* addresses cannot be aligned on a 32-bit boundary at the same
|
||||
* time. Data is read and written in 32-bit chunks at a 32-bit
|
||||
* boundary.
|
||||
*
|
||||
*/
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
#define IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2) \
|
||||
data = src_data << shift1; \
|
||||
src_data = *src_u32++; \
|
||||
data = (src_data >> shift2) | data; \
|
||||
chksum += (Ip_u16) data; \
|
||||
*dst_u32++ = data; \
|
||||
chksum += (data >> 16);
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
#define IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2) \
|
||||
data = src_data >> shift1; \
|
||||
src_data = *src_u32++; \
|
||||
data = (src_data << shift2) | data; \
|
||||
chksum += (Ip_u16) data; \
|
||||
*dst_u32++ = data; \
|
||||
chksum += (data >> 16);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_UNALIGNED_CPY_LOOP
|
||||
*===========================================================================
|
||||
* Description: Copies data as long as a full 32-bit word can be written.
|
||||
*
|
||||
*/
|
||||
#define IPCOM_UNALIGNED_CPY_LOOP(shift1, shift2) \
|
||||
i = (int)((len - octet_unalignment) >> 5); \
|
||||
while (i--) \
|
||||
{ \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
} \
|
||||
i = (int)(((len - octet_unalignment) & 0x1f) >> 2); \
|
||||
while (i--) \
|
||||
{ \
|
||||
IPCOM_CPY_32_BITS_UNALIGNED(shift1, shift2); \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_ASM
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_update2_asm(void *pbuf, Ip_size_t bytes);
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_memcpy_asm(void *dst, void *src, Ip_size_t bytes);
|
||||
#endif
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
IP_EXTERN Ip_u32
|
||||
ipcom_in_checksum_update2(void *pbuf, Ip_size_t bytes);
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_update
|
||||
*===========================================================================
|
||||
* Description: Computes the internet checksum (RFC 1071). NOTE
|
||||
* it does not compute the 1 complement checksum.
|
||||
* Parameters: pbuf and bytes.
|
||||
* Returns: A standard internet checksum..
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_update(void *pbuf, Ip_size_t bytes)
|
||||
{
|
||||
Ip_u32 sum;
|
||||
#if defined(IP_PORT_LKM) && !defined(IP_TARGET_ARM) && !defined(IP_TARGET_MIPS)
|
||||
sum = ipcom_in_checksum_update2(pbuf, bytes);
|
||||
/* One folding step MUST be done to avoid overflow in IPNET/IPLITE */
|
||||
return (sum & 0xffff) + (sum >> 16);
|
||||
#else
|
||||
Ip_u32 nwords;
|
||||
Ip_u16 *buf;
|
||||
#ifdef IPCOM_USE_ASM
|
||||
if (IP_LIKELY(((long)pbuf & 0x1) == 0)
|
||||
&& IP_LIKELY(bytes >= sizeof(Ip_u16)))
|
||||
{
|
||||
sum = ipcom_in_checksum_update2_asm(pbuf, bytes);
|
||||
/* One folding step MUST be done to avoid overflow in IPNET/IPLITE */
|
||||
return (sum & 0xffff) + (sum >> 16);
|
||||
}
|
||||
#endif
|
||||
buf = (Ip_u16 *) pbuf;
|
||||
sum = 0;
|
||||
|
||||
for (nwords = (Ip_u32)bytes >> 5; nwords > 0; nwords--)
|
||||
{
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
sum += *buf++; sum += *buf++; sum += *buf++; sum += *buf++;
|
||||
}
|
||||
for (nwords = (Ip_u32)(bytes & 0x1f) >> 1; nwords > 0; nwords--)
|
||||
sum += *buf++;
|
||||
|
||||
/* Add left-over byte, if any. */
|
||||
if (bytes & 0x01)
|
||||
sum += *buf & ip_htons(0xff00);
|
||||
|
||||
return sum;
|
||||
#endif /* IP_PORT_LKM && !IP_TARGET_ARM*/
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_finish
|
||||
*===========================================================================
|
||||
* Description: Computes the one complement internet checksum (RFC 1071).
|
||||
* Parameters: sum - The accumulated 32 bit internet sum.
|
||||
* Returns: A one complement standard internet checksum.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u16
|
||||
ipcom_in_checksum_finish(Ip_u32 sum)
|
||||
{
|
||||
/* Fold 32-bit sum to 16 bits. */
|
||||
while (sum >> 16)
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
|
||||
return (Ip_u16)~(Ip_u16)sum;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum
|
||||
*===========================================================================
|
||||
* Description: Calculates the checksum on the IPv4 header.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u16
|
||||
ipcom_in_checksum(void *buf, Ip_size_t bytes)
|
||||
{
|
||||
Ip_u32 sum;
|
||||
|
||||
sum = ipcom_in_checksum_update(buf, bytes);
|
||||
|
||||
/* inline ipcom_in_checksum_finish code: */
|
||||
while (sum >> 16)
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
|
||||
return (Ip_u16)~(Ip_u16)sum;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_update_pkt
|
||||
*===========================================================================
|
||||
* Description: Calculates the checksum on the IPv4 header.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_update_pkt(Ipcom_pkt *pkt, Ip_u32 chksum)
|
||||
{
|
||||
Ip_u32 sum = chksum;
|
||||
Ip_u32 pkt_sum = 0;
|
||||
int len = 0;
|
||||
while (pkt != IP_NULL)
|
||||
{
|
||||
pkt_sum = ipcom_in_checksum_update(pkt->data+pkt->start, pkt->end-pkt->start);
|
||||
if (len & 0x01)
|
||||
pkt_sum = (pkt_sum >> 8) + ((pkt_sum & 0xff) << 8);
|
||||
sum += pkt_sum;
|
||||
len += (pkt->end - pkt->start);
|
||||
pkt = pkt->next_part;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_pkt
|
||||
*===========================================================================
|
||||
* Description: Calculates the checksum on the IPv4 header.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u16
|
||||
ipcom_in_checksum_pkt(Ipcom_pkt *pkt, Ip_u32 chksum)
|
||||
{
|
||||
Ip_u32 sum = ipcom_in_checksum_update_pkt(pkt, chksum);
|
||||
return ipcom_in_checksum_finish(sum);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_in_checksum_memcpy
|
||||
*===========================================================================
|
||||
* Description: Copies data and calculate the internet checksum at the same
|
||||
* time.
|
||||
* Parameters: dst - Destination buffer.
|
||||
* src - Source buffer.
|
||||
* len - Number of octets to copy.
|
||||
* Returns: The intermediate internet checksum, use
|
||||
* ipcom_in_checksum_finish() to get the actual checksum.
|
||||
*
|
||||
*/
|
||||
#if !defined(IP_PORT_LKM) || (defined(IP_PORT_LKM) && (defined(IP_TARGET_ARM) || defined(IP_TARGET_MIPS)))
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_in_checksum_memcpy(void *dst, void *src, Ip_size_t len)
|
||||
{
|
||||
#ifdef IPCOM_USE_ASM
|
||||
Ip_u32 sum = ipcom_in_checksum_memcpy_asm(dst, src, len);
|
||||
/* One folding step MUST be done to avoid overflow in IPNET/IPLITE */
|
||||
return (sum & 0xffff) + (sum >> 16);
|
||||
#elif defined(IPBOUNDS) || defined(__BOUNDS_CHECKING_ON) || defined(IP_PORT_LKM)
|
||||
(void)ipcom_copy_from_user(dst, src, len);
|
||||
return ipcom_in_checksum_update(dst, len);
|
||||
#else
|
||||
Ip_u8 *dst_u8;
|
||||
Ip_u8 *src_u8;
|
||||
Ip_u32 *dst_u32;
|
||||
Ip_u32 *src_u32;
|
||||
Ip_u32 data;
|
||||
Ip_u32 src_data;
|
||||
Ip_u32 chksum = 0;
|
||||
int i;
|
||||
int initial_octets;
|
||||
int octet_unalignment = 0;
|
||||
Ip_bool dst_addr_is_odd = (Ip_bool)((Ip_ptrdiff_t) dst & 0x1);
|
||||
|
||||
initial_octets = (int) IP_MIN(((-(Ip_ptrdiff_t) dst) & 0x3), (Ip_ptrdiff_t) len);
|
||||
if (initial_octets == 0)
|
||||
{
|
||||
dst_u32 = (Ip_u32 *) dst;
|
||||
src_u32 = (Ip_u32 *) src;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_u8 = (Ip_u8 *) dst;
|
||||
src_u8 = (Ip_u8 *) src;
|
||||
for (i = 0; i < initial_octets; ++i)
|
||||
{
|
||||
/* Copy initial octets (so that dst will be 32-bit aligned) */
|
||||
data = *dst_u8++ = *src_u8++;
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
if ((i ^ dst_addr_is_odd) & 0x1)
|
||||
chksum += data;
|
||||
else
|
||||
chksum += data << 8;
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
if ((i ^ dst_addr_is_odd) & 0x1)
|
||||
chksum += data << 8;
|
||||
else
|
||||
chksum += data;
|
||||
#endif
|
||||
}
|
||||
dst_u32 = (Ip_u32 *) dst_u8;
|
||||
src_u32 = (Ip_u32 *) src_u8;
|
||||
len -= initial_octets;
|
||||
}
|
||||
/* dst is now 32-bit aligned */
|
||||
|
||||
if (((Ip_ptrdiff_t) dst_u32 & 0x3) == ((Ip_ptrdiff_t) src_u32 & 0x3))
|
||||
{
|
||||
/* Both src and dst is now on an even 32-bit boundary */
|
||||
i = (int)(len >> 5);
|
||||
while (i--)
|
||||
{
|
||||
/* Big main copy loop */
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
}
|
||||
|
||||
i = (int)((len & 0x1f) >> 2);
|
||||
while (i--)
|
||||
{
|
||||
/* Small main copy loop */
|
||||
IPCOM_CPY_32_BITS_ALIGNED;
|
||||
}
|
||||
|
||||
len -= len & ~0x3;
|
||||
}
|
||||
else if (len >= 4)
|
||||
{
|
||||
/* dst and src cannot be aligned */
|
||||
octet_unalignment = (int)((Ip_ptrdiff_t) src_u32 & 0x3);
|
||||
src_u32 = (Ip_u32 *) ((Ip_u8 *) src_u32 - octet_unalignment);
|
||||
src_data = *src_u32++;
|
||||
/* src is now 32-bit aligned */
|
||||
|
||||
switch (octet_unalignment)
|
||||
{
|
||||
case 1:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(8, 24);
|
||||
break;
|
||||
case 2:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(16, 16);
|
||||
break;
|
||||
case 3:
|
||||
IPCOM_UNALIGNED_CPY_LOOP(24, 8);
|
||||
break;
|
||||
default:
|
||||
IP_PANIC();
|
||||
break;
|
||||
}
|
||||
--src_u32;
|
||||
len -= ((len - octet_unalignment) & ~0x3);
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
/* Copy data that cannot be written in 32-bit chunks */
|
||||
src_u8 = (Ip_u8 *) src_u32 + octet_unalignment;
|
||||
dst_u8 = (Ip_u8 *) dst_u32;
|
||||
for (i = 0; i < (int) len; ++i)
|
||||
{
|
||||
data = *dst_u8++ = *src_u8++;
|
||||
#ifdef IP_BIG_ENDIAN
|
||||
if (i & 0x1)
|
||||
chksum += data;
|
||||
else
|
||||
chksum += data << 8;
|
||||
#else /* IP_LITTLE_ENDIAN */
|
||||
if (i & 0x1)
|
||||
chksum += data << 8;
|
||||
else
|
||||
chksum += data;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (dst_addr_is_odd)
|
||||
{
|
||||
/* The checksum has the low and hi bytes swaped */
|
||||
return (((Ip_u8 *) &chksum)[0] << 8)
|
||||
+ ((Ip_u8 *) &chksum)[1]
|
||||
+ (((Ip_u8 *) &chksum)[2] << 8)
|
||||
+ ((Ip_u8 *) &chksum)[3]; /*lint !e647 */
|
||||
}
|
||||
|
||||
return chksum;
|
||||
#endif /* IPCOM_USE_ASM */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ctime.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_ctime.c,v $
|
||||
* $Author: lob $ $Date: 2004-09-01 18:06:49 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_asctime_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ASCTIME_R) && IPCOM_ASCTIME_R == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_asctime_r(const struct Ip_tm *tm, char *buf)
|
||||
{
|
||||
static const char *day_name[8] =
|
||||
{
|
||||
"Sun",
|
||||
"Mon",
|
||||
"Tue",
|
||||
"Wed",
|
||||
"Thu",
|
||||
"Fri",
|
||||
"Sat",
|
||||
"ERR"
|
||||
};
|
||||
static const char *month_name[13] =
|
||||
{
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
"ERR"
|
||||
};
|
||||
|
||||
ipcom_sprintf(buf, "%s %s %02d %02d:%02d:%02d %04d\n",
|
||||
day_name[IP_MIN(tm->tm_wday, 7)],
|
||||
month_name[IP_MIN(tm->tm_mon, 12)],
|
||||
tm->tm_mday,
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec,
|
||||
tm->tm_year + 1900);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_asctime
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ASCTIME) && IPCOM_ASCTIME == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_asctime(const struct Ip_tm *tm)
|
||||
{
|
||||
static char buf[26];
|
||||
|
||||
return ipcom_asctime_r(tm, (char *)buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ctime_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_CTIME_R) && IPCOM_CTIME_R == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_ctime_r(const Ip_time_t *timep, char *buf)
|
||||
{
|
||||
struct Ip_tm tm;
|
||||
|
||||
return ipcom_asctime_r(ipcom_localtime_r(timep, &tm), buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ctime
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_CTIME) && IPCOM_CTIME == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_ctime(const Ip_time_t *timep)
|
||||
{
|
||||
static char buf[26];
|
||||
|
||||
return ipcom_ctime_r(timep, (char *)buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ctype.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_ctype.c,v $
|
||||
* $Author: ulf $ $Date: 2008-10-13 11:09:39 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_PORT_WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#elif defined(IP_PORT_OSE) && defined(IP_TARGET_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
#elif defined(IP_PORT_VXWORKS)
|
||||
#include <vxWorks.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isspace
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISSPACE) && IPCOM_ISSPACE == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isspace(int c)
|
||||
{
|
||||
return isspace(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isalpha
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISALPHA) && IPCOM_ISALPHA == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isalpha(int c)
|
||||
{
|
||||
return isalpha(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isgraph
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISGRAPH) && IPCOM_ISGRAPH == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isgraph(int c)
|
||||
{
|
||||
return isgraph(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isupper
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISUPPER) && IPCOM_ISUPPER == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isupper(int c)
|
||||
{
|
||||
return isupper(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_islower
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISLOWER) && IPCOM_ISLOWER == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_islower(int c)
|
||||
{
|
||||
return islower(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isdigit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISDIGIT) && IPCOM_ISDIGIT == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isdigit(int c)
|
||||
{
|
||||
return isdigit(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isprint
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISPRINT) && IPCOM_ISPRINT == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isprint(int c)
|
||||
{
|
||||
return isprint(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isalnum
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISALNUM) && IPCOM_ISALNUM == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isalnum(int c)
|
||||
{
|
||||
return isalnum(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_iscntrl
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISCNTRL) && IPCOM_ISCNTRL == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_iscntrl(int c)
|
||||
{
|
||||
return iscntrl(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ispunct
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISPUNCT) && IPCOM_ISPUNCT == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_ispunct(int c)
|
||||
{
|
||||
return ispunct(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isxdigit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISXDIGIT) && IPCOM_ISXDIGIT == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isxdigit(int c)
|
||||
{
|
||||
return isxdigit(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_isascii
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ISASCII) && IPCOM_ISASCII == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_isascii(int c)
|
||||
{
|
||||
return isascii(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_toupper
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_TOUPPER) && IPCOM_TOUPPER == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_toupper(int c)
|
||||
{
|
||||
return toupper(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_tolower
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_TOLOWER) && IPCOM_TOLOWER == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_tolower(int c)
|
||||
{
|
||||
return tolower(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_dns.c,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_dns.c,v $
|
||||
* $Author: lob $ $Date: 2007-02-08 14:49:11 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_cstyle.h"
|
||||
|
||||
#ifdef IPDNSC
|
||||
#include <ipdnsc.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipcom_dns_init_ok = 0;
|
||||
|
||||
#ifdef IPDNSC
|
||||
IP_PUBLIC Ipdnsc_api ipcom_dns;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_exit.c,v $ $Revision: 1.16 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_exit.c,v $
|
||||
* $Author: ulf $ $Date: 2010-09-09 08:55:22 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
#include <ose.h>
|
||||
#endif
|
||||
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
#include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_shell.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_abort
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ABORT) && IPCOM_ABORT == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_abort(void)
|
||||
{
|
||||
IP_PANIC();
|
||||
|
||||
#if defined(IP_PORT_OSE5)
|
||||
efs_abort(__FILE__, __LINE__);
|
||||
#elif defined(IP_PORT_RTCORE)
|
||||
ipcom_proc_exit();
|
||||
#elif !defined(IP_PORT_ITRON) && \
|
||||
(!defined(IP_PORT_INTEGRITY) || !defined(INT_178B))
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_exit
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_EXIT) && IPCOM_EXIT == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_exit(int status)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
ipcom_shell_exit(status);
|
||||
#elif defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
exit(status);
|
||||
#else
|
||||
IPCOM_UNUSED_ARG(status);
|
||||
ipcom_proc_exit();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ffs.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_ffs.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-04 11:20:10 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Firstname Lastname <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ffs
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_ffs(Ip_u32 mask)
|
||||
{
|
||||
int bit;
|
||||
|
||||
if(mask == 0)
|
||||
return 0;
|
||||
|
||||
for(bit = 1; !(mask & 1); bit++)
|
||||
mask >>= 1;
|
||||
|
||||
return bit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_generic_llpipe.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_generic_llpipe.c,v $
|
||||
* $Author: dlkrejsa $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* IPCOM generic lockless pipes implementation.
|
||||
* Two restrictions apply:
|
||||
*
|
||||
* 1: Only one sender and one receiver must use the pipe at the same time.
|
||||
* 2: Sender and receiver processes must run with the same priority or have
|
||||
* hard affinity to different cores.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_pipe.h>
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_atomic.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_pipe_lockless
|
||||
*===========================================================================
|
||||
* Lockless pipe
|
||||
*/
|
||||
typedef struct Ipcom_pipe_lockless_struct
|
||||
{
|
||||
int capacity;
|
||||
Ipcom_atomic_t head;
|
||||
Ipcom_atomic_t tail;
|
||||
void **elem;
|
||||
}
|
||||
Ipcom_pipe_lockless;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ipcom_pipe_lockless_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_dtor_helper
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_lockless_pipe_dtor_helper(Ipcom_pipe_lockless *p)
|
||||
{
|
||||
ipcom_free(p->elem);
|
||||
ipcom_free(p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_dtor
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_lockless_pipe_dtor(Ipcom_pipe *pipe)
|
||||
{
|
||||
ipcom_lockless_pipe_dtor(pipe->p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_new_fifo
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipcom_pipe_lockless *
|
||||
ipcom_lockless_pipe_new_fifo(int msg_limit)
|
||||
{
|
||||
Ipcom_pipe_lockless *pipe;
|
||||
|
||||
pipe = ipcom_calloc(1, sizeof(Ipcom_pipe_lockless));
|
||||
if (pipe == IP_NULL)
|
||||
return IPCOM_PIPE_INVALID;
|
||||
|
||||
pipe->elem = ipcom_calloc(msg_limit, sizeof(void*));
|
||||
if (pipe->elem == IP_NULL)
|
||||
goto errout;
|
||||
|
||||
pipe->capacity = msg_limit;
|
||||
ipcom_atomic_set(&pipe->head, 0);
|
||||
ipcom_atomic_set(&pipe->tail, 0);
|
||||
|
||||
return pipe;
|
||||
|
||||
errout:
|
||||
ipcom_lockless_pipe_dtor_helper(pipe);
|
||||
return IPCOM_PIPE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_poll_send
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_lockless_pipe_poll_send(Ipcom_pipe *pipe, void *msg, Ip_bool poll)
|
||||
{
|
||||
Ipcom_pipe_lockless *p = pipe->p;
|
||||
int tail;
|
||||
int new_tail;
|
||||
|
||||
/* p->tail can only be modified in ipcom_lockless_pipe_send() */
|
||||
tail = ipcom_atomic_get(&p->tail);
|
||||
new_tail = tail + 1;
|
||||
if (new_tail == p->capacity)
|
||||
new_tail = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (new_tail != ipcom_atomic_get(&p->head))
|
||||
{
|
||||
p->elem[tail] = msg;
|
||||
ipcom_wmb();
|
||||
ipcom_atomic_set(&p->tail, new_tail);
|
||||
break;
|
||||
}
|
||||
else if (poll == IP_FALSE)
|
||||
return IP_FALSE;
|
||||
ipcom_proc_yield(); /* Yield for receiver */
|
||||
}
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_send
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_lockless_pipe_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
(void)ipcom_lockless_pipe_poll_send(pipe, msg, IP_TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_try_send
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_lockless_pipe_try_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
return ipcom_lockless_pipe_poll_send(pipe, msg, IP_FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_poll_recv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_lockless_pipe_poll_recv(Ipcom_pipe *pipe, void **pmsg, Ip_bool poll)
|
||||
{
|
||||
Ipcom_pipe_lockless *p = pipe->p;
|
||||
int head;
|
||||
|
||||
head = ipcom_atomic_get(&p->head);
|
||||
for (;;)
|
||||
{
|
||||
if (head != ipcom_atomic_get(&p->tail))
|
||||
{
|
||||
*pmsg = p->elem[head];
|
||||
ipcom_rmb();
|
||||
if (++head == p->capacity)
|
||||
head = 0;
|
||||
ipcom_atomic_set(&p->head, head);
|
||||
break;
|
||||
}
|
||||
else if (poll == IP_FALSE)
|
||||
return IP_FALSE;
|
||||
ipcom_proc_yield(); /* Yield for sender */
|
||||
}
|
||||
return IP_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_recv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_lockless_pipe_recv(Ipcom_pipe *pipe, void **pmsg)
|
||||
{
|
||||
(void)ipcom_lockless_pipe_poll_recv(pipe, pmsg, IP_TRUE);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lockless_pipe_recv_with_tmo
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_lockless_pipe_recv_with_tmo(Ipcom_pipe *pipe, void **pmsg, struct Ip_timeval *tv)
|
||||
{
|
||||
struct Ip_timeval timeout;
|
||||
struct Ip_timeval now;
|
||||
|
||||
if (tv->tv_sec == 0 && tv->tv_usec == 0)
|
||||
{
|
||||
if (ipcom_lockless_pipe_poll_recv(pipe, pmsg, IP_FALSE))
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
goto empty;
|
||||
}
|
||||
|
||||
ipcom_microtime(&now);
|
||||
ip_timeval_add(&now, tv, &timeout);
|
||||
|
||||
do {
|
||||
if (ipcom_lockless_pipe_poll_recv(pipe, pmsg, IP_FALSE))
|
||||
return IPCOM_SUCCESS;
|
||||
ipcom_microtime(&now);
|
||||
} while (ip_timeval_cmp(&now, &timeout, <));
|
||||
|
||||
empty:
|
||||
|
||||
return IPCOM_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pipe_lockless_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ipcom_pipe_lockless_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr)
|
||||
{
|
||||
static Ipcom_pipe_ops ipcom_generic_llpipe_ops = {
|
||||
ipcom_lockless_pipe_dtor,
|
||||
ipcom_lockless_pipe_send,
|
||||
ipcom_lockless_pipe_try_send,
|
||||
ipcom_lockless_pipe_recv,
|
||||
ipcom_lockless_pipe_recv_with_tmo,
|
||||
};
|
||||
|
||||
pipe->p = ipcom_lockless_pipe_new_fifo(attr->msg_limit);
|
||||
if (pipe->p == IPCOM_PIPE_INVALID)
|
||||
return IPCOM_ERR_FAILED;
|
||||
|
||||
pipe->ops = &ipcom_generic_llpipe_ops;
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,523 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_generic_pipe.c,v $ $Revision: 1.13.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_generic_pipe.c,v $
|
||||
* $Author: kenneth $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* IPCOM generic pipes implementation. Supports one reader and multiple
|
||||
* writers.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_pipe.h>
|
||||
#include <ipcom_spinlock.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_pipe_generic
|
||||
*===========================================================================
|
||||
* Generic pipe
|
||||
*/
|
||||
typedef struct Ipcom_pipe_generic_struct
|
||||
{
|
||||
Ipcom_spinlock lock; /* Protects all members of this
|
||||
structure */
|
||||
void **msgs; /* Array of pointer to the
|
||||
messages currently waiting to
|
||||
be read */
|
||||
int next_send_slot; /* Index of first free slot in
|
||||
the pipe */
|
||||
int next_recv_slot; /* Index of the next message to
|
||||
return in receive */
|
||||
int msg_limit; /* Maximum number of message
|
||||
this pipe can hold*/
|
||||
Ip_pid_t creator_pid; /* PID of the creator of this
|
||||
pipe */
|
||||
int reader_cnt; /* Number of processes waiting
|
||||
for this pipe to become
|
||||
redable */
|
||||
Ipcom_block reader_sem; /* Semaphore waiting processes
|
||||
sleep on if the pipe was
|
||||
empty during a receive call */
|
||||
int writer_cnt; /* Number of precesses waiting
|
||||
for this pipe to become
|
||||
writable */
|
||||
Ipcom_sem writer_sem; /* Semaphore waiting processes
|
||||
sleep on if their message
|
||||
could not be written */
|
||||
}
|
||||
Ipcom_pipe_generic;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ipcom_pipe_generic_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_try_recv_locked
|
||||
*===========================================================================
|
||||
* Description: Tries to receive a message from the pipe.
|
||||
* Parameters: pipe - the pipe the message should be received from
|
||||
* pmsg - pointer to where the message pointer should be
|
||||
* stored if the call is successful.
|
||||
* Returns: -1 = operation failed, pipe is empty
|
||||
* 0 = operation successful
|
||||
* 0> = operation successful, need to wake return value
|
||||
* of writers.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_generic_pipe_try_recv_locked(Ipcom_pipe *pipe, void **pmsg)
|
||||
{
|
||||
Ipcom_pipe_generic *p = pipe->p;
|
||||
int next_recv_slot = p->next_recv_slot;
|
||||
|
||||
if (next_recv_slot == p->next_send_slot)
|
||||
/* Pipe is empty */
|
||||
return -1;
|
||||
|
||||
*pmsg = p->msgs[next_recv_slot];
|
||||
p->next_recv_slot = next_recv_slot + 1;
|
||||
if (p->next_recv_slot == p->msg_limit)
|
||||
p->next_recv_slot = 0;
|
||||
|
||||
if (p->next_recv_slot == p->next_send_slot
|
||||
&& IP_UNLIKELY(p->writer_cnt > 0))
|
||||
{
|
||||
/* Pipe empty and there is at least one task waiting to write
|
||||
this pipe. NOTE: waiting writers are only woken when the
|
||||
pipe gets empty to avoid too much context switches between
|
||||
taskes. */
|
||||
int writer_cnt = p->writer_cnt;
|
||||
|
||||
p->writer_cnt = 0;
|
||||
return writer_cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_try_send_locked
|
||||
*===========================================================================
|
||||
* Description: Tries to send one message to the specified pipe. This
|
||||
* function must only be called with pipe lock the be held.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns: -1 = operation failed, pipe is full
|
||||
* 0 = operation successful
|
||||
* 0> = operation successful, need to wake return value
|
||||
* of readers.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_generic_pipe_try_send_locked(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_generic *p = pipe->p;
|
||||
int next_send_slot;
|
||||
int this_send_slot;
|
||||
int reader_cnt;
|
||||
|
||||
this_send_slot = p->next_send_slot;
|
||||
next_send_slot = this_send_slot + 1;
|
||||
if (next_send_slot == p->msg_limit)
|
||||
next_send_slot = 0;
|
||||
|
||||
if (IP_UNLIKELY(next_send_slot == p->next_recv_slot))
|
||||
/* Pipe is full */
|
||||
return -1;
|
||||
|
||||
p->msgs[this_send_slot] = msg;
|
||||
p->next_send_slot = next_send_slot;
|
||||
|
||||
reader_cnt = p->reader_cnt;
|
||||
p->reader_cnt = 0;
|
||||
|
||||
return reader_cnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_dtor_helper
|
||||
*===========================================================================
|
||||
* Description: Destroys a generic pipe.
|
||||
* Parameters: p - the Ipcom_generic_pipe to destroy
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_generic_pipe_dtor_helper(Ipcom_pipe_generic *p)
|
||||
{
|
||||
if (p->lock != IPCOM_SPINLOCK_INVALID)
|
||||
ipcom_spinlock_delete(&p->lock);
|
||||
if (p->reader_sem != IPCOM_BLOCK_INVALID)
|
||||
ipcom_block_delete(&p->reader_sem);
|
||||
if (p->writer_sem != IPCOM_SEM_INVALID)
|
||||
ipcom_sem_delete(&p->writer_sem);
|
||||
ipcom_free(p->msgs);
|
||||
ipcom_free(p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_dtor
|
||||
*===========================================================================
|
||||
* Description: Destroys a pipe.
|
||||
* Parameters: pipe - the pipe do destroy
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_generic_pipe_dtor(Ipcom_pipe *pipe)
|
||||
{
|
||||
ipcom_generic_pipe_dtor_helper(pipe->p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_new_fifo
|
||||
*===========================================================================
|
||||
* Description: Creates a new pipe.
|
||||
* Parameters: msg_limit - maximum number of messages this pipe can hold
|
||||
* Returns: Pointer the the newly created pipe or
|
||||
* IPCOM_PIPE_INVALID if a new pipe could not be created.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipcom_pipe_generic *
|
||||
ipcom_generic_pipe_new_fifo(int msg_limit)
|
||||
{
|
||||
Ipcom_pipe_generic *pipe;
|
||||
|
||||
pipe = ipcom_calloc(1, sizeof(Ipcom_pipe_generic));
|
||||
if (pipe == IP_NULL)
|
||||
return IPCOM_PIPE_INVALID;
|
||||
|
||||
pipe->msgs = ipcom_calloc(msg_limit, sizeof(void*));
|
||||
if (pipe->msgs == IP_NULL)
|
||||
goto errout;
|
||||
|
||||
if (ipcom_spinlock_create(&pipe->lock) != IPCOM_SUCCESS)
|
||||
goto errout;
|
||||
|
||||
pipe->msg_limit = msg_limit;
|
||||
pipe->creator_pid = ipcom_getpid();
|
||||
if (ipcom_block_create(&pipe->reader_sem) != IPCOM_SUCCESS)
|
||||
goto errout;
|
||||
if (ipcom_sem_create(&pipe->writer_sem, 0) != IPCOM_SUCCESS)
|
||||
goto errout;
|
||||
|
||||
return pipe;
|
||||
|
||||
errout:
|
||||
ipcom_generic_pipe_dtor_helper(pipe);
|
||||
return IPCOM_PIPE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_send
|
||||
*===========================================================================
|
||||
* Description: Sends one message to the specified pipe.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_generic_pipe_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_generic *p = pipe->p;
|
||||
int reader_cnt;
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
reader_cnt = ipcom_generic_pipe_try_send_locked(pipe, msg);
|
||||
if (reader_cnt >= 0)
|
||||
break;
|
||||
/* else: Failed to send message since the pipe was full */
|
||||
|
||||
++p->writer_cnt;
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
/* Wait until the pipe becomes non-full */
|
||||
ipcom_sem_wait(p->writer_sem);
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
}
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
|
||||
while (reader_cnt > 0)
|
||||
{
|
||||
ipcom_block_post(p->reader_sem);
|
||||
--reader_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_try_send
|
||||
*===========================================================================
|
||||
* Description: Tries to send one message to the specified pipe.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns: IP_TRUE - message was successfully sent
|
||||
* IP_FALSE - operation was aborted before the message
|
||||
* got sent
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_generic_pipe_try_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_generic *p = pipe->p;
|
||||
int reader_cnt;
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
reader_cnt = ipcom_generic_pipe_try_send_locked(pipe, msg);
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
|
||||
while (reader_cnt > 0)
|
||||
{
|
||||
ipcom_block_post(p->reader_sem);
|
||||
--reader_cnt;
|
||||
}
|
||||
|
||||
return reader_cnt == 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_recv_with_tmo
|
||||
*===========================================================================
|
||||
* Description: Receives one message from a pipe, the operation will
|
||||
* be aborted if nothing is received within a
|
||||
* specific duration.
|
||||
* Parameters: pipe - the pipe to receive from
|
||||
* psmg - pointer to where a pointer to the message
|
||||
* should be stored
|
||||
* tv - maximum duration to wait for a message, IP_NULL
|
||||
* means wait forever.
|
||||
* Returns: IPCOM_SUCCESS - message was received
|
||||
* IPCOM_ERR_TIMEOUT - the specified duration elapsed
|
||||
* without any message being received.
|
||||
* IPCOM_ERR_INTERRUPT - operation was aborted before any message
|
||||
* was received.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_generic_pipe_recv_with_tmo(Ipcom_pipe *pipe, void **pmsg, struct Ip_timeval *tv)
|
||||
{
|
||||
Ipcom_pipe_generic *p = pipe->p;
|
||||
Ip_s32 msec = (Ip_s32) (tv
|
||||
? tv->tv_sec * 1000 + tv->tv_usec / 1000
|
||||
: IPC_TIMEOUT_INFINITE);
|
||||
int ret = IPCOM_SUCCESS;
|
||||
int writer_cnt;
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
writer_cnt = ipcom_generic_pipe_try_recv_locked(pipe, pmsg);
|
||||
if (writer_cnt >= 0)
|
||||
break;
|
||||
|
||||
++p->reader_cnt;
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
/*
|
||||
* Pipe was empty, wait until there is something to receive
|
||||
*/
|
||||
ret = ipcom_block_wait(p->reader_sem, msec);
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
if (ret != IPCOM_SUCCESS)
|
||||
break;
|
||||
|
||||
if (tv != IP_NULL)
|
||||
{
|
||||
/*
|
||||
* Running with a timeout, this call should return a
|
||||
* message, but another process might steal the message
|
||||
* before this process got hold of the lock. Pretend we
|
||||
* got interrupted if that happens.
|
||||
*/
|
||||
writer_cnt = ipcom_generic_pipe_try_recv_locked(pipe, pmsg);
|
||||
if (writer_cnt < 0)
|
||||
{
|
||||
ret = IPCOM_ERR_INTERRUPT;
|
||||
--p->reader_cnt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
|
||||
while (writer_cnt > 0)
|
||||
{
|
||||
ipcom_sem_post(p->writer_sem);
|
||||
--writer_cnt;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_generic_pipe_recv
|
||||
*===========================================================================
|
||||
* Description: Receives one message from the specified pipe.
|
||||
* Parameters: pipe - a pipe
|
||||
* pmsg - pointer to where a pointer to the received
|
||||
* message should be stored
|
||||
* Returns: IPCOM_SUCCESS - message was received
|
||||
* IPCOM_ERR_INTERRUPT - operation was aborted before any message
|
||||
* was received.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_generic_pipe_recv(Ipcom_pipe *pipe, void **pmsg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
do
|
||||
{
|
||||
ret = ipcom_generic_pipe_recv_with_tmo(pipe, pmsg, IP_NULL);
|
||||
} while (ret == IPCOM_ERR_TIMEOUT);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pipe_generic_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ipcom_pipe_generic_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr)
|
||||
{
|
||||
static Ipcom_pipe_ops ipcom_generic_pipe_ops = {
|
||||
ipcom_generic_pipe_dtor,
|
||||
ipcom_generic_pipe_send,
|
||||
ipcom_generic_pipe_try_send,
|
||||
ipcom_generic_pipe_recv,
|
||||
ipcom_generic_pipe_recv_with_tmo,
|
||||
};
|
||||
|
||||
pipe->p = ipcom_generic_pipe_new_fifo(attr->msg_limit);
|
||||
if (pipe->p == IPCOM_PIPE_INVALID)
|
||||
return IPCOM_ERR_FAILED;
|
||||
|
||||
pipe->ops = &ipcom_generic_pipe_ops;
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,827 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_generic_slab.c,v $ $Revision: 1.11.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_generic_slab.c,v $
|
||||
* $Author: hxie $ $Date: 2013-01-09 04:40:09 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
Implementation of the IPCOM slab cache API using only other the
|
||||
public IPCOM API. This implementation will run unmodified on all OS:es
|
||||
supported by IPCOM.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#define IPCOM_KERNEL
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
#define IPCOM_USE_SLAB_CMD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Defines the maximum number of empty slabs that will be kept around
|
||||
* before the memory they occupies is released back to the memory
|
||||
* pool.
|
||||
*/
|
||||
#define IPNET_GENERIC_SLAB_AUTO_GC_THRESH 1
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_shell.h"
|
||||
#include "ipcom_slab.h"
|
||||
|
||||
#ifdef IPCOM_USE_SLAB_CMD
|
||||
#include "ipcom_getopt.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SLAB_SIZEOF(data_type) ((Ip_size_t) (Ip_ptrdiff_t) (((data_type*)IP_NULL) + 1))
|
||||
#define IPCOM_SLAB_ALIGN(size, align) ((Ip_size_t) (Ip_ptrdiff_t) IP_PTR_ALIGN(size, align))
|
||||
|
||||
/* Minimum number of objects that will be put into each slab. The
|
||||
actual number will be rouded up to fit an integer
|
||||
IPCOM_SLAB_PAGE_SIZE as close as possible */
|
||||
#define IPCOM_SLAB_FEW_OBJS 10
|
||||
#define IPCOM_SLAB_AVERAGE_OBJS 30
|
||||
#define IPCOM_SLAB_MANY_OBJS 100
|
||||
|
||||
/* Memory will always be allocated in multiple of this size */
|
||||
#define IPCOM_SLAB_PAGE_SIZE 4000
|
||||
|
||||
#define IPCOM_SLAB_LOCK(mc) \
|
||||
do { \
|
||||
if (IP_BIT_ISFALSE(mc->flags, IPCOM_SLAB_F_NO_LOCKING)) \
|
||||
ipcom_spinlock_lock(&mc->lock); \
|
||||
} while (0)
|
||||
|
||||
#define IPCOM_SLAB_UNLOCK(mc) \
|
||||
do { \
|
||||
if (IP_BIT_ISFALSE(mc->flags, IPCOM_SLAB_F_NO_LOCKING)) \
|
||||
ipcom_spinlock_unlock(&mc->lock); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Bottom level structure of a slab cache, this is the memory blocks
|
||||
being returned to the caller */
|
||||
typedef struct Ipcom_slab_obj_struct
|
||||
{
|
||||
struct Ipcom_slab_obj_struct *next;
|
||||
}
|
||||
Ipcom_slab_obj;
|
||||
|
||||
|
||||
typedef struct Ipcom_slab_struct
|
||||
{
|
||||
Ipcom_list list; /* List of slabs of this type */
|
||||
const unsigned total_objs; /* Total number of objects in this
|
||||
slab */
|
||||
unsigned allocated_objs;/* Number of allocated objects
|
||||
from this slab */
|
||||
Ipcom_slab_obj *free_objs; /* List of free objects in this
|
||||
slab */
|
||||
}
|
||||
Ipcom_slab;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
Ipcom_once_t ipcom_slab_once = IPCOM_ONCE_INIT;
|
||||
Ipcom_list ipcom_slab_memory_pool_list;
|
||||
IP_EXTERN void *(*ipcom_sys_malloc)(Ip_size_t size);
|
||||
IP_EXTERN void (*ipcom_sys_free)(void *ptr);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memory_pool_free
|
||||
*===========================================================================
|
||||
* Description: Return a buffer allocated with
|
||||
* ipcom_memory_pool_alloc() back to the pool.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_memory_pool_free(Ipcom_memory_pool *mp, Ip_size_t size, void *buf, Ip_u32 flags)
|
||||
{
|
||||
if (IP_BIT_ISSET(flags, IPCOM_SLAB_F_SYSMEM) && ipcom_sys_free != IP_NULL)
|
||||
ipcom_sys_free(buf);
|
||||
else
|
||||
ipcom_free(buf);
|
||||
|
||||
ipcom_atomic_add(&mp->bytes, (int)size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memory_pool_alloc
|
||||
*===========================================================================
|
||||
* Description: Allocates memory from the specified memory pool.
|
||||
* Parameters: mp - the memory pool to allocate from
|
||||
* size - number of bytes to allocate
|
||||
* flags - flag associated with the memory cache to be allocated
|
||||
* Returns: Pointer to a memory buffer of the specified size or
|
||||
* IP_NULL if the allocation failed.
|
||||
*
|
||||
*/
|
||||
IP_STATIC void *
|
||||
ipcom_memory_pool_alloc(Ipcom_memory_pool *mp, Ip_size_t size, Ip_u32 flags)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
if (ipcom_atomic_sub_and_return(&mp->bytes, (int)size) < 0)
|
||||
goto failed;
|
||||
|
||||
if (IP_BIT_ISSET(flags, IPCOM_SLAB_F_SYSMEM) && ipcom_sys_malloc != IP_NULL)
|
||||
{
|
||||
buf = ipcom_sys_malloc(size);
|
||||
ipcom_memset(buf, 0x00, size);
|
||||
}
|
||||
else
|
||||
buf = ipcom_calloc(1, size);
|
||||
|
||||
if (buf == IP_NULL)
|
||||
{
|
||||
IP_PANIC();
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (ipcom_atomic_get(&mp->bytes) < (int) mp->low)
|
||||
mp->low = ipcom_atomic_get(&mp->bytes);
|
||||
|
||||
return buf;
|
||||
|
||||
failed:
|
||||
ipcom_memory_pool_free(mp, size, IP_NULL, 0);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_get_size
|
||||
*===========================================================================
|
||||
* Description: Calculates the total, per object size and number of objects.
|
||||
* Parameters: mc - memory cache to do garbage collection on.
|
||||
* aligned_obj_size_ptr - Will contain the size each
|
||||
* object takes in memory, can be IP_NULL
|
||||
* num_objs_ptr - Will contain the total number of
|
||||
* objects, can be IP_NULL
|
||||
* Returns: The total amount of memory used by this slab.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_size_t
|
||||
ipcom_slab_get_size(Ipcom_memory_cache *mc,
|
||||
Ip_size_t *aligned_obj_size_ptr,
|
||||
unsigned *num_objs_ptr)
|
||||
{
|
||||
Ip_size_t aligned_obj_size;
|
||||
unsigned num_objs;
|
||||
Ip_size_t slab_size = IPCOM_SLAB_PAGE_SIZE;
|
||||
Ip_size_t calculated_size;
|
||||
|
||||
aligned_obj_size = IPCOM_SLAB_ALIGN(mc->obj_size, sizeof(void*));
|
||||
aligned_obj_size = IPCOM_SLAB_ALIGN(aligned_obj_size + sizeof(void*), mc->alignment);
|
||||
|
||||
switch (mc->flags & IPCOM_SLAB_F_MANY)
|
||||
{
|
||||
case IPCOM_SLAB_F_ONE:
|
||||
num_objs = 1;
|
||||
break;
|
||||
case IPCOM_SLAB_F_FEW:
|
||||
num_objs = IPCOM_SLAB_FEW_OBJS;
|
||||
break;
|
||||
case IPCOM_SLAB_F_MANY:
|
||||
num_objs = IPCOM_SLAB_MANY_OBJS;
|
||||
break;
|
||||
default:
|
||||
num_objs = IPCOM_SLAB_AVERAGE_OBJS;
|
||||
break;
|
||||
}
|
||||
|
||||
calculated_size = (IPCOM_SLAB_SIZEOF(Ipcom_slab)
|
||||
+ mc->alignment
|
||||
- sizeof(void*)
|
||||
+ num_objs * aligned_obj_size);
|
||||
|
||||
if (slab_size <= calculated_size)
|
||||
/* Figure out how many pages that are needed */
|
||||
slab_size *= (calculated_size + slab_size - 1) / slab_size;
|
||||
else
|
||||
{
|
||||
/* One slab page is enough, calculate how many objects that
|
||||
actual fit into the allocated memory */
|
||||
num_objs = (unsigned)((slab_size - (IPCOM_SLAB_SIZEOF(Ipcom_slab)
|
||||
+ mc->alignment
|
||||
- sizeof(void*))) / aligned_obj_size);
|
||||
}
|
||||
|
||||
if (aligned_obj_size_ptr)
|
||||
*aligned_obj_size_ptr = aligned_obj_size;
|
||||
if (num_objs_ptr)
|
||||
*num_objs_ptr = num_objs;
|
||||
|
||||
return slab_size;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_ptr_from_obj
|
||||
*===========================================================================
|
||||
* Description: Returns a pointer to where the slab structure the
|
||||
* object belongs to
|
||||
* Parameters: mc - A pointer to the memory cache structure the slab
|
||||
* is located in
|
||||
* obj - An object allocated from the passed memory cache.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_INLINE Ipcom_slab **
|
||||
ipcom_slab_ptr_from_obj(Ipcom_memory_cache *mc, void *obj)
|
||||
{
|
||||
return (Ipcom_slab **) ((char*) obj + IPCOM_SLAB_ALIGN(mc->obj_size, sizeof(void*)));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_dtor_objs
|
||||
*===========================================================================
|
||||
* Description: Frees all unused slabs within the specified slab cache.
|
||||
* Parameters: mc - memory cache to do garbage collection on.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_slab_dtor_objs(Ipcom_memory_cache *mc, Ipcom_slab *slab)
|
||||
{
|
||||
if (mc->dtor != IP_NULL)
|
||||
{
|
||||
Ipcom_slab_obj *obj;
|
||||
Ipcom_slab_obj *next_obj = slab->free_objs;
|
||||
|
||||
while (IP_NULL != (obj = next_obj))
|
||||
{
|
||||
next_obj = obj->next;
|
||||
mc->dtor(mc, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_garbage_collect
|
||||
*===========================================================================
|
||||
* Description: Frees all unused slabs within the specified slab cache.
|
||||
* Parameters: mc - memory cache to do garbage collection on.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_slab_garbage_collect(Ipcom_memory_cache *mc)
|
||||
{
|
||||
Ipcom_slab *slab;
|
||||
|
||||
IPCOM_SLAB_LOCK(mc);
|
||||
|
||||
while (IP_NULL != (slab = IPCOM_LIST_FIRST(&mc->slabs_empty)))
|
||||
{
|
||||
ipcom_list_remove(&slab->list);
|
||||
ipcom_slab_dtor_objs(mc, slab);
|
||||
ipcom_memory_pool_free(mc->memory_pool,
|
||||
ipcom_slab_get_size(mc, IP_NULL, IP_NULL),
|
||||
slab,
|
||||
mc->flags);
|
||||
}
|
||||
|
||||
IPCOM_SLAB_UNLOCK(mc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memory_pool_garbage_collect
|
||||
*===========================================================================
|
||||
* Description: Frees all unused memory in all the slabs using the
|
||||
* specified memory pool
|
||||
* Parameters: mp - memory pool to do garbage collection on.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_memory_pool_garbage_collect(Ipcom_memory_pool *mp)
|
||||
{
|
||||
Ipcom_memory_cache *mc;
|
||||
|
||||
for (mc = IPCOM_LIST_FIRST(&mp->memory_caches);
|
||||
mc != IP_NULL;
|
||||
mc = IPCOM_LIST_NEXT(&mc->list))
|
||||
{
|
||||
if (IP_BIT_ISSET(mc->flags, IPCOM_SLAB_F_NO_LOCKING))
|
||||
mc->do_garbage_collect = IP_TRUE;
|
||||
else
|
||||
ipcom_slab_garbage_collect(mc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef IPCOM_USE_SLAB_CMD
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_cmd_slab
|
||||
*===========================================================================
|
||||
* Description: Slab information shell command
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_cmd_slab(int argc, char **argv)
|
||||
{
|
||||
Ipcom_memory_pool *mp;
|
||||
Ipcom_memory_cache *mc;
|
||||
Ipcom_slab *slab;
|
||||
Ipcom_getopt opt;
|
||||
int i;
|
||||
Ip_bool garbage_collect = IP_FALSE;
|
||||
|
||||
ipcom_getopt_clear_r(&opt);
|
||||
while ((i = ipcom_getopt_r(argc, argv, "g", &opt)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'g':
|
||||
garbage_collect = IP_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (mp = IPCOM_LIST_FIRST(&ipcom_slab_memory_pool_list);
|
||||
mp != IP_NULL;
|
||||
mp = IPCOM_LIST_NEXT(&mp->list))
|
||||
{
|
||||
ipcom_printf("Memory pool: %s has %d bytes allocated, alloc high is %d, limit is %d"IP_LF,
|
||||
mp->name,
|
||||
mp->limit - ipcom_atomic_get(&mp->bytes),
|
||||
mp->limit - mp->low,
|
||||
mp->limit);
|
||||
for (mc = IPCOM_LIST_FIRST(&mp->memory_caches);
|
||||
mc != IP_NULL;
|
||||
mc = IPCOM_LIST_NEXT(&mc->list))
|
||||
{
|
||||
if (garbage_collect)
|
||||
ipcom_slab_garbage_collect(mc);
|
||||
|
||||
ipcom_printf(" Slab: %s, object size %d, alignment %d"IP_LF,
|
||||
mc->name, mc->obj_size, mc->alignment);
|
||||
|
||||
ipcom_printf(" Full: %d"IP_LF, mc->slabs_full.size);
|
||||
for (slab = IPCOM_LIST_FIRST(&mc->slabs_full);
|
||||
slab != IP_NULL;
|
||||
slab = IPCOM_LIST_NEXT(&slab->list))
|
||||
ipcom_printf(" Objects - total: %d, allocated %d"IP_LF,
|
||||
slab->total_objs,
|
||||
slab->allocated_objs);
|
||||
|
||||
ipcom_printf(" Partial: %d"IP_LF, mc->slabs_partial.size);
|
||||
for (slab = IPCOM_LIST_FIRST(&mc->slabs_partial);
|
||||
slab != IP_NULL;
|
||||
slab = IPCOM_LIST_NEXT(&slab->list))
|
||||
ipcom_printf(" Objects - total: %d, allocated %d"IP_LF,
|
||||
slab->total_objs,
|
||||
slab->allocated_objs);
|
||||
|
||||
ipcom_printf(" Empty: %d"IP_LF, mc->slabs_empty.size);
|
||||
for (slab = IPCOM_LIST_FIRST(&mc->slabs_empty);
|
||||
slab != IP_NULL;
|
||||
slab = IPCOM_LIST_NEXT(&slab->list))
|
||||
ipcom_printf(" Objects - total: %d, allocated %d"IP_LF,
|
||||
slab->total_objs,
|
||||
slab->allocated_objs);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* IPCOM_USE_SLAB_CMD */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_init
|
||||
*===========================================================================
|
||||
* Description: Initializes the slab module.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipcom_slab_init(void *unused)
|
||||
{
|
||||
IPCOM_UNUSED_ARG(unused);
|
||||
|
||||
ipcom_list_init(&ipcom_slab_memory_pool_list);
|
||||
#ifdef IPCOM_USE_SLAB_CMD
|
||||
ipcom_shell_add_cmd("slab", "slab", "Print slab cache information",
|
||||
ipcom_cmd_slab,
|
||||
IPCOM_PRIORITY_DEFAULT, IPCOM_PROC_STACK_SMALL);
|
||||
#endif /* IPCOM_USE_SLAB_CMD */
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memory_pool_new
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ipcom_memory_pool *
|
||||
ipcom_memory_pool_new(const char *name, Ip_size_t limit)
|
||||
{
|
||||
Ipcom_memory_pool *mp;
|
||||
|
||||
if (ipcom_once(&ipcom_slab_once, ipcom_slab_init, IP_NULL)
|
||||
!= IPCOM_SUCCESS)
|
||||
return IP_NULL;
|
||||
|
||||
mp = ipcom_malloc(IPCOM_SLAB_SIZEOF(Ipcom_memory_pool) + ipcom_strlen(name) + 1);
|
||||
if (mp != IP_NULL)
|
||||
{
|
||||
mp->name = (char *) (mp + 1);
|
||||
ipcom_strcpy((char *) mp->name, name);
|
||||
ipcom_atomic_set(&mp->bytes, (int)limit);
|
||||
*(Ip_size_t *) &mp->limit = limit;
|
||||
mp->low = limit;
|
||||
ipcom_list_init(&mp->memory_caches);
|
||||
ipcom_list_insert_last(&ipcom_slab_memory_pool_list, &mp->list);
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_new
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ipcom_memory_cache *
|
||||
ipcom_slab_new(const char *name,
|
||||
Ip_u32 flags,
|
||||
Ip_size_t obj_size,
|
||||
Ip_size_t obj_alignment,
|
||||
Ipcom_slab_ctor ctor,
|
||||
Ipcom_slab_dtor dtor,
|
||||
Ipcom_memory_pool *memory_pool)
|
||||
{
|
||||
Ipcom_memory_cache *mc;
|
||||
|
||||
mc = ipcom_memory_pool_alloc(memory_pool,
|
||||
IPCOM_SLAB_SIZEOF(Ipcom_memory_cache) + ipcom_strlen(name) + 1,
|
||||
0);
|
||||
if (mc != IP_NULL)
|
||||
{
|
||||
mc->name = (char *) (mc + 1);
|
||||
ipcom_strcpy((char *) mc->name, name);
|
||||
mc->flags = flags;
|
||||
mc->ctor = ctor;
|
||||
mc->dtor = dtor;
|
||||
*(Ip_size_t *) &mc->obj_size = obj_size;
|
||||
*(Ip_size_t *) &mc->alignment = IP_MAX(obj_alignment, sizeof(void*));
|
||||
|
||||
ipcom_list_init(&mc->slabs_full);
|
||||
ipcom_list_init(&mc->slabs_partial);
|
||||
ipcom_list_init(&mc->slabs_empty);
|
||||
|
||||
mc->memory_pool = memory_pool;
|
||||
ipcom_list_insert_last(&memory_pool->memory_caches, &mc->list);
|
||||
|
||||
if (IP_BIT_ISFALSE(flags, IPCOM_SLAB_F_NO_LOCKING))
|
||||
if (ipcom_spinlock_create(&mc->lock) != IPCOM_SUCCESS)
|
||||
IP_PANIC();
|
||||
}
|
||||
|
||||
return mc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_add
|
||||
*===========================================================================
|
||||
* Description: Allocates a new slab for a memory cache. Returns the new
|
||||
* slab, does not actually add it to the memory cache.
|
||||
* Parameters: mc - memory cache the slab will be added to.
|
||||
* Returns: A pointer to the new slab to be added, or IP_NULL if
|
||||
* allocation fails.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void *
|
||||
ipcom_slab_add(Ipcom_memory_cache *mc)
|
||||
{
|
||||
Ipcom_slab *slab;
|
||||
Ipcom_slab_obj *obj;
|
||||
Ip_size_t aligned_obj_size;
|
||||
unsigned added_objs;
|
||||
unsigned total_objs;
|
||||
Ip_bool first_try = IP_TRUE;
|
||||
Ip_size_t slab_size;
|
||||
|
||||
slab_size = ipcom_slab_get_size(mc,
|
||||
&aligned_obj_size,
|
||||
&total_objs);
|
||||
retry:
|
||||
slab = ipcom_memory_pool_alloc(mc->memory_pool, slab_size, mc->flags);
|
||||
if (slab == IP_NULL)
|
||||
{
|
||||
if (first_try)
|
||||
{
|
||||
/* Try to free up enough resource to satisfy this request */
|
||||
ipcom_memory_pool_garbage_collect(mc->memory_pool);
|
||||
first_try = IP_FALSE;
|
||||
goto retry;
|
||||
}
|
||||
return IP_FALSE;
|
||||
}
|
||||
|
||||
*(unsigned *) &slab->total_objs = total_objs;
|
||||
slab->allocated_objs = 0;
|
||||
|
||||
slab->free_objs = IP_NULL;
|
||||
obj = IP_PTR_ALIGN(slab + 1, mc->alignment);
|
||||
|
||||
for (added_objs = 0; added_objs < slab->total_objs; added_objs++)
|
||||
{
|
||||
if (mc->ctor != IP_NULL)
|
||||
if (mc->ctor(mc, obj) == IP_FALSE)
|
||||
{
|
||||
/* Ctor failed, garbage collect slabs to see if that
|
||||
frees up the necessary resources */
|
||||
ipcom_memory_pool_garbage_collect(mc->memory_pool);
|
||||
if (mc->ctor(mc, obj) == IP_FALSE)
|
||||
{
|
||||
/* Ctor still failed, give up */
|
||||
ipcom_slab_dtor_objs(mc, slab);
|
||||
ipcom_memory_pool_free(mc->memory_pool,
|
||||
slab_size,
|
||||
slab,
|
||||
mc->flags);
|
||||
return IP_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
obj->next = slab->free_objs;
|
||||
slab->free_objs = obj;
|
||||
*ipcom_slab_ptr_from_obj(mc, obj) = slab;
|
||||
obj = (Ipcom_slab_obj *) ((char *)obj + aligned_obj_size);
|
||||
}
|
||||
|
||||
return slab;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_alloc_try
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void *
|
||||
ipcom_slab_alloc_try(Ipcom_memory_cache *mc, Ip_bool retry)
|
||||
{
|
||||
Ipcom_slab *slab;
|
||||
void *obj;
|
||||
|
||||
IPCOM_SLAB_LOCK(mc);
|
||||
slab = IPCOM_LIST_FIRST(&mc->slabs_partial);
|
||||
if (slab == IP_NULL)
|
||||
{
|
||||
slab = IPCOM_LIST_FIRST(&mc->slabs_empty);
|
||||
if (slab == IP_NULL)
|
||||
{
|
||||
IPCOM_SLAB_UNLOCK(mc);
|
||||
if (!retry || (slab = ipcom_slab_add(mc)) == IP_NULL)
|
||||
return IP_NULL;
|
||||
IPCOM_SLAB_LOCK (mc);
|
||||
goto insert;
|
||||
}
|
||||
}
|
||||
|
||||
if (slab->allocated_objs == 0)
|
||||
{
|
||||
ipcom_list_remove(&slab->list);
|
||||
insert:
|
||||
ipcom_list_insert_last(&mc->slabs_partial, &slab->list);
|
||||
}
|
||||
|
||||
if (++slab->allocated_objs == slab->total_objs)
|
||||
{
|
||||
ipcom_list_remove(&slab->list);
|
||||
ipcom_list_insert_last(&mc->slabs_full, &slab->list);
|
||||
}
|
||||
obj = slab->free_objs;
|
||||
slab->free_objs = slab->free_objs->next;
|
||||
|
||||
IPCOM_SLAB_UNLOCK(mc);
|
||||
|
||||
if (IP_BIT_ISSET(mc->flags, IPCOM_SLAB_F_ZERO))
|
||||
ipcom_memset(obj, 0, mc->obj_size);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_alloc_from
|
||||
*===========================================================================
|
||||
* Description: Allocate an object from new slab, add slab to memory cache.
|
||||
* Do not use slab subsequently, it has been added to the cache.
|
||||
* Parameters: mc - memory cache to add slab to (minus one object)
|
||||
* slab - new slab returned from ipcom_slab_add()
|
||||
* Returns: A pointer to the object allocated out of slab.
|
||||
*/
|
||||
IP_PUBLIC void *
|
||||
ipcom_slab_alloc_from(Ipcom_memory_cache *mc, void * slab)
|
||||
{
|
||||
Ipcom_slab * s = (Ipcom_slab *) slab;
|
||||
void * obj;
|
||||
|
||||
ip_assert (s != IP_NULL);
|
||||
ip_assert(s->allocated_objs == 0);
|
||||
|
||||
s->allocated_objs = 1;
|
||||
obj = s->free_objs;
|
||||
s->free_objs = s->free_objs->next;
|
||||
|
||||
IPCOM_SLAB_LOCK(mc);
|
||||
if (s->total_objs == 1)
|
||||
ipcom_list_insert_last(&mc->slabs_full, &s->list);
|
||||
else
|
||||
ipcom_list_insert_last(&mc->slabs_partial, &s->list);
|
||||
IPCOM_SLAB_UNLOCK(mc);
|
||||
|
||||
if (IP_BIT_ISSET(mc->flags, IPCOM_SLAB_F_ZERO))
|
||||
ipcom_memset(obj, 0, mc->obj_size);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_free
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_slab_free(Ipcom_memory_cache *mc, void *obj)
|
||||
{
|
||||
Ipcom_slab *slab;
|
||||
|
||||
slab = *ipcom_slab_ptr_from_obj(mc, obj);
|
||||
if (IP_BIT_ISSET(mc->flags, IPCOM_SLAB_F_POISON))
|
||||
ipcom_memset(obj, 0xab, mc->obj_size);
|
||||
|
||||
IPCOM_SLAB_LOCK(mc);
|
||||
|
||||
if (slab->allocated_objs-- == slab->total_objs)
|
||||
{
|
||||
ipcom_list_remove(&slab->list);
|
||||
ipcom_list_insert_first(&mc->slabs_partial, &slab->list);
|
||||
}
|
||||
|
||||
if (slab->allocated_objs == 0)
|
||||
{
|
||||
ipcom_list_remove(&slab->list);
|
||||
ipcom_list_insert_first(&mc->slabs_empty, &slab->list);
|
||||
/* Release the memory if too many objects are unused in this
|
||||
slab */
|
||||
if (mc->slabs_empty.size > IPNET_GENERIC_SLAB_AUTO_GC_THRESH)
|
||||
mc->do_garbage_collect = IP_TRUE;
|
||||
}
|
||||
|
||||
((Ipcom_slab_obj *) obj)->next = slab->free_objs;
|
||||
slab->free_objs = obj;
|
||||
|
||||
IPCOM_SLAB_UNLOCK(mc);
|
||||
|
||||
if (IP_UNLIKELY(mc->do_garbage_collect))
|
||||
{
|
||||
/* do_garbage_collect is modified outside of any lock. This is
|
||||
OK since the worst think that could happen is that we run
|
||||
the garbage collect function more times than needed, which
|
||||
would not cause any corruption of the slab. */
|
||||
mc->do_garbage_collect = IP_FALSE;
|
||||
ipcom_slab_garbage_collect(mc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_slab_get_objects_per_slab
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC unsigned
|
||||
ipcom_slab_get_objects_per_slab(Ipcom_memory_cache *mc)
|
||||
{
|
||||
unsigned objs_per_slab;
|
||||
|
||||
(void) ipcom_slab_get_size(mc, IP_NULL, &objs_per_slab);
|
||||
return objs_per_slab;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,632 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getenv.c,v $ $Revision: 1.26 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getenv.c,v $
|
||||
* $Author: jhorteli $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_NATIVE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
#include <vxWorks.h>
|
||||
#include <envLib.h>
|
||||
#endif
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_NATIVE && (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5))
|
||||
#include <ose.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_file.h"
|
||||
#include "ipcom_hash.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_sysvar.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
IP_STATIC Ip_err ipcom_env_init(void *procptr);
|
||||
|
||||
IP_GLOBAL void ipcom_proc_clearenv(Ipcom_proc *proc);
|
||||
IP_GLOBAL void ipcom_proc_copyenv(Ipcom_proc *proc);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_hash_key
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC unsigned
|
||||
ipcom_env_hash_key(const char *key)
|
||||
{
|
||||
return ipcom_hash_update(key, ipcom_strlen(key), 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_hash_obj
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC unsigned
|
||||
ipcom_env_hash_obj(const Ipcom_env_entry *s)
|
||||
{
|
||||
return ipcom_env_hash_key(s->name);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_hash_cmp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_env_hash_cmp(const Ipcom_env_entry *s, const char *key)
|
||||
{
|
||||
return ipcom_strcmp(s->name, key) == 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC Ipcom_env_entry *
|
||||
ipcom_env_create(const char *name, const char *value)
|
||||
{
|
||||
Ip_size_t name_length;
|
||||
Ip_size_t value_length;
|
||||
Ipcom_env_entry *env;
|
||||
|
||||
/* Create environment variable */
|
||||
name_length = ipcom_strlen(name) + 1;
|
||||
value_length = ipcom_strlen(value) + 1;
|
||||
env = ipcom_malloc(sizeof(Ipcom_env_entry) + name_length + value_length);
|
||||
if(env == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Init environment variable */
|
||||
env->name = (const char *)env + sizeof(Ipcom_env_entry);
|
||||
ipcom_memcpy((void *)env->name, name, name_length);
|
||||
env->value = env->name + name_length;
|
||||
ipcom_memcpy((void *)env->value, value, value_length);
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipcom_env_init(void *procptr)
|
||||
{
|
||||
Ipcom_proc *proc = procptr;
|
||||
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
(void)ipcom_mutex_create(&proc->env_mutex);
|
||||
|
||||
proc->env_tree = ipcom_hash_new((Ipcom_hash_obj_func)ipcom_env_hash_obj,
|
||||
(Ipcom_hash_key_func)ipcom_env_hash_key,
|
||||
(Ipcom_hash_cmp_func)ipcom_env_hash_cmp);
|
||||
ip_assert(proc->env_tree != IP_NULL);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_delete
|
||||
*===========================================================================
|
||||
* Description: Removes the element from its hash table and frees memory for
|
||||
* the entry.
|
||||
* Parameters: env - entry to delete
|
||||
* hash - hash table the entry is assigned to
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_env_delete(Ipcom_env_entry *env, Ipcom_hash *hash)
|
||||
{
|
||||
ipcom_hash_remove(hash, env);
|
||||
ipcom_free(env);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_env_clone
|
||||
*===========================================================================
|
||||
* Description: Clones an env entry and adds it to the specified hash table.
|
||||
* Parameters: env - entry to clone
|
||||
* hash - hash table the cloned entry should be added to.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_env_clone(Ipcom_env_entry *env, Ipcom_hash *hash)
|
||||
{
|
||||
Ipcom_env_entry *clone = ipcom_env_create(env->name, env->value);
|
||||
ipcom_hash_add(hash, clone);
|
||||
}
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_clearenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipcom_proc_clearenv(Ipcom_proc *proc)
|
||||
{
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
ipcom_mutex_lock(proc->env_mutex);
|
||||
|
||||
/* Remove all environment variable entries */
|
||||
ipcom_hash_for_each(proc->env_tree,
|
||||
(Ipcom_hash_foreach_cb_func) ipcom_env_delete,
|
||||
proc->env_tree);
|
||||
|
||||
ipcom_mutex_unlock(proc->env_mutex);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_proc_copyenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipcom_proc_copyenv(Ipcom_proc *proc_c)
|
||||
{
|
||||
Ipcom_proc *proc_p;
|
||||
Ip_err retval;
|
||||
|
||||
proc_p = ipcom_proc_self();
|
||||
ip_assert(proc_p != IP_NULL);
|
||||
ip_assert(proc_c != IP_NULL);
|
||||
|
||||
if (proc_p->env_tree == IP_NULL)
|
||||
/* Parent process has no environment variables */
|
||||
return;
|
||||
|
||||
/* Create child environment semaphore and tree */
|
||||
retval = ipcom_once(&proc_c->env_once, ipcom_env_init, proc_c);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
IP_PANIC();
|
||||
return;
|
||||
}
|
||||
|
||||
ipcom_mutex_lock(proc_p->env_mutex);
|
||||
|
||||
ipcom_hash_for_each(proc_p->env_tree,
|
||||
(Ipcom_hash_foreach_cb_func) ipcom_env_clone,
|
||||
proc_c->env_tree);
|
||||
|
||||
ipcom_mutex_unlock(proc_p->env_mutex);
|
||||
}
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC char *
|
||||
ipcom_getenv(const char *name)
|
||||
{
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
Ip_err retval;
|
||||
Ipcom_proc *proc;
|
||||
Ipcom_env_entry *env;
|
||||
char *value = IP_NULL;
|
||||
|
||||
proc = ipcom_proc_self();
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
retval = ipcom_once(&proc->env_once, ipcom_env_init, proc);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
IP_PANIC();
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
ipcom_mutex_lock(proc->env_mutex);
|
||||
|
||||
env = ipcom_hash_get(proc->env_tree, name);
|
||||
if (env != IP_NULL)
|
||||
value = (char *)env->value;
|
||||
|
||||
ipcom_mutex_unlock(proc->env_mutex);
|
||||
|
||||
return value;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5))
|
||||
char *env;
|
||||
static char buf[256];
|
||||
|
||||
env = get_env(current_process(), name);
|
||||
if (env != IP_NULL)
|
||||
{
|
||||
ipcom_strncpy(buf, env, sizeof(buf));
|
||||
free_buf((union SIGNAL **)&env);
|
||||
return (char *)buf;
|
||||
}
|
||||
return IP_NULL;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE
|
||||
return getenv(name);
|
||||
|
||||
#elif defined(IPCOM_USE_SYSVAR) && IPCOM_VR_MAX == 1
|
||||
static char buf[256];
|
||||
Ip_size_t buf_size = sizeof(buf);
|
||||
|
||||
return ipcom_sysvar_get(name, buf, &buf_size);
|
||||
|
||||
#else
|
||||
return IP_NULL;
|
||||
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_setenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_setenv(const char *name, const char *value, int rewrite)
|
||||
{
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
Ip_err retval;
|
||||
Ipcom_proc *proc;
|
||||
Ipcom_env_entry *env;
|
||||
|
||||
proc = ipcom_proc_self();
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
retval = ipcom_once(&proc->env_once, ipcom_env_init, proc);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
IP_PANIC();
|
||||
return -1;
|
||||
}
|
||||
|
||||
ipcom_mutex_lock(proc->env_mutex);
|
||||
|
||||
/* Check for duplicate. */
|
||||
env = ipcom_hash_get(proc->env_tree, name);
|
||||
if (env != IP_NULL)
|
||||
{
|
||||
if (rewrite == 0)
|
||||
goto leave;
|
||||
ipcom_env_delete(env, proc->env_tree);
|
||||
}
|
||||
|
||||
/* Create environment variable. */
|
||||
env = ipcom_env_create(name, value);
|
||||
if (env == IP_NULL)
|
||||
{
|
||||
ipcom_mutex_unlock(proc->env_mutex);
|
||||
return -1;
|
||||
}
|
||||
(void)ipcom_hash_add(proc->env_tree, env);
|
||||
|
||||
leave:
|
||||
ipcom_mutex_unlock(proc->env_mutex);
|
||||
return 0;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5))
|
||||
(void)rewrite;
|
||||
|
||||
set_env(current_process(), name, value);
|
||||
return 0;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && defined(IP_PORT_VXWORKS)
|
||||
char buf[256];
|
||||
int ret;
|
||||
|
||||
(void)rewrite;
|
||||
|
||||
ipcom_snprintf(buf, sizeof(buf), "%s=%s", name, value);
|
||||
ret = (int)putenv(buf);
|
||||
return ret == 0 ? 0 : -1;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE
|
||||
return setenv(name, value, rewrite);
|
||||
|
||||
#elif defined(IPCOM_USE_SYSVAR) && IPCOM_VR_MAX == 1
|
||||
(void)ipcom_sysvar_set(name, value, rewrite ? IPCOM_SYSVAR_FLAG_OVERWRITE : 0);
|
||||
return 0;
|
||||
|
||||
#else
|
||||
(void)name;
|
||||
(void)value;
|
||||
(void)rewrite;
|
||||
return -1;
|
||||
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_unsetenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_unsetenv(const char *name)
|
||||
{
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
Ip_err retval;
|
||||
Ipcom_proc *proc;
|
||||
Ipcom_env_entry *env;
|
||||
|
||||
proc = ipcom_proc_self();
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
retval = ipcom_once(&proc->env_once, ipcom_env_init, proc);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
IP_PANIC();
|
||||
return -1;
|
||||
}
|
||||
|
||||
ipcom_mutex_lock(proc->env_mutex);
|
||||
|
||||
env = ipcom_hash_get(proc->env_tree, name);
|
||||
if (env != IP_NULL)
|
||||
ipcom_env_delete(env, proc->env_tree);
|
||||
|
||||
ipcom_mutex_unlock(proc->env_mutex);
|
||||
|
||||
return 0;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5))
|
||||
set_env(current_process(), name, NULL);
|
||||
return 0;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && defined(IP_PORT_VXWORKS)
|
||||
{
|
||||
char buf[256];
|
||||
int ret;
|
||||
ipcom_snprintf(buf, sizeof(buf), "%s=", name);
|
||||
ret = (int)putenv(buf);
|
||||
return ret == 0 ? 0 : -1;
|
||||
}
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE
|
||||
return unsetenv(name);
|
||||
|
||||
#elif defined(IPCOM_USE_SYSVAR) && IPCOM_VR_MAX == 1
|
||||
(void)ipcom_sysvar_unset(name);
|
||||
return 0;
|
||||
|
||||
#else
|
||||
return 0;
|
||||
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_clearenv
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_clearenv(void)
|
||||
{
|
||||
#if IPCOM_USE_ENV == IPCOM_ENV_IPCOM
|
||||
Ip_err retval;
|
||||
Ipcom_proc *proc;
|
||||
|
||||
proc = ipcom_proc_self();
|
||||
ip_assert(proc != IP_NULL);
|
||||
|
||||
retval = ipcom_once(&proc->env_once, ipcom_env_init, proc);
|
||||
if (retval != IPCOM_SUCCESS)
|
||||
{
|
||||
IP_PANIC();
|
||||
return -1;
|
||||
}
|
||||
|
||||
ipcom_proc_clearenv(proc);
|
||||
return 0;
|
||||
|
||||
#elif IPCOM_USE_ENV == IPCOM_ENV_NATIVE && (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5))
|
||||
/*!! Are all environment variables cleaned up by OS automatically? */
|
||||
return 0;
|
||||
|
||||
#elif defined(IPCOM_USE_SYSVAR) && IPCOM_VR_MAX == 1
|
||||
/*! Hmmmm */
|
||||
return -1;
|
||||
|
||||
#else
|
||||
return -1;
|
||||
|
||||
#endif /* #if IPCOM_USE_ENV == IPCOM_ENV_IPCOM */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getenv_as_int
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getenv_as_int(const char *name, int default_value)
|
||||
{
|
||||
char *env;
|
||||
|
||||
env = ipcom_getenv(name);
|
||||
if (env != IP_NULL)
|
||||
return ipcom_atoi(env);
|
||||
else
|
||||
return default_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_setenv_as_int
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_setenv_as_int(const char *name, int value, int rewrite)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
ipcom_sprintf(buf, "%d", value);
|
||||
return ipcom_setenv(name, buf, rewrite);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,700 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_gethostby.c,v $ $Revision: 1.65.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_gethostby.c,v $
|
||||
* $Author: hxie $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SKIP_NATIVE_SOCK_API
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE5)
|
||||
#if !defined(softOSE) && defined(IP_TARGET_SOFT)
|
||||
#define softOSE /* to use sfk_netdb.h */
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef s6_addr
|
||||
#undef s6_addr
|
||||
#endif
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
|
||||
#elif defined(IPDNSC)
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include <ipdnsc.h>
|
||||
|
||||
#elif defined(IP_PORT_VXWORKS)
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#undef s6_addr /* Remove the ipcom definition, vxWorks 6.0 has a conflicting macro definition */
|
||||
#undef ifa_dstaddr /* The ifa_dstaddr #define in ipcom_sock2.h breaks code in target/h/.../ifvar.h */
|
||||
#undef ifa_broadaddr /* The ifa_broadaddr #define in ipcom_sock2.h breaks code in target/h/.../ifvar.h */
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(WRS_IPNET) && !defined(WRS_IPLITE)
|
||||
#include <config.h>
|
||||
#ifdef INCLUDE_DNS_RESOLVER
|
||||
#include <resolvLib.h>
|
||||
#endif
|
||||
#endif /* WRS_IPNET */
|
||||
|
||||
#include <hostLib.h>
|
||||
|
||||
#elif defined(IP_PORT_WIN32) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include <winsock2.h>
|
||||
|
||||
#elif defined(IP_PORT_OSE) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#ifdef USE_OSEDEF_H
|
||||
#undef USE_OSEDEF_H
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
#elif (defined(IP_PORT_UNIX) || defined(IP_PORT_LAS)) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_type.h"
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef s6_addr
|
||||
#undef s6_addr
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_type.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_GETHOST_MAXNAME 256
|
||||
|
||||
/* Size of buffer used in ipcom_gethostbyname() */
|
||||
#define IPCOM_HOSTENT_SIZE 512
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ip_hostent_buffer
|
||||
{
|
||||
char *addr_list[2];
|
||||
char *alias_list[1];
|
||||
char host_name[IPCOM_GETHOST_MAXNAME];
|
||||
char space[IPCOM_HOSTENT_SIZE - sizeof(union Ip_in_addr_union) - 3*sizeof(char *) - IPCOM_GETHOST_MAXNAME];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65)
|
||||
struct hostent;
|
||||
extern void hostentFree(struct hostent *);
|
||||
extern int hostTblInit(void); /*!!FIXME - should not be called here!*/
|
||||
IP_EXTERN struct Ip_hostent *getlhostbyname(const char *name, int family);
|
||||
IP_EXTERN struct Ip_hostent *getlhostbyaddr(const char *addr, int len, int af);
|
||||
#endif
|
||||
|
||||
#ifdef IPDNSC
|
||||
IP_EXTERN int ipcom_dns_init_ok;
|
||||
IP_EXTERN Ipdnsc_api ipcom_dns;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65)
|
||||
IP_PUBLIC struct Ip_hostent *ipcom_gethostbynamelocal(const char *name,
|
||||
int family,
|
||||
Ip_u32 *ifindexp,
|
||||
struct Ip_hostent *result,
|
||||
char *buf, int buflen);
|
||||
IP_PUBLIC struct Ip_hostent *ipcom_gethostbyaddrlocal(const char *addr,
|
||||
int len, int type,
|
||||
struct Ip_hostent *result,
|
||||
char *buf, int buflen);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC int ipcom_h_errno;
|
||||
|
||||
static struct Ip_hostent ipcom_he_result;
|
||||
static struct Ip_hostent_buffer ipcom_he_buffer;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostip
|
||||
*===========================================================================
|
||||
* Description: Get the first IPv4 address. Avoid loopback if possible.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC struct Ip_hostent *
|
||||
ipcom_gethostip(char *name,
|
||||
struct Ip_hostent *result,
|
||||
char *buf,
|
||||
int buflen)
|
||||
{
|
||||
Ip_u32 host_addr_n = 0;
|
||||
struct Ip_hostent_buffer *buffer;
|
||||
|
||||
#if defined(IPCOM_USE_INET) && defined(IPCOM_SOCK)
|
||||
struct Ip_if_nameindex *ifrs;
|
||||
|
||||
ifrs = ipcom_if_nameindex();
|
||||
if (ifrs)
|
||||
{
|
||||
struct Ip_if_nameindex *oifrs;
|
||||
Ip_fd fd;
|
||||
|
||||
oifrs = ifrs;
|
||||
fd = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, IP_IPPROTO_UDP);
|
||||
if (fd != IP_INVALID_SOCKET)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
|
||||
for (; ifrs && ifrs->if_name != IP_NULL; ifrs++)
|
||||
{
|
||||
ipcom_strncpy(ifreq.ifr_name, ifrs->if_name, sizeof(ifreq.ifr_name));
|
||||
ifreq.ifr_name[sizeof(ifreq.ifr_name)-1] = '\0';
|
||||
if (ipcom_socketioctl(fd, IP_SIOCGIFADDR, &ifreq) >= 0)
|
||||
{
|
||||
host_addr_n = ((struct Ip_sockaddr_in *)&ifreq.ip_ifr_addr)->sin_addr.s_addr;
|
||||
if (ipcom_strcmp(ifrs->if_name, "lo0"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)ipcom_socketclose(fd);
|
||||
}
|
||||
ipcom_if_freenameindex(oifrs);
|
||||
}
|
||||
#endif /* IPCOM_USE_INET && IPCOM_SOCK */
|
||||
|
||||
(void) buflen; /* Avoid compiler warning */
|
||||
|
||||
/* Set hostent */
|
||||
buffer = IP_PTR_ALIGN(buf, sizeof(void*));
|
||||
|
||||
result->h_name = buffer->host_name;
|
||||
result->h_aliases = buffer->alias_list;
|
||||
result->h_aliases[0] = IP_NULL;
|
||||
result->h_addrtype = IP_AF_INET;
|
||||
result->h_length = sizeof(host_addr_n);
|
||||
result->h_addr_list = buffer->addr_list;
|
||||
result->h_addr_list[0] = IP_PTR_ALIGN(buffer->space, sizeof(void*));
|
||||
result->h_addr_list[1] = IP_NULL;
|
||||
|
||||
/* Set host addr, addr_list and alias_list */
|
||||
ipcom_memcpy(result->h_addr_list[0], &host_addr_n, result->h_length);
|
||||
|
||||
/* Set hostname */
|
||||
ipcom_strncpy(result->h_name, name, sizeof(buffer->host_name)-1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethost_static
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPDNSC) || (defined(IP_PORT_WIN32) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE) \
|
||||
|| (defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65)
|
||||
|
||||
IP_STATIC struct Ip_hostent *
|
||||
ipcom_gethost_static(struct Ip_hostent *he,
|
||||
struct Ip_hostent *result,
|
||||
char *buf,
|
||||
int buflen)
|
||||
{
|
||||
struct Ip_hostent_buffer *buffer;
|
||||
#ifdef IPDNSC
|
||||
struct Ip_hostent *port_he = he;
|
||||
#else
|
||||
struct hostent *port_he = (struct hostent *)he;
|
||||
#endif
|
||||
|
||||
if (port_he == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
if (result == IP_NULL)
|
||||
{
|
||||
result = &ipcom_he_result;
|
||||
buf = (char *)&ipcom_he_buffer;
|
||||
buflen = sizeof (ipcom_he_buffer);
|
||||
}
|
||||
|
||||
if (buflen < (int)(sizeof(union Ip_in_addr_union)
|
||||
+ (3 * sizeof(char *)) + ipcom_strlen(port_he->h_name) + 1))
|
||||
{
|
||||
/* Yes the reentrant versions set errno and not h_errno for this error */
|
||||
(void)ipcom_errno_set(IP_ERRNO_ERANGE);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
buffer = IP_PTR_ALIGN(buf, sizeof(void*));
|
||||
|
||||
/* Set hostent */
|
||||
result->h_name = buffer->host_name;
|
||||
result->h_aliases = buffer->alias_list;
|
||||
result->h_aliases[0] = IP_NULL;
|
||||
result->h_addrtype = port_he->h_addrtype;
|
||||
result->h_length = port_he->h_length;
|
||||
result->h_addr_list = buffer->addr_list;
|
||||
result->h_addr_list[0] = IP_PTR_ALIGN(buffer->space, sizeof(void*));
|
||||
result->h_addr_list[1] = IP_NULL;
|
||||
|
||||
/* Set hostname */
|
||||
ipcom_strcpy(result->h_name, port_he->h_name);
|
||||
|
||||
/* Set host addr */
|
||||
ipcom_memcpy(result->h_addr_list[0],
|
||||
port_he->h_addr_list[0],
|
||||
port_he->h_length);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbyname_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbyname_r(const char *name,
|
||||
struct Ip_hostent *result,
|
||||
char *buffer,
|
||||
int buflen,
|
||||
int *h_errnop)
|
||||
{
|
||||
char hostname[IPCOM_GETHOST_MAXNAME];
|
||||
|
||||
if (name == IP_NULL || result == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Check local hostname first */
|
||||
if (ipcom_gethostname(hostname, sizeof(hostname)) == 0 && ipcom_strcmp(name, hostname) == 0)
|
||||
return ipcom_gethostip(hostname, result, buffer, buflen);
|
||||
|
||||
/* VxWorks static host table check */
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
{
|
||||
struct Ip_hostent *he;
|
||||
he = ipcom_gethostbynamelocal(name, IP_AF_INET, IP_NULL, result, buffer, buflen);
|
||||
if (he != IP_NULL)
|
||||
return he;
|
||||
}
|
||||
#endif /* IP_PORT_VXWORKS && IP_PORT_VXWORKS >= 65 */
|
||||
|
||||
/* Interpeak DNS lookup */
|
||||
#if defined(IPDNSC)
|
||||
{
|
||||
struct Ip_hostent *he, *resultp;
|
||||
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
return IP_NULL;
|
||||
he = ipcom_dns.getipnodebyname(name, IP_AF_INET, 0, h_errnop);
|
||||
if (he == IP_NULL)
|
||||
return IP_NULL;
|
||||
resultp = ipcom_gethost_static(he, result, buffer, buflen);
|
||||
ipcom_dns.freehostent(he);
|
||||
return resultp;
|
||||
}
|
||||
|
||||
#elif defined(IP_PORT_VXWORKS) && defined(INCLUDE_DNS_RESOLVER)
|
||||
(void)h_errnop;
|
||||
return (struct Ip_hostent *)resolvGetHostByName((char *)name,
|
||||
buffer,
|
||||
buflen);
|
||||
#else
|
||||
(void)h_errnop;
|
||||
return IP_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbyname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbyname(const char *name)
|
||||
{
|
||||
char hostname[IPCOM_GETHOST_MAXNAME];
|
||||
|
||||
if (name == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Check local hostname first */
|
||||
if (ipcom_gethostname(hostname, sizeof(hostname)) == 0 && ipcom_strcmp(name, hostname) == 0)
|
||||
return ipcom_gethostip(hostname, &ipcom_he_result, (char *)&ipcom_he_buffer, sizeof(ipcom_he_buffer));
|
||||
|
||||
/* VxWorks static host table check */
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
{
|
||||
struct Ip_hostent *he;
|
||||
he = ipcom_gethostbynamelocal(name, IP_AF_INET, IP_NULL, IP_NULL, IP_NULL, 0);
|
||||
if (he != IP_NULL)
|
||||
return he;
|
||||
}
|
||||
#endif /* IP_PORT_VXWORKS && IP_PORT_VXWORKS >= 65 */
|
||||
|
||||
#if defined(IP_PORT_OSE5)
|
||||
return (struct Ip_hostent *)gethostbyname(name);
|
||||
|
||||
#elif defined(IP_PORT_LKM)
|
||||
return IP_NULL;
|
||||
|
||||
/* Interpeak DNS client */
|
||||
#elif defined(IPDNSC)
|
||||
{
|
||||
struct Ip_hostent *he, *resultp;
|
||||
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
return IP_NULL;
|
||||
he = ipcom_dns.getipnodebyname(name, IP_AF_INET, 0, &ipcom_h_errno);
|
||||
if (he == IP_NULL)
|
||||
return IP_NULL;
|
||||
resultp = ipcom_gethost_static(he, &ipcom_he_result,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
ipcom_dns.freehostent(he);
|
||||
return resultp;
|
||||
}
|
||||
|
||||
/* Port specific lookups */
|
||||
#elif defined(IP_PORT_VXWORKS) && defined(INCLUDE_DNS_RESOLVER)
|
||||
return (struct Ip_hostent *)resolvGetHostByName((char *)name,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
|
||||
#elif (defined(IP_PORT_OSE) || defined(IP_PORT_UNIX) || defined(IP_PORT_LAS)) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
return (struct Ip_hostent *)gethostbyname(name);
|
||||
|
||||
#elif defined(IP_PORT_WIN32) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
return ipcom_gethost_static((struct Ip_hostent *)gethostbyname(name),
|
||||
&ipcom_he_result,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
|
||||
#else
|
||||
return IP_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbyaddr_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbyaddr_r(const char *addr, int len, int type,
|
||||
struct Ip_hostent *result,
|
||||
char *buffer, int buflen, int *h_errnop)
|
||||
{
|
||||
if (addr == IP_NULL || result == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* VxWorks static host table check */
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
{
|
||||
struct Ip_hostent *he;
|
||||
he = ipcom_gethostbyaddrlocal(addr, len, type, result, buffer, buflen);
|
||||
if (he != IP_NULL)
|
||||
return he;
|
||||
}
|
||||
#endif /* IP_PORT_VXWORKS && IP_PORT_VXWORKS >= 65 */
|
||||
|
||||
/* Interpeak DNS client */
|
||||
#if defined(IPDNSC)
|
||||
{
|
||||
struct Ip_hostent *he, *resultp;
|
||||
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
return IP_NULL;
|
||||
he = ipcom_dns.getipnodebyaddr(addr, (Ip_size_t)len, type, h_errnop);
|
||||
if (he == IP_NULL)
|
||||
return IP_NULL;
|
||||
resultp = ipcom_gethost_static(he, result, buffer, buflen);
|
||||
ipcom_dns.freehostent(he);
|
||||
return resultp;
|
||||
}
|
||||
|
||||
/* Port specific lookups */
|
||||
#elif defined(IP_PORT_VXWORKS) && defined(INCLUDE_DNS_RESOLVER)
|
||||
return (struct Ip_hostent *)resolvGetHostByAddr((char *)addr,
|
||||
buffer,
|
||||
buflen);
|
||||
|
||||
#else
|
||||
(void)addr;
|
||||
(void)len;
|
||||
(void)type;
|
||||
(void)result;
|
||||
(void)buffer;
|
||||
(void)buflen;
|
||||
(void)h_errnop;
|
||||
return IP_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbyaddr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbyaddr(const char *addr, int len, int type)
|
||||
{
|
||||
/* Check the static host table first */
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
{
|
||||
struct Ip_hostent *he;
|
||||
he = ipcom_gethostbyaddrlocal(addr, len, type, IP_NULL, IP_NULL, 0);
|
||||
if (he != IP_NULL)
|
||||
return he;
|
||||
}
|
||||
#endif /* IP_PORT_VXWORKS && IP_PORT_VXWORKS >= 65 */
|
||||
|
||||
/* Lookup the address with the appropriate function */
|
||||
#if defined(IP_PORT_OSE5)
|
||||
return (struct Ip_hostent *)gethostbyaddr(addr, len, type);
|
||||
|
||||
/* Interpeak DNS client */
|
||||
#elif defined(IPDNSC)
|
||||
{
|
||||
struct Ip_hostent *he, *resultp;
|
||||
|
||||
if (addr == IP_NULL || ipcom_dns_init_ok == 0)
|
||||
return IP_NULL;
|
||||
he = ipcom_dns.getipnodebyaddr(addr, (Ip_size_t)len, type, &ipcom_h_errno);
|
||||
if (he == IP_NULL)
|
||||
return IP_NULL;
|
||||
resultp = ipcom_gethost_static(he, &ipcom_he_result,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
ipcom_dns.freehostent(he);
|
||||
return resultp;
|
||||
}
|
||||
|
||||
/* Port specific lookups */
|
||||
#elif defined(IP_PORT_VXWORKS) && defined(INCLUDE_DNS_RESOLVER)
|
||||
return (struct Ip_hostent *)resolvGetHostByAddr((char *)addr,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
|
||||
#elif (defined(IP_PORT_OSE) || defined(IP_PORT_UNIX) || defined(IP_PORT_LAS)) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
return (struct Ip_hostent *)gethostbyaddr(addr, len, type);
|
||||
|
||||
#elif defined(IP_PORT_WIN32) && IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE
|
||||
return ipcom_gethost_static((struct Ip_hostent *)gethostbyaddr(addr, len, type),
|
||||
&ipcom_he_result,
|
||||
(char *)&ipcom_he_buffer,
|
||||
sizeof(ipcom_he_buffer));
|
||||
|
||||
#else
|
||||
(void)addr;
|
||||
(void)len;
|
||||
(void)type;
|
||||
return IP_NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbynamelocal
|
||||
*===========================================================================
|
||||
* Description: Gets host info from local host table given the host name
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbynamelocal(const char *name, int family, Ip_u32 *ifindexp,
|
||||
struct Ip_hostent *result, char *buf, int buflen)
|
||||
{
|
||||
struct Ip_hostent *he = IP_NULL;
|
||||
struct Ip_hostent *hes = IP_NULL;
|
||||
|
||||
if (hostTblInit() != 0)
|
||||
return IP_NULL;
|
||||
|
||||
#ifdef IPCOM_HOST_FROM_LOCALTBL
|
||||
he = (struct Ip_hostent *)getlhostbyname(name, family);
|
||||
#endif
|
||||
if (he != IP_NULL)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (ifindexp != IP_NULL && he->h_addrtype == IP_AF_INET6)
|
||||
*ifindexp = *(Ip_u32 *)(he->h_addr + 16);
|
||||
#endif
|
||||
hes = ipcom_gethost_static(he, result, buf, buflen);
|
||||
hostentFree((struct hostent *)he);
|
||||
}
|
||||
|
||||
return hes;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostbyaddrlocal
|
||||
*===========================================================================
|
||||
* Description: Gets host info from local host table given the host address
|
||||
* Parameters:
|
||||
* Returns: IP_NULL or a pointer to struct Ip_hostent.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_hostent *
|
||||
ipcom_gethostbyaddrlocal(const char *addr, int len, int family,
|
||||
struct Ip_hostent *result, char *buf, int buflen)
|
||||
{
|
||||
struct Ip_hostent *he = IP_NULL;
|
||||
struct Ip_hostent *hes = IP_NULL;
|
||||
|
||||
if (hostTblInit() != 0)
|
||||
return IP_NULL;
|
||||
|
||||
#ifdef IPCOM_HOST_FROM_LOCALTBL
|
||||
he = (struct Ip_hostent *)getlhostbyaddr(addr, len, family);
|
||||
#endif
|
||||
if (he != IP_NULL)
|
||||
{
|
||||
hes = ipcom_gethost_static(he, result, buf, buflen);
|
||||
hostentFree((struct hostent *)he);
|
||||
}
|
||||
|
||||
return hes;
|
||||
}
|
||||
#endif /* defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65) */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getinfo.c,v $ $Revision: 1.35 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getinfo.c,v $
|
||||
* $Author: ulf $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE5)
|
||||
#include "osarch.h" /* Will set softOSE appropriately */
|
||||
#include "errno.h"
|
||||
#include "netdb.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#ifdef s6_addr
|
||||
#undef s6_addr
|
||||
#endif
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
|
||||
#else
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
|
||||
#endif /* IP_PORT_OSE5 */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if !defined(IP_PORT_VXWORKS) || defined(_WRS_KERNEL)
|
||||
#define IPCOM_USE_GETINFO
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_GETINFO
|
||||
IP_PUBLIC int
|
||||
ipcom_getnameinfo2(IP_CONST struct Ip_sockaddr *sa, Ip_socklen_t salen,
|
||||
char *host, Ip_size_t hostlen,
|
||||
char *serv, Ip_size_t servlen,
|
||||
int flags);
|
||||
|
||||
IP_PUBLIC int
|
||||
ipcom_getaddrinfo2(IP_CONST char *hostname,
|
||||
IP_CONST char *servname,
|
||||
IP_CONST struct Ip_addrinfo *hints,
|
||||
struct Ip_addrinfo **res);
|
||||
#endif /* IPCOM_USE_GETINFO */
|
||||
|
||||
IP_PUBLIC void
|
||||
ipcom_freeaddrinfo2(struct Ip_addrinfo *ai);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE5)
|
||||
/* Start by assuming that getaddrinfo is supported.
|
||||
* The first call to ipcom_getaddrinfo() will test if getaddrinfo()
|
||||
* is supported. If it is not the fallback flag is set, and
|
||||
* ipcom_getaddrinfo2() is called.
|
||||
* A subsequent call to ipcom_freeaddrinfo() will use ipcom_freeaddrinfo2().
|
||||
* We will never run in into a situation where we have a addrinfo struct
|
||||
* from CRT with fallback flag set, since no addrinfo struct is returned
|
||||
* when getaddrinfo() is found to be unsupported.
|
||||
*/
|
||||
static int ipcom_getaddrinfo_fallback = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_GETINFO
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getnameinfo
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getnameinfo(IP_CONST struct Ip_sockaddr *sa,
|
||||
Ip_socklen_t salen,
|
||||
char *host,
|
||||
Ip_size_t hostlen,
|
||||
char *serv,
|
||||
Ip_size_t servlen,
|
||||
int flags)
|
||||
{
|
||||
#if defined(IP_PORT_OSE5)
|
||||
int ret;
|
||||
|
||||
ret = getnameinfo((const struct sockaddr *)sa, (socklen_t)salen,
|
||||
host, (socklen_t)hostlen,
|
||||
serv, (socklen_t)servlen,
|
||||
flags);
|
||||
if (ret != 0 && errno == EOPNOTSUPP)
|
||||
{
|
||||
/* Fall back to ipcom_getnameinfo2() */
|
||||
ret = ipcom_getnameinfo2(sa, salen, host, hostlen, serv, servlen, flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else
|
||||
return ipcom_getnameinfo2(sa, salen, host, hostlen, serv, servlen, flags);
|
||||
#endif /* IP_PORT_OSE5 */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getaddrinfo
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getaddrinfo(IP_CONST char *hostname,
|
||||
IP_CONST char *servname,
|
||||
IP_CONST struct Ip_addrinfo *hints,
|
||||
struct Ip_addrinfo **res)
|
||||
{
|
||||
#if defined(IP_PORT_OSE5)
|
||||
int ret;
|
||||
|
||||
if (ipcom_getaddrinfo_fallback == 0)
|
||||
{
|
||||
ret = getaddrinfo("127.0.0.1", IP_NULL, IP_NULL, IP_NULL);
|
||||
if (ret == EAI_SYSTEM && errno == EOPNOTSUPP)
|
||||
/* Fall back to ipcom_getnameinfo2(), but set ipcom_getaddrinfo_fallback
|
||||
* flag first to steer ipcom_freeaddrinfo() via ipcom_freeaddrinfo2().
|
||||
*/
|
||||
ipcom_getaddrinfo_fallback = 2;
|
||||
else
|
||||
ipcom_getaddrinfo_fallback = 1;
|
||||
}
|
||||
|
||||
if (ipcom_getaddrinfo_fallback == 1)
|
||||
ret = getaddrinfo((const char *)hostname, (const char *)servname,
|
||||
(const struct addrinfo *)hints,
|
||||
(struct addrinfo **)res);
|
||||
else
|
||||
/* Use fallback solution via ipcom_getaddrinfo2() */
|
||||
ret = ipcom_getaddrinfo2(hostname, servname, hints, res);
|
||||
return ret;
|
||||
#else
|
||||
return ipcom_getaddrinfo2(hostname, servname, hints, res);
|
||||
#endif /* IP_PORT_OSE5 */
|
||||
}
|
||||
#endif /* IPCOM_USE_GETINFO */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_freeaddrinfo
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_freeaddrinfo(struct Ip_addrinfo *ai)
|
||||
{
|
||||
#if defined(IP_PORT_OSE5)
|
||||
ip_assert(ipcom_getaddrinfo_fallback > 0);
|
||||
if (ipcom_getaddrinfo_fallback == 1)
|
||||
freeaddrinfo((struct addrinfo *)ai);
|
||||
else
|
||||
ipcom_freeaddrinfo2(ai);
|
||||
#else
|
||||
ipcom_freeaddrinfo2(ai);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,826 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getinfo2.c,v $ $Revision: 1.27.10.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getinfo2.c,v $
|
||||
* $Author: hchu0 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if defined(IPDNSC)
|
||||
#define IPCOM_USE_DNS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_sock6.h"
|
||||
#include "ipcom_inet.h"
|
||||
|
||||
#ifdef IPCOM_USE_DNS
|
||||
#include <ipdnsc.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if !defined(IP_PORT_VXWORKS) || defined(_WRS_KERNEL)
|
||||
#define IPCOM_USE_GETINFO
|
||||
#endif
|
||||
|
||||
#if defined(IPCOM_USE_DNS) && defined(IP_PORT_OSE5)
|
||||
#define ipcom_getnameinfo2 ipcom_getnameinfo3
|
||||
#define ipcom_getaddrinfo2 ipcom_getaddrinfo3
|
||||
#define ipcom_freeaddrinfo2 ipcom_freeaddrinfo3
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
IP_EXTERN struct Ip_hostent *ipcom_gethostbynamelocal(const char *name,
|
||||
int family,
|
||||
Ip_u32 *ifindex,
|
||||
struct Ip_hostent *result,
|
||||
char *buf, int buflen);
|
||||
IP_EXTERN struct Ip_hostent *ipcom_gethostbyaddrlocal(const char *addr,
|
||||
int len, int family,
|
||||
struct Ip_hostent *result,
|
||||
char *buf, int buflen);
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_USE_DNS
|
||||
IP_EXTERN int ipcom_dns_init_ok;
|
||||
IP_EXTERN Ipdnsc_api ipcom_dns;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_GETINFO
|
||||
IP_PUBLIC int
|
||||
ipcom_getnameinfo2(IP_CONST struct Ip_sockaddr *sa, Ip_socklen_t salen,
|
||||
char *host, Ip_size_t hostlen,
|
||||
char *serv, Ip_size_t servlen,
|
||||
int flags);
|
||||
|
||||
IP_PUBLIC int
|
||||
ipcom_getaddrinfo2(IP_CONST char *hostname,
|
||||
IP_CONST char *servname,
|
||||
IP_CONST struct Ip_addrinfo *hints,
|
||||
struct Ip_addrinfo **res);
|
||||
#endif /* IPCOM_USE_GETINFO */
|
||||
|
||||
IP_PUBLIC void
|
||||
ipcom_freeaddrinfo2(struct Ip_addrinfo *ai);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_GETINFO
|
||||
IP_STATIC struct Ip_addrinfo *
|
||||
ipcom_getaddrinfo_alloc(void)
|
||||
{
|
||||
struct Ip_addrinfo *ai;
|
||||
|
||||
/* Allocate the ai structure */
|
||||
ai = ipcom_malloc(sizeof(*ai));
|
||||
if (ai == IP_NULL)
|
||||
return IP_NULL;
|
||||
ipcom_memset(ai, 0, sizeof(*ai));
|
||||
|
||||
/* Allocate the sockaddr structure */
|
||||
ai->ai_addr = ipcom_malloc(sizeof(union Ip_sockaddr_union));
|
||||
if (ai->ai_addr == IP_NULL)
|
||||
{
|
||||
ipcom_free(ai);
|
||||
return IP_NULL;
|
||||
}
|
||||
ipcom_memset(ai->ai_addr, 0, sizeof(union Ip_sockaddr_union));
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getnameinfo2
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getnameinfo2(IP_CONST struct Ip_sockaddr *sa, Ip_socklen_t salen,
|
||||
char *host, Ip_size_t hostlen,
|
||||
char *serv, Ip_size_t servlen,
|
||||
int flags)
|
||||
{
|
||||
union Ip_sockaddr_union *su;
|
||||
struct Ip_servent *se;
|
||||
char numserv[8];
|
||||
int family = 0;
|
||||
Ip_u16 port_n = 0;
|
||||
char *addr_n = IP_NULL;
|
||||
void *real_addr_n = IP_NULL;
|
||||
#ifdef IPCOM_USE_INET6
|
||||
Ip_u32 ipv4addr;
|
||||
char numaddr[IP_INET6_ADDRSTRLEN];
|
||||
#else
|
||||
char numaddr[IP_INET_ADDRSTRLEN];
|
||||
#endif
|
||||
char zone[16];
|
||||
struct Ip_hostent *he;
|
||||
int h_errno;
|
||||
#ifdef IPCOM_USE_DNS
|
||||
Ip_bool hes = IP_FALSE;
|
||||
#endif
|
||||
#if !defined(IPCOM_USE_DNS) || (defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65))
|
||||
char buffer[300];
|
||||
struct Ip_hostent result;
|
||||
#endif
|
||||
|
||||
/* Check arguments */
|
||||
if (sa == IP_NULL || IPCOM_SA_LEN_GET(sa) > salen)
|
||||
return IP_EAI_FAIL;
|
||||
if ((serv == IP_NULL || servlen == 0) && (host == IP_NULL || hostlen == 0))
|
||||
return IP_EAI_FAIL;
|
||||
|
||||
su = (union Ip_sockaddr_union *)sa;
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (sa->sa_family == IP_AF_INET)
|
||||
{
|
||||
family = IP_AF_INET;
|
||||
port_n = su->sin.sin_port;
|
||||
addr_n = (char *)(&su->sin.sin_addr);
|
||||
real_addr_n = addr_n;
|
||||
}
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (sa->sa_family == IP_AF_INET6)
|
||||
{
|
||||
family = IP_AF_INET6;
|
||||
port_n = su->sin6.sin6_port;
|
||||
addr_n = (char *)(&su->sin6.sin6_addr);
|
||||
real_addr_n = addr_n;
|
||||
if (IP_IN6_IS_ADDR_V4COMPAT(&su->sin6.sin6_addr) ||
|
||||
IP_IN6_IS_ADDR_V4MAPPED(&su->sin6.sin6_addr))
|
||||
{
|
||||
family = IP_AF_INET;
|
||||
ipv4addr = su->sin6.sin6_addr.in6.addr32[3];
|
||||
addr_n = (char *)&ipv4addr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (real_addr_n == IP_NULL)
|
||||
/* Invalid family */
|
||||
return IP_EAI_FAIL;
|
||||
|
||||
/* Translate the socket address to a node name */
|
||||
if (host != IP_NULL && hostlen != 0)
|
||||
{
|
||||
if (!(flags & IP_NI_NUMERICHOST))
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
#if defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65)
|
||||
he = ipcom_gethostbyaddrlocal(addr_n,
|
||||
#ifdef IPCOM_USE_INET6
|
||||
family == IP_AF_INET ? 4 : 16,
|
||||
#else
|
||||
4,
|
||||
#endif
|
||||
family,
|
||||
&result, buffer, sizeof(buffer));
|
||||
if (he)
|
||||
hes = IP_TRUE;
|
||||
else
|
||||
#endif
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
he = IP_NULL;
|
||||
else
|
||||
he = ipcom_dns.getipnodebyaddr(addr_n,
|
||||
#ifdef IPCOM_USE_INET6
|
||||
family == IP_AF_INET ? 4 : 16,
|
||||
#else
|
||||
4,
|
||||
#endif
|
||||
family, &h_errno);
|
||||
#else
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (family != IP_AF_INET)
|
||||
he = IP_NULL;
|
||||
else
|
||||
#endif
|
||||
he = ipcom_gethostbyaddr_r(addr_n, 4, IP_AF_INET, &result, buffer, sizeof(buffer), &h_errno);
|
||||
#endif /* IPCOM_USE_DNS */
|
||||
|
||||
if (he != IP_NULL)
|
||||
{
|
||||
if (ipcom_strlen(he->h_name) + 1 > hostlen)
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
return IP_EAI_MEMORY;
|
||||
}
|
||||
ipcom_strcpy(host, he->h_name);
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Try numeric */
|
||||
flags |= IP_NI_NUMERICHOST;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & IP_NI_NUMERICHOST)
|
||||
{
|
||||
if (flags & IP_NI_NAMEREQD)
|
||||
return IP_EAI_NONAME;
|
||||
|
||||
if (ipcom_inet_ntop(sa->sa_family, real_addr_n, numaddr, sizeof(numaddr)) == IP_NULL)
|
||||
return IP_EAI_SYSTEM;
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (sa->sa_family == IP_AF_INET6
|
||||
&& ((struct Ip_sockaddr_in6 *)sa)->sin6_scope_id != 0)
|
||||
{
|
||||
zone[0] = '%';
|
||||
ipcom_sprintf(&zone[1], "%u", ((struct Ip_sockaddr_in6 *)sa)->sin6_scope_id);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* ipv4 or unscoped ipv6 */
|
||||
zone[0] = '\0';
|
||||
}
|
||||
if (ipcom_strlen(numaddr) + ipcom_strlen(zone) + 1 > hostlen)
|
||||
return IP_EAI_MEMORY;
|
||||
ipcom_strcpy(host, numaddr);
|
||||
ipcom_strcat(host, zone);
|
||||
}
|
||||
}
|
||||
|
||||
/* Translate the socket address to a service */
|
||||
if (serv != IP_NULL && servlen != 0)
|
||||
{
|
||||
if (flags & IP_NI_NUMERICSERV)
|
||||
se = IP_NULL;
|
||||
else
|
||||
se = ipcom_getservbyport((int)port_n, (flags & IP_NI_DGRAM) ? "udp" : "tcp");
|
||||
|
||||
if (se)
|
||||
{
|
||||
if (ipcom_strlen(se->s_name) + 1 > servlen)
|
||||
return IP_EAI_MEMORY;
|
||||
ipcom_strcpy(serv, se->s_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_snprintf(numserv, sizeof(numserv), "%u", ip_ntohs(port_n));
|
||||
if (ipcom_strlen(numserv) + 1 > servlen)
|
||||
return IP_EAI_MEMORY;
|
||||
ipcom_strcpy(serv, numserv);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getaddrinfo2
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
/*lint -efunc(429,ipcom_getaddrinfo2) */
|
||||
/*lint -efunc(429,ipcom_getsockaddrbyaddr) */
|
||||
IP_PUBLIC int
|
||||
ipcom_getaddrinfo2(IP_CONST char *hostname,
|
||||
IP_CONST char *servname,
|
||||
IP_CONST struct Ip_addrinfo *hints,
|
||||
struct Ip_addrinfo **res)
|
||||
{
|
||||
struct Ip_addrinfo *ai = IP_NULL;
|
||||
struct Ip_addrinfo *tmp;
|
||||
int family = 0, flags = 0, socktype = 0, protocol = 0, ret;
|
||||
struct Ip_addrinfo lhints;
|
||||
int h_errno;
|
||||
#if !defined(IPCOM_USE_DNS) || (defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65))
|
||||
char buffer[300];
|
||||
struct Ip_hostent result;
|
||||
#endif
|
||||
|
||||
IP_CONST char* pHost = hostname;
|
||||
if(pHost != IP_NULL)
|
||||
while(*pHost == ' ') pHost ++;
|
||||
|
||||
/* Check arguments */
|
||||
if (pHost == IP_NULL && servname == IP_NULL)
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
if (hints != IP_NULL)
|
||||
{
|
||||
if (hints->ai_addrlen || hints->ai_canonname || hints->ai_addr || hints->ai_next)
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
if (hints->ai_flags & ~(IP_AI_PASSIVE | IP_AI_CANONNAME | IP_AI_NUMERICHOST | IP_AI_NUMERICSERV
|
||||
| IP_AI_V4MAPPED | IP_AI_ALL | IP_AI_ADDRCONFIG))
|
||||
{
|
||||
ret = IP_EAI_BADFLAGS;
|
||||
goto fail;
|
||||
}
|
||||
if (hints->ai_family != IP_AF_UNSPEC
|
||||
&& hints->ai_family != IP_AF_INET
|
||||
&& hints->ai_family != IP_AF_INET6)
|
||||
{
|
||||
ret = IP_EAI_FAMILY;
|
||||
goto fail;
|
||||
}
|
||||
if (hints->ai_socktype != 0
|
||||
&& hints->ai_socktype != IP_SOCK_STREAM
|
||||
&& hints->ai_socktype != IP_SOCK_DGRAM
|
||||
&& hints->ai_socktype != IP_SOCK_RAW)
|
||||
{
|
||||
ret = IP_EAI_SOCKTYPE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* intentional codes */
|
||||
/* coverity[copy_paste_error] */
|
||||
if (hints->ai_socktype != IP_SOCK_RAW
|
||||
&& hints->ai_protocol != 0
|
||||
&& hints->ai_protocol != IP_IPPROTO_UDP
|
||||
#ifdef IPSCTP
|
||||
&& hints->ai_protocol != IP_IPPROTO_SCTP
|
||||
#endif
|
||||
&& hints->ai_protocol != IP_IPPROTO_TCP)
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((hints->ai_socktype == IP_SOCK_STREAM && hints->ai_protocol == IP_IPPROTO_UDP)
|
||||
|| (hints->ai_socktype == IP_SOCK_DGRAM && hints->ai_protocol == IP_IPPROTO_TCP))
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (hints->ai_socktype == IP_SOCK_RAW && servname != IP_NULL)
|
||||
{
|
||||
ret = IP_EAI_SERVICE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
flags = hints->ai_flags;
|
||||
family = hints->ai_family;
|
||||
socktype = hints->ai_socktype;
|
||||
protocol = hints->ai_protocol;
|
||||
}
|
||||
|
||||
if (family == IP_AF_UNSPEC)
|
||||
{
|
||||
int ret1;
|
||||
|
||||
if (hints == IP_NULL)
|
||||
ipcom_memset(&lhints, 0, sizeof(lhints));
|
||||
else
|
||||
ipcom_memcpy(&lhints, hints, sizeof(lhints));
|
||||
lhints.ai_family = IP_AF_INET6;
|
||||
ret = ipcom_getaddrinfo2(pHost, servname, &lhints, res);
|
||||
lhints.ai_family = IP_AF_INET;
|
||||
tmp = *res;
|
||||
if (*res != IP_NULL)
|
||||
while(tmp->ai_next != IP_NULL)
|
||||
tmp = tmp->ai_next;
|
||||
ret1 = ipcom_getaddrinfo2(pHost, servname, &lhints, *res == IP_NULL ? res : &tmp->ai_next);
|
||||
return ret == 0 || ret1 == 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
/* Allocate initial addrinfo structure */
|
||||
ai = ipcom_getaddrinfo_alloc();
|
||||
if (ai == IP_NULL)
|
||||
{
|
||||
ret = IP_EAI_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Explore hostname */
|
||||
if (pHost == IP_NULL)
|
||||
{
|
||||
char *addr;
|
||||
|
||||
if (flags & IP_AI_PASSIVE)
|
||||
addr = family == IP_AF_INET ? "0.0.0.0" : "::";
|
||||
else
|
||||
addr = family == IP_AF_INET ? "127.0.0.1" : "::1";
|
||||
if (ipcom_getsockaddrbyaddr(family, addr, ai->ai_addr))
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int literal_v4 = 0, literal_v6 = 0;
|
||||
Ip_u32 ipaddr[4];
|
||||
struct Ip_hostent *he;
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
Ip_u32 ifindex = 0;
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
/* The extra 12 bytes is for a numeric %ifindex scope id string */
|
||||
char hostaddr[IP_INET6_ADDRSTRLEN+16];
|
||||
#else
|
||||
char hostaddr[16];
|
||||
#endif
|
||||
#ifdef IPCOM_USE_DNS
|
||||
Ip_bool hes = IP_FALSE;
|
||||
int dns_flags = 0;
|
||||
#endif
|
||||
|
||||
ipcom_memset(ipaddr, 0, sizeof(ipaddr));
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (family == IP_AF_INET)
|
||||
literal_v4 = ipcom_inet_pton(family, (char *) pHost, ipaddr);
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (literal_v4 == 0 && family == IP_AF_INET6)
|
||||
literal_v6 = ipcom_inet_pton(family, pHost, ipaddr);
|
||||
#endif
|
||||
if ((literal_v4 == 0) && (literal_v6 == 0))
|
||||
{
|
||||
if (flags & IP_AI_NUMERICHOST)
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (family == IP_AF_INET6)
|
||||
{
|
||||
dns_flags |= flags & IP_AI_V4MAPPED ? IPDNSC_AI_V4MAPPED : 0;
|
||||
dns_flags |= (flags & IP_AI_V4MAPPED) && (flags & IP_AI_ALL) ? IPDNSC_AI_ALL : 0;
|
||||
dns_flags |= flags & IP_AI_ADDRCONFIG ? IPDNSC_AI_ADDRCONFIG : 0;
|
||||
}
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
he = ipcom_gethostbynamelocal(pHost, family, &ifindex, &result, buffer, sizeof(buffer));
|
||||
if (he)
|
||||
hes = IP_TRUE;
|
||||
else
|
||||
#endif
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
he = IP_NULL;
|
||||
else
|
||||
he = ipcom_dns.getipnodebyname(pHost, family, dns_flags, &h_errno);
|
||||
#else
|
||||
if (family == IP_AF_INET)
|
||||
he = ipcom_gethostbyname_r(pHost, &result, buffer, sizeof(buffer), &h_errno);
|
||||
else
|
||||
he = IP_NULL;
|
||||
#endif /* IPCOM_USE_DNS */
|
||||
if (he == IP_NULL)
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
union Ip_sockaddr_union sa;
|
||||
struct Ip_addrinfo *prev = IP_NULL;
|
||||
|
||||
while (he->h_addr_list[i] != IP_NULL)
|
||||
{
|
||||
if (ipcom_inet_ntop(he->h_addrtype, he->h_addr_list[i], hostaddr, sizeof(hostaddr)) == IP_NULL
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65
|
||||
|| (ifindex != 0 && (ipcom_sprintf(ipcom_strchr(hostaddr, '\0'), "%%%u", ifindex) <= 0))
|
||||
#endif
|
||||
|| ipcom_getsockaddrbyaddr(he->h_addrtype, hostaddr, &sa.sa) != 0)
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
tmp = ai;
|
||||
else
|
||||
{
|
||||
/* Allocate additional addrinfo structure for optional alias address */
|
||||
tmp = ipcom_getaddrinfo_alloc();
|
||||
if (tmp == IP_NULL)
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
ret = IP_EAI_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy socket address */
|
||||
ipcom_memcpy(tmp->ai_addr, &sa, sizeof(union Ip_sockaddr_union));
|
||||
|
||||
/* Get the name */
|
||||
if (flags & IP_AI_CANONNAME)
|
||||
{
|
||||
tmp->ai_canonname = ipcom_strdup(he->h_name);
|
||||
if (tmp->ai_canonname == IP_NULL)
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
ret = IP_EAI_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev != IP_NULL)
|
||||
prev->ai_next = tmp;
|
||||
prev = tmp;
|
||||
i++;
|
||||
}
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (literal_v4 == 1)
|
||||
family = IP_AF_INET;
|
||||
else
|
||||
#endif
|
||||
family = IP_AF_INET6;
|
||||
|
||||
if (!(flags & IP_AI_NUMERICHOST) && (flags & IP_AI_CANONNAME))
|
||||
{
|
||||
#ifdef IPCOM_USE_DNS
|
||||
#if defined(IP_PORT_VXWORKS) && (IP_PORT_VXWORKS >= 65)
|
||||
he = ipcom_gethostbyaddrlocal((const char *)ipaddr,
|
||||
family == IP_AF_INET ? 4 : 16,
|
||||
family,
|
||||
&result, buffer, sizeof(buffer));
|
||||
if (he)
|
||||
hes = IP_TRUE;
|
||||
else
|
||||
#endif
|
||||
if (ipcom_dns_init_ok == 0)
|
||||
he = IP_NULL;
|
||||
else
|
||||
he = ipcom_dns.getipnodebyaddr(ipaddr,
|
||||
family == IP_AF_INET ? 4 : 16,
|
||||
family, &h_errno);
|
||||
#else
|
||||
if (family == IP_AF_INET)
|
||||
he = ipcom_gethostbyaddr_r((char *)ipaddr, 4, IP_AF_INET, &result, buffer, sizeof(buffer), &h_errno);
|
||||
else
|
||||
he = IP_NULL;
|
||||
#endif /* IPCOM_USE_DNS */
|
||||
if (he != IP_NULL)
|
||||
{
|
||||
ai->ai_canonname = ipcom_strdup(he->h_name);
|
||||
#ifdef IPCOM_USE_DNS
|
||||
if (hes == IP_FALSE)
|
||||
ipcom_dns.freehostent(he);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
ai->ai_canonname = ipcom_strdup(pHost);
|
||||
}
|
||||
|
||||
if (ai->ai_canonname == IP_NULL)
|
||||
{
|
||||
ret = IP_EAI_MEMORY;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
if (ipcom_getsockaddrbyaddr(family, pHost, ai->ai_addr))
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Explore servname */
|
||||
if (servname != IP_NULL)
|
||||
{
|
||||
long val;
|
||||
char *proto = IP_NULL;
|
||||
char *suff;
|
||||
struct Ip_servent *se = IP_NULL;
|
||||
Ip_in_port_t port_n;
|
||||
int i = 0, numericserv = 0;
|
||||
|
||||
if (flags & IP_AI_NUMERICSERV)
|
||||
{
|
||||
/* Allow only numeric service specification */
|
||||
numericserv = 1;
|
||||
while (servname[i] != '\0')
|
||||
{
|
||||
if (servname[i] < '0' || servname[i] > '9')
|
||||
{
|
||||
ret = IP_EAI_NONAME;
|
||||
goto fail;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (socktype == IP_SOCK_DGRAM || protocol == IP_IPPROTO_UDP)
|
||||
proto = "udp";
|
||||
#ifdef IPSCTP
|
||||
else if (socktype == IP_SOCK_STREAM && protocol == IP_IPPROTO_SCTP)
|
||||
proto = "sctp";
|
||||
#endif
|
||||
else if (socktype == IP_SOCK_STREAM || protocol == IP_IPPROTO_TCP)
|
||||
proto = "tcp";
|
||||
if (numericserv == 0)
|
||||
se = ipcom_getservbyname((char *)servname, proto);
|
||||
if (se == IP_NULL)
|
||||
{
|
||||
val = ipcom_strtol((char *)servname, &suff, 10);
|
||||
if (val < 0 || val > 0xffff || *suff != '\0' || suff == servname)
|
||||
{
|
||||
ret = IP_EAI_SERVICE;
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (proto == IP_NULL)
|
||||
proto = "udp";
|
||||
port_n = (Ip_in_port_t)ip_htons((short)val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
proto = se->s_proto;
|
||||
port_n = (Ip_in_port_t)se->s_port;
|
||||
}
|
||||
|
||||
socktype = (ipcom_strcmp(proto, "tcp") == 0 || ipcom_strcmp(proto, "sctp") == 0) ?
|
||||
IP_SOCK_STREAM : IP_SOCK_DGRAM;
|
||||
#ifdef IPSCTP
|
||||
if (protocol != IP_IPPROTO_SCTP)
|
||||
#endif
|
||||
protocol = socktype == IP_SOCK_STREAM ? IP_IPPROTO_TCP : IP_IPPROTO_UDP;
|
||||
tmp = ai;
|
||||
while (tmp != IP_NULL)
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (family == IP_AF_INET)
|
||||
((union Ip_sockaddr_union *)tmp->ai_addr)->sin.sin_port = port_n;
|
||||
#endif
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (family == IP_AF_INET6)
|
||||
((union Ip_sockaddr_union *)tmp->ai_addr)->sin6.sin6_port = port_n;
|
||||
#endif
|
||||
tmp = tmp->ai_next;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = ai;
|
||||
while (tmp != IP_NULL)
|
||||
{
|
||||
tmp->ai_flags = 0;
|
||||
tmp->ai_family = family;
|
||||
tmp->ai_socktype = socktype;
|
||||
tmp->ai_protocol = protocol;
|
||||
tmp->ai_addrlen = IPCOM_SA_LEN_GET(tmp->ai_addr);
|
||||
tmp = tmp->ai_next;
|
||||
}
|
||||
|
||||
*res = ai;
|
||||
ip_assert(*res != IP_NULL && (*res)->ai_addr != IP_NULL);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (ai != IP_NULL)
|
||||
ipcom_freeaddrinfo2(ai);
|
||||
*res = IP_NULL;
|
||||
return ret;
|
||||
}
|
||||
#endif /* IPCOM_USE_GETINFO */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_freeaddrinfo2
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_freeaddrinfo2(struct Ip_addrinfo *ai)
|
||||
{
|
||||
struct Ip_addrinfo *next;
|
||||
|
||||
while (ai != IP_NULL)
|
||||
{
|
||||
next = ai->ai_next;
|
||||
if (ai->ai_canonname != IP_NULL)
|
||||
ipcom_free(ai->ai_canonname);
|
||||
if (ai->ai_addr != IP_NULL)
|
||||
ipcom_free(ai->ai_addr);
|
||||
ipcom_free(ai);
|
||||
ai = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getput.c,v $ $Revision: 1.17 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getput.c,v $
|
||||
* $Author: ulf $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
#include "ipcom_file.h"
|
||||
#include "ipcom_shell.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fgetc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_FGETC) && IPCOM_FGETC == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_fgetc(IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
char character;
|
||||
|
||||
if (ipcom_fread(&character, 1, 1, stream) == 1)
|
||||
return (int)character;
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
char character;
|
||||
|
||||
if (stream == ip_stdin && ipcom_shell_fread(&character, 1, 1, stream) == 1)
|
||||
return (int)character;
|
||||
#endif
|
||||
|
||||
return IP_EOF;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GETC) && IPCOM_GETC == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_getc(IP_FILE *stream)
|
||||
{
|
||||
#if defined(IPCOM_FGETC) && IPCOM_FGETC == 1
|
||||
return ipcom_fgetc(stream);
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
return ipcom_fgetc((FILE *)stream);
|
||||
#else
|
||||
return ipcom_fgetc(stream);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getchar
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GETCHAR) && IPCOM_GETCHAR == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_getchar(void)
|
||||
{
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_IPCOM
|
||||
#if IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
return ipcom_fgetc(ip_stdin);
|
||||
#else
|
||||
return IP_EOF;
|
||||
#endif
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
return ipcom_fgetc(stdin);
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
return ipcom_fgetc(ip_stdin);
|
||||
#else
|
||||
return IP_EOF;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fgets
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_FGETS) && IPCOM_FGETS == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_fgets(char *buffer, int bufsize, IP_FILE *stream)
|
||||
{
|
||||
char c[1];
|
||||
char *cs;
|
||||
Ip_size_t len;
|
||||
|
||||
ip_assert(stream != IP_NULL);
|
||||
|
||||
for (cs = buffer; bufsize > 1; cs++, bufsize--)
|
||||
{
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
len = ipcom_fread(c, 1, 1, stream);
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
len = ipcom_shell_fread(c, 1, 1, stream);
|
||||
#else
|
||||
len = 0;
|
||||
#endif
|
||||
if (len != 1)
|
||||
{
|
||||
if (cs == buffer)
|
||||
return IP_NULL; /* read-error or eof and no characters. */
|
||||
break;
|
||||
}
|
||||
|
||||
if (*c == '\n')
|
||||
{
|
||||
*cs++ = '\n';
|
||||
break;
|
||||
}
|
||||
else if (*c == '\0')
|
||||
break;
|
||||
else
|
||||
*cs = *c;
|
||||
}
|
||||
|
||||
ip_assert(bufsize > 0);
|
||||
*cs = '\0';
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fputc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns: Character written or IP_EOF on error.
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_FPUTC) && IPCOM_FPUTC == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_fputc(int c, IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
char character = (char)c;
|
||||
|
||||
if (ipcom_fwrite(&character, 1, 1, stream) == 1)
|
||||
return c;
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
char character = (char)c;
|
||||
|
||||
if (ipcom_shell_fwrite(&character, 1, 1, stream) == 1)
|
||||
return c;
|
||||
#endif
|
||||
|
||||
return IP_EOF;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_putc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_PUTC) && IPCOM_PUTC == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_putc(int c, IP_FILE *stream)
|
||||
{
|
||||
#if defined(IPCOM_FPUTC) && IPCOM_FPUTC == 1
|
||||
return ipcom_fputc(c, stream);
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
return ipcom_fputc(c, (FILE *)stream);
|
||||
#else
|
||||
return ipcom_fputc(c, stream);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_putchar
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_PUTCHAR) && IPCOM_PUTCHAR == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_putchar(int c)
|
||||
{
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_IPCOM
|
||||
#if IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
return ipcom_fputc(c, ip_stdout);
|
||||
#else
|
||||
(void)c;
|
||||
return IP_EOF;
|
||||
#endif
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
return ipcom_fputc(c, stdout);
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
return ipcom_fputc(c, ip_stdout);
|
||||
#else
|
||||
(void)c;
|
||||
return IP_EOF;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fputs
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_FPUTS) && IPCOM_FPUTS == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_fputs(const char *str, IP_FILE *stream)
|
||||
{
|
||||
Ip_size_t length;
|
||||
|
||||
length = (Ip_size_t)ipcom_strlen(str);
|
||||
(void)length;
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
if (ipcom_fwrite(str, length, 1, stream) == length)
|
||||
return (int)length;
|
||||
#elif IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
if (ipcom_shell_fwrite((IP_CONST void *)str, length, 1, stream) == length)
|
||||
return (int)length;
|
||||
#endif
|
||||
|
||||
return IP_EOF;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getservby.c,v $ $Revision: 1.13 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getservby.c,v $
|
||||
* $Author: joel $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
#include "ipcom_sock2.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_service
|
||||
*===========================================================================
|
||||
*/
|
||||
struct Ipcom_service
|
||||
{
|
||||
char *name;
|
||||
int port;
|
||||
char *proto;
|
||||
char *alias1;
|
||||
char *alias2;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC IP_CONST struct Ipcom_service services[] =
|
||||
{
|
||||
{"echo", 7, "tcp", IP_NULL, IP_NULL},
|
||||
{"echo", 7, "udp", IP_NULL, IP_NULL},
|
||||
{"discard", 9, "tcp", "sink", "null"},
|
||||
{"discard", 9, "udp", "sink", "null"},
|
||||
{"ftp-data", 20, "tcp", IP_NULL, IP_NULL},
|
||||
{"ftp", 21, "tcp", IP_NULL, IP_NULL},
|
||||
{"ssh", 22, "tcp", IP_NULL, IP_NULL},
|
||||
{"ssh", 22, "udp", IP_NULL, IP_NULL},
|
||||
{"telnet", 23, "tcp", IP_NULL, IP_NULL},
|
||||
{"domain", 53, "tcp", "nameserver", IP_NULL},
|
||||
{"domain", 53, "udp", "nameserver", IP_NULL},
|
||||
{"bootps", 67, "tcp", IP_NULL, IP_NULL},
|
||||
{"bootps", 67, "udp", IP_NULL, IP_NULL},
|
||||
{"bootpc", 68, "tcp", IP_NULL, IP_NULL},
|
||||
{"bootpc", 68, "udp", IP_NULL, IP_NULL},
|
||||
{"tftp", 69, "udp", IP_NULL, IP_NULL},
|
||||
{"www", 80, "tcp", "http", IP_NULL},
|
||||
{"www", 80, "udp", IP_NULL, IP_NULL},
|
||||
{"kerberos", 88, "tcp", "kerberos5", "krb5"},
|
||||
{"kerberos", 88, "udp", "kerberos5", "krb5"},
|
||||
{"sftp", 115, "tcp", IP_NULL, IP_NULL},
|
||||
{"ntp", 123, "tcp", IP_NULL, IP_NULL},
|
||||
{"ntp", 123, "udp", IP_NULL, IP_NULL},
|
||||
{"snmp", 161, "udp", IP_NULL, IP_NULL},
|
||||
{"snmp-trap", 162, "udp", "snmptrap", IP_NULL},
|
||||
{"bgp", 179, "tcp", IP_NULL, IP_NULL},
|
||||
{"bgp", 179, "udp", IP_NULL, IP_NULL},
|
||||
{"ldap", 389, "tcp", IP_NULL, IP_NULL},
|
||||
{"ldap", 389, "udp", IP_NULL, IP_NULL},
|
||||
{"https", 443, "tcp", IP_NULL, IP_NULL},
|
||||
{"https", 443, "udp", IP_NULL, IP_NULL},
|
||||
{IP_NULL, 0, IP_NULL, IP_NULL, IP_NULL}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_find_service_byname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC struct Ipcom_service *
|
||||
ipcom_find_service_byname(const char *name, const char *proto)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(services[i].name != IP_NULL)
|
||||
{
|
||||
if(ipcom_strcmp(services[i].name, name) == 0
|
||||
|| (services[i].alias1 != IP_NULL && ipcom_strcmp(services[i].alias1, name) == 0)
|
||||
|| (services[i].alias2 != IP_NULL && ipcom_strcmp(services[i].alias2, name) == 0))
|
||||
{
|
||||
if(proto == IP_NULL || ipcom_strcmp(services[i].proto, proto) == 0)
|
||||
return (struct Ipcom_service *)&services[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_find_service_byport
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC struct Ipcom_service *
|
||||
ipcom_find_service_byport(int port, char *proto)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(services[i].name != IP_NULL)
|
||||
{
|
||||
if(services[i].port == port)
|
||||
{
|
||||
if(proto == IP_NULL || ipcom_strcmp(services[i].proto, proto) == 0)
|
||||
return (struct Ipcom_service *)&services[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getservbyname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_servent *
|
||||
ipcom_getservbyname(const char *name, const char *proto)
|
||||
{
|
||||
static struct Ip_servent se;
|
||||
static char *s_aliases[3] = { IP_NULL, IP_NULL, IP_NULL };
|
||||
struct Ipcom_service *sp;
|
||||
|
||||
if(name == IP_NULL)
|
||||
return IP_NULL;
|
||||
sp = ipcom_find_service_byname(name, proto);
|
||||
if(sp == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
se.s_name = sp->name;
|
||||
s_aliases[0] = sp->alias1;
|
||||
s_aliases[1] = sp->alias2;
|
||||
se.s_aliases = s_aliases;
|
||||
se.s_port = (int)ip_htons(sp->port);
|
||||
se.s_proto = sp->proto;
|
||||
|
||||
return &se;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getservbyport
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_servent *
|
||||
ipcom_getservbyport(int port, char *proto)
|
||||
{
|
||||
static struct Ip_servent se;
|
||||
static char *s_aliases[3] = { IP_NULL, IP_NULL, IP_NULL };
|
||||
struct Ipcom_service *sp;
|
||||
|
||||
sp = ipcom_find_service_byport((int)ip_ntohs(port), proto);
|
||||
if(sp == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
se.s_name = sp->name;
|
||||
s_aliases[0] = sp->alias1;
|
||||
s_aliases[1] = sp->alias2;
|
||||
se.s_aliases = s_aliases;
|
||||
se.s_port = (int)ip_htons(sp->port);
|
||||
se.s_proto = sp->proto;
|
||||
|
||||
return &se;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_getuid.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_getuid.c,v $
|
||||
* $Author: lob $ $Date: 2004-11-26 10:29:59 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
#ifdef USE_OSEDEF_H
|
||||
#undef USE_OSEDEF_H
|
||||
#endif
|
||||
#include <ose.h>
|
||||
#endif
|
||||
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
#ifdef IP_PORT_WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <LMCONS.H>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getuid
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GETUID) && IPCOM_GETUID == 1
|
||||
IP_PUBLIC Ip_uid_t
|
||||
ipcom_getuid(void)
|
||||
{
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
return (Ip_uid_t)get_uid(current_process());
|
||||
#elif defined(IP_PORT_WIN32)
|
||||
Ip_uid_t uid = 0;
|
||||
|
||||
TCHAR buf[UNLEN + 1];
|
||||
char* pbuf = buf;
|
||||
DWORD size = UNLEN + 1;
|
||||
|
||||
GetUserName(buf, &size);
|
||||
while (*pbuf++ != '\0')
|
||||
uid += ((*pbuf + uid) * 5213577) % 76942543 + 9871451;
|
||||
return uid;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_getuid_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_gmtime.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_gmtime.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define SECS_IN_MIN 60
|
||||
#define MINS_IN_HR 60
|
||||
#define HRS_IN_DAY 24
|
||||
#define DAYS_IN_NON_LEAP_YR 365
|
||||
|
||||
#define SECS_IN_HR (SECS_IN_MIN * MINS_IN_HR)
|
||||
#define SECS_IN_DAY (SECS_IN_HR * HRS_IN_DAY)
|
||||
#define SECS_IN_NON_LEAP_YR (SECS_IN_DAY * DAYS_IN_NON_LEAP_YR)
|
||||
|
||||
#define LEAP_YEAR(yr) ((((yr) & 0x3) == 0 && ((yr) % 100) != 0) || ((yr) % 400) == 0)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_time_timetotm
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if (defined(IPCOM_GMTIME_R) && IPCOM_GMTIME_R == 1) || (defined(IPCOM_LOCALTIME_R) && IPCOM_LOCALTIME_R == 1)
|
||||
IP_STATIC struct Ip_tm *
|
||||
ipcom_time_timetotm(const Ip_time_t *timep, struct Ip_tm *tm)
|
||||
{
|
||||
Ip_u32 secs;
|
||||
Ip_u32 days;
|
||||
Ip_u32 years;
|
||||
Ip_u32 months;
|
||||
int inc_day = 0;
|
||||
static const int days_in_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
ip_assert(timep != IP_NULL);
|
||||
|
||||
/* Get days and seconds. */
|
||||
secs = (Ip_u32)*timep;
|
||||
days = secs / SECS_IN_DAY;
|
||||
secs -= days * SECS_IN_DAY;
|
||||
|
||||
/* Set hours */
|
||||
tm->tm_hour = (int)(secs / SECS_IN_HR);
|
||||
secs -= tm->tm_hour * SECS_IN_HR;
|
||||
|
||||
/* Set minutes */
|
||||
tm->tm_min = (int)secs / SECS_IN_MIN;
|
||||
secs -= tm->tm_min * SECS_IN_MIN;
|
||||
|
||||
/* Set seconds */
|
||||
tm->tm_sec = (int)secs;
|
||||
|
||||
/* Set week day */
|
||||
tm->tm_wday = (int)((days + 4) % 7); /* + 4 since 1 Jan 1970 was a thursday. */
|
||||
|
||||
/* Set years */
|
||||
for(years = 1970;; years++)
|
||||
{
|
||||
if(LEAP_YEAR(years))
|
||||
{
|
||||
if(days < 366)
|
||||
break;
|
||||
days -= 366;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(days < 365)
|
||||
break;
|
||||
days -= 365;
|
||||
}
|
||||
}
|
||||
tm->tm_year = (int)(years - 1900);
|
||||
|
||||
/* Set year days */
|
||||
tm->tm_yday = (int)days;
|
||||
|
||||
/* Set months. */
|
||||
if(LEAP_YEAR(years) && days > 58)
|
||||
{
|
||||
if(days == 59)
|
||||
inc_day = 1;
|
||||
days--; /* Adjust for leap year extra day in february. */
|
||||
}
|
||||
ip_assert(days <= 365);
|
||||
|
||||
for(months = 0;; months++)
|
||||
{
|
||||
if(days < (Ip_u32)days_in_month[months])
|
||||
break;
|
||||
days -= (Ip_u32)days_in_month[months];
|
||||
}
|
||||
tm->tm_mon = (int)months;
|
||||
|
||||
/* Set month day. */
|
||||
tm->tm_mday = (int)(days + 1 + inc_day);
|
||||
|
||||
/*!! Not supported: Set daylight savings time flag. */
|
||||
tm->tm_isdst = 0;
|
||||
|
||||
return tm;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gmtime_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GMTIME_R) && IPCOM_GMTIME_R == 1
|
||||
IP_PUBLIC struct Ip_tm *
|
||||
ipcom_gmtime_r(const Ip_time_t *timep, struct Ip_tm *tm)
|
||||
{
|
||||
return ipcom_time_timetotm(timep, tm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gmtime
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GMTIME) && IPCOM_GMTIME == 1
|
||||
IP_PUBLIC struct Ip_tm *
|
||||
ipcom_gmtime(const Ip_time_t *timep)
|
||||
{
|
||||
static struct Ip_tm tm;
|
||||
|
||||
return ipcom_gmtime_r(timep, (struct Ip_tm *)&tm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_tzset
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_TZSET) && IPCOM_TZSET == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_tzset(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_localtime_r
|
||||
*===========================================================================
|
||||
* Context:
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_LOCALTIME_R) && IPCOM_LOCALTIME_R == 1
|
||||
IP_PUBLIC struct Ip_tm *
|
||||
ipcom_localtime_r(const Ip_time_t *timep, struct Ip_tm *tm)
|
||||
{
|
||||
/*!!timezone*/
|
||||
return ipcom_time_timetotm(timep, tm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_localtime
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_LOCALTIME) && IPCOM_LOCALTIME == 1
|
||||
IP_PUBLIC struct Ip_tm *
|
||||
ipcom_localtime(const Ip_time_t *timep)
|
||||
{
|
||||
static struct Ip_tm tm;
|
||||
|
||||
/*!!timezone*/
|
||||
return ipcom_localtime_r(timep, (struct Ip_tm *)&tm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_hostname.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_hostname.c,v $
|
||||
* $Author: lob $ $Date: 2004-11-02 12:35:33 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_sysvar.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_gethostname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_GETHOSTNAME) && IPCOM_GETHOSTNAME == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_gethostname(char *name, Ip_size_t len)
|
||||
{
|
||||
char *sysvar;
|
||||
|
||||
ip_assert2(name);
|
||||
|
||||
if (len <= 1)
|
||||
return ipcom_errno_set(IP_ERRNO_EINVAL);
|
||||
if (name == IP_NULL)
|
||||
return ipcom_errno_set(IP_ERRNO_EFAULT);
|
||||
|
||||
sysvar = ipcom_sysvar_get("ipcom.hostname", IP_NULL, IP_NULL);
|
||||
if (sysvar == IP_NULL)
|
||||
*name = '\0';
|
||||
else
|
||||
{
|
||||
ipcom_strncpy(name, sysvar, len - 1);
|
||||
name[len-1] = '\0';
|
||||
ipcom_free(sysvar);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_sethostname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_SETHOSTNAME) && IPCOM_SETHOSTNAME == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_sethostname(const char *name, Ip_size_t len)
|
||||
{
|
||||
ip_assert2(name);
|
||||
|
||||
if (len <= 1 || len >= IP_MAXHOSTNAMELEN)
|
||||
return ipcom_errno_set(IP_ERRNO_EINVAL);
|
||||
if (name == IP_NULL)
|
||||
return ipcom_errno_set(IP_ERRNO_EFAULT);
|
||||
|
||||
if (*name)
|
||||
(void)ipcom_sysvar_set("ipcom.hostname", name, IPCOM_SYSVAR_FLAG_OVERWRITE);
|
||||
else
|
||||
(void)ipcom_sysvar_unset("ipcom.hostname");
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,553 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ifaddrs.c,v $ $Revision: 1.21.10.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_ifaddrs.c,v $
|
||||
* $Author: hguo2 $ $Date: 2017-06-23 08:35:49 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_h.h"
|
||||
#include "ipcom_sock2.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_sysctl.h"
|
||||
|
||||
#if defined(IPNET) || defined(IPLITE) || (defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL))
|
||||
#include <ipnet_routesock.h>
|
||||
#include <ipnet_cmd.h>
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL)
|
||||
#include <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL)
|
||||
|
||||
#define ipcom_free free
|
||||
#define ipcom_calloc calloc
|
||||
#define ipcom_strdup strdup
|
||||
#define ipcom_malloc malloc
|
||||
#define ipcom_memcpy memcpy
|
||||
#define ipcom_memset memset
|
||||
|
||||
#ifdef ipcom_socketioctl
|
||||
#undef ipcom_socketioctl
|
||||
#define ipcom_socketioctl ioctl
|
||||
#endif /* ipcom_socketioctl */
|
||||
#define ipcom_sysctl sysctl
|
||||
|
||||
#ifdef ipcom_socket
|
||||
#undef ipcom_socket
|
||||
#define ipcom_socket socket
|
||||
#endif /* ipcom_socket */
|
||||
|
||||
#ifdef ipcom_socketclose
|
||||
#undef ipcom_socketclose
|
||||
#define ipcom_socketclose close
|
||||
#endif /* ipcom_socketclose */
|
||||
|
||||
#define ipcom_getifaddrs getifaddrs
|
||||
#define ipcom_freeifaddrs freeifaddrs
|
||||
|
||||
#ifdef IPCOM_LOG1
|
||||
#undef IPCOM_LOG1
|
||||
#define IPCOM_LOG1(x, fm, a) printf(fm, a)
|
||||
#endif /* IPCOM_LOG1 */
|
||||
|
||||
#define Ip_size_t size_t
|
||||
|
||||
|
||||
extern int socket
|
||||
(
|
||||
int domain, /* address family (AF_xxx) */
|
||||
int type, /* socket type (SOCK_xxx) */
|
||||
int protocol /* socket protocol (usually 0) */
|
||||
);
|
||||
|
||||
extern int sysctl (int *, u_int, void *, size_t *, void *, size_t);
|
||||
extern int ioctl (int fd, int function, ...);
|
||||
extern int close (int);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void
|
||||
ipcom_ifaddrs_free(struct Ip_ifaddrs *ifa)
|
||||
{
|
||||
if(ifa->ifa_name != IP_NULL)
|
||||
ipcom_free(ifa->ifa_name);
|
||||
if(ifa->ifa_addr != IP_NULL)
|
||||
ipcom_free(ifa->ifa_addr);
|
||||
if(ifa->ifa_netmask != IP_NULL)
|
||||
ipcom_free(ifa->ifa_netmask);
|
||||
if(ifa->ifa_broadaddr != IP_NULL)
|
||||
ipcom_free(ifa->ifa_broadaddr);
|
||||
|
||||
ipcom_free(ifa);
|
||||
}
|
||||
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL)
|
||||
IP_STATIC void
|
||||
ipnet_cmd_init_addrs_rtp(void *msg, Ip_u32 addrs, struct Ip_sockaddr **sas)
|
||||
{
|
||||
int i;
|
||||
Ip_size_t offset = 0;
|
||||
|
||||
for (i = 0; i < IPNET_RTAX_MAX; i++)
|
||||
{
|
||||
if (IP_BIT_ISSET(addrs, 1 << i))
|
||||
{
|
||||
sas[i] = (struct Ip_sockaddr *) &((Ip_u8 *) msg)[offset];
|
||||
offset += IPCOM_SA_LEN_GET(sas[i]);
|
||||
}
|
||||
else
|
||||
sas[i] = IP_NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
IP_STATIC void
|
||||
ipcom_create_if(Ip_fd fd,
|
||||
const char *ifname,
|
||||
struct Ip_sockaddr_dl *dl,
|
||||
struct Ipnet_if_msghdr *ifm,
|
||||
struct Ip_ifaddrs ***tail)
|
||||
{
|
||||
struct Ip_ifaddrs *nifa;
|
||||
|
||||
(void)fd;
|
||||
|
||||
nifa = ipcom_calloc(1, sizeof(*nifa));
|
||||
if (nifa == IP_NULL)
|
||||
return ;
|
||||
|
||||
/* Interface name */
|
||||
nifa->ifa_name = ipcom_strdup(ifname);
|
||||
if(nifa->ifa_name == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
/* Interface flags */
|
||||
nifa->ifa_flags = ifm->ifm_flags;
|
||||
|
||||
/* Interface address */
|
||||
nifa->ifa_addr = ipcom_malloc(IPCOM_SA_LEN_GET(dl));
|
||||
if(nifa->ifa_addr == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_memcpy(nifa->ifa_addr, dl, IPCOM_SA_LEN_GET(dl));
|
||||
|
||||
nifa->ifa_netmask = IP_NULL;
|
||||
|
||||
nifa->ifa_next = **tail;
|
||||
**tail = nifa;
|
||||
|
||||
return ;
|
||||
fail:
|
||||
ipcom_ifaddrs_free(nifa);
|
||||
return ;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_create_ifaddrs_entry
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC struct Ip_ifaddrs *
|
||||
ipcom_create_ifaddrs_entry(const char *ifname,
|
||||
struct Ipnet_if_msghdr *ifm,
|
||||
struct Ipnet_ifa_msghdr *ifa,
|
||||
struct Ip_sockaddr **addrs)
|
||||
{
|
||||
/**/
|
||||
struct Ip_ifaddrs *nifa = ipcom_calloc(1, sizeof(*nifa));
|
||||
|
||||
if (nifa == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
/* Interface name */
|
||||
nifa->ifa_name = ipcom_strdup(ifname);
|
||||
if(nifa->ifa_name == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
/* Interface flags */
|
||||
nifa->ifa_flags = ifm->ifm_flags;
|
||||
|
||||
/* Interface address */
|
||||
nifa->ifa_addr = ipcom_malloc(sizeof(union Ip_sockaddr_union));
|
||||
if(nifa->ifa_addr == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_memcpy(nifa->ifa_addr, addrs[IPNET_RTAX_IFA], IPCOM_SA_LEN_GET(addrs[IPNET_RTAX_IFA]));
|
||||
|
||||
nifa->ifa_netmask = ipcom_malloc(sizeof(union Ip_sockaddr_union));
|
||||
if(nifa->ifa_netmask == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_memcpy(nifa->ifa_netmask, addrs[IPNET_RTAX_NETMASK], IPCOM_SA_LEN_GET(addrs[IPNET_RTAX_IFA]));
|
||||
|
||||
|
||||
if (IP_BIT_ISSET(ifa->ifam_addrs, IPNET_RTA_BRD))
|
||||
{
|
||||
nifa->ifa_broadaddr = ipcom_malloc(sizeof(union Ip_sockaddr_union));
|
||||
if(nifa->ifa_broadaddr == IP_NULL)
|
||||
goto fail;
|
||||
|
||||
ipcom_memcpy(nifa->ifa_broadaddr, addrs[IPNET_RTAX_BRD], IPCOM_SA_LEN_GET(addrs[IPNET_RTAX_BRD]));
|
||||
}
|
||||
|
||||
return nifa;
|
||||
|
||||
fail:
|
||||
ipcom_ifaddrs_free(nifa);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_print_ipv4
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef IPCOM_USE_INET
|
||||
IP_STATIC Ip_size_t
|
||||
ipcom_create_ifaddrs_inet(Ip_fd fd,
|
||||
const char *ifname,
|
||||
Ip_u8 *ifa_first,
|
||||
Ip_size_t buf_len,
|
||||
struct Ipnet_if_msghdr *ifm,
|
||||
struct Ip_ifaddrs ***tail)
|
||||
{
|
||||
struct Ipnet_ifa_msghdr *ifa;
|
||||
struct Ip_sockaddr_in *addrs[IPNET_RTAX_MAX];
|
||||
Ip_size_t offset;
|
||||
|
||||
(void)fd;
|
||||
|
||||
offset = 0;
|
||||
while (offset < buf_len)
|
||||
{
|
||||
struct Ip_ifaddrs *nifa;
|
||||
|
||||
ifa = (struct Ipnet_ifa_msghdr *) &ifa_first[offset];
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL)
|
||||
ipnet_cmd_init_addrs_rtp(ifa + 1, ifa->ifam_addrs, (struct Ip_sockaddr **) addrs);
|
||||
#else
|
||||
ipnet_cmd_init_addrs(ifa + 1, ifa->ifam_addrs, (struct Ip_sockaddr **) addrs);
|
||||
#endif
|
||||
|
||||
if (ifa->ifam_type != IPNET_RTM_NEWADDR || addrs[IPNET_RTAX_IFA]->sin_family != IP_AF_INET)
|
||||
break;
|
||||
|
||||
offset += ifa->ifam_msglen;
|
||||
|
||||
if (IP_IN_CLASSD(addrs[IPNET_RTAX_IFA]->sin_addr.s_addr))
|
||||
continue;
|
||||
|
||||
nifa = ipcom_create_ifaddrs_entry(ifname, ifm, ifa, (struct Ip_sockaddr **)addrs);
|
||||
if (nifa != IP_NULL)
|
||||
{
|
||||
nifa->ifa_next = **tail;
|
||||
**tail = nifa;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
IP_STATIC Ip_size_t
|
||||
ipcom_create_ifaddrs_inet6(Ip_fd fd,
|
||||
const char *ifname,
|
||||
Ip_u8 *ifa_first,
|
||||
Ip_size_t buf_len,
|
||||
struct Ipnet_if_msghdr *ifm,
|
||||
struct Ip_ifaddrs ***tail)
|
||||
{
|
||||
struct Ip_in6_aliasreq ifareq;
|
||||
struct Ipnet_ifa_msghdr *ifa;
|
||||
struct Ip_sockaddr_in6 *addrs[IPNET_RTAX_MAX];
|
||||
Ip_size_t offset = 0;
|
||||
|
||||
offset = 0;
|
||||
while (offset < buf_len)
|
||||
{
|
||||
struct Ip_ifaddrs *nifa;
|
||||
|
||||
ifa = (struct Ipnet_ifa_msghdr *) &ifa_first[offset];
|
||||
#if defined(IP_PORT_VXWORKS) && !defined(_WRS_KERNEL)
|
||||
ipnet_cmd_init_addrs_rtp(ifa + 1, ifa->ifam_addrs, (struct Ip_sockaddr **) addrs);
|
||||
#else
|
||||
ipnet_cmd_init_addrs(ifa + 1, ifa->ifam_addrs, (struct Ip_sockaddr **) addrs);
|
||||
#endif
|
||||
|
||||
if (ifa->ifam_type != IPNET_RTM_NEWADDR || addrs[IPNET_RTAX_IFA]->sin6_family != IP_AF_INET6)
|
||||
break;
|
||||
|
||||
offset += ifa->ifam_msglen;
|
||||
|
||||
ipcom_memset(&ifareq, 0, sizeof(ifareq));
|
||||
ipcom_memcpy(ifareq.ifra_name, ifname, IP_IFNAMSIZ);
|
||||
ipcom_memcpy(&ifareq.ifra_addr, addrs[IPNET_RTAX_IFA], sizeof(ifareq.ifra_addr));
|
||||
(void)ipcom_socketioctl(fd, IP_SIOCXGIFADDR_IN6, &ifareq);
|
||||
|
||||
if (IP_BIT_ISSET(ifareq.ifra_flags, IP_IN6_IFF_ANYCAST))
|
||||
continue;
|
||||
|
||||
if (IP_IN6_IS_ADDR_MULTICAST(&addrs[IPNET_RTAX_IFA]->sin6_addr))
|
||||
continue;
|
||||
|
||||
nifa = ipcom_create_ifaddrs_entry(ifname, ifm, ifa, (struct Ip_sockaddr **)addrs);
|
||||
if (nifa != IP_NULL)
|
||||
{
|
||||
nifa->ifa_next = **tail;
|
||||
**tail = nifa;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getifaddrs
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getifaddrs(struct Ip_ifaddrs **ifa)
|
||||
{
|
||||
int name[6];
|
||||
Ip_u8 *if_data;
|
||||
Ip_size_t if_data_len;
|
||||
Ip_size_t if_data_offset;
|
||||
struct Ipnet_if_msghdr *ifm;
|
||||
struct Ip_ifaddrs **tail = ifa;
|
||||
struct Ip_sockaddr_dl *dl;
|
||||
struct Ipnet_rt_msghdr *rtm;
|
||||
Ip_fd fd = IP_INVALID_SOCKET;
|
||||
char ifname[IP_IFNAMSIZ];
|
||||
#if defined(IP_PORT_VXWORKS) && defined(IPLITE)
|
||||
extern int iplite_getifaddrs(struct Ip_ifaddrs **ifa);
|
||||
#endif
|
||||
|
||||
if(ifa == IP_NULL)
|
||||
return -1;
|
||||
*ifa = IP_NULL;
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && defined(IPLITE)
|
||||
return iplite_getifaddrs(ifa);
|
||||
#endif
|
||||
|
||||
name[0] = IP_CTL_NET;
|
||||
name[1] = IP_AF_ROUTE;
|
||||
name[2] = 0; /* Always 0 */
|
||||
name[3] = 0;
|
||||
name[4] = IP_NET_RT_IFLIST;
|
||||
name[5] = 0;
|
||||
|
||||
redo_alloc:
|
||||
if (ipcom_sysctl(name, 6, IP_NULL, &if_data_len, IP_NULL, 0) < 0)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_getifaddrs() :: ipcom_sysctl(%d) failed!"IP_LF, ipcom_errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if_data = ipcom_malloc(if_data_len);
|
||||
if (if_data == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_getifaddrs() :: ipcom_malloc(%d) failed!"IP_LF, if_data_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ipcom_sysctl(name, 6, if_data, &if_data_len, IP_NULL, 0) < 0)
|
||||
{
|
||||
if (ipcom_errno == IP_ERRNO_ENOMEM)
|
||||
{
|
||||
ipcom_free(if_data);
|
||||
goto redo_alloc;
|
||||
}
|
||||
|
||||
IPCOM_LOG1(ERR, "ipcom_getifaddrs() :: ipcom_sysctl(%d) failed!"IP_LF, ipcom_errno);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#if defined(IPCOM_USE_INET)
|
||||
fd = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, IP_IPPROTO_UDP);
|
||||
#elif defined(IPCOM_USE_INET6)
|
||||
fd = ipcom_socket(IP_AF_INET6, IP_SOCK_DGRAM, IP_IPPROTO_UDP);
|
||||
#endif
|
||||
if (fd == IP_INVALID_SOCKET)
|
||||
goto cleanup;
|
||||
|
||||
if_data_offset = 0;
|
||||
/* if_data_len returned from sysctl won't be a very big vaule. */
|
||||
/* coverity[tainted_data] */
|
||||
while (if_data_len > if_data_offset + sizeof(struct Ipnet_if_msghdr))
|
||||
{
|
||||
ifm = (struct Ipnet_if_msghdr *) &if_data[if_data_offset];
|
||||
if_data_offset += ifm->ifm_msglen;
|
||||
rtm = (struct Ipnet_rt_msghdr *)(void *)ifm;
|
||||
switch (rtm->rtm_type) {
|
||||
case IPNET_RTM_IFINFO:
|
||||
if (ifm->ifm_addrs & IPNET_RTA_IFP) {
|
||||
dl = (struct Ip_sockaddr_dl *)(void *)(ifm + 1);
|
||||
ipcom_memset(ifname,0,IP_IFNAMSIZ);
|
||||
ipcom_memcpy(ifname, dl->sdl_data,(Ip_size_t)dl->sdl_nlen);
|
||||
ipcom_create_if(fd, ifname, dl, ifm, &tail);
|
||||
break; /* Got the name! */
|
||||
}
|
||||
default:
|
||||
continue; /* No name, continue */
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
if_data_offset += ipcom_create_ifaddrs_inet(fd,
|
||||
ifname,
|
||||
&if_data[if_data_offset],
|
||||
if_data_len - if_data_offset,
|
||||
ifm,
|
||||
&tail);
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if_data_offset += ipcom_create_ifaddrs_inet6(fd,
|
||||
ifname,
|
||||
&if_data[if_data_offset],
|
||||
if_data_len - if_data_offset,
|
||||
ifm,
|
||||
&tail);
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (fd != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(fd);
|
||||
ipcom_free(if_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_freeifaddrs
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_freeifaddrs(struct Ip_ifaddrs *ifa)
|
||||
{
|
||||
struct Ip_ifaddrs *next;
|
||||
|
||||
if(ifa == IP_NULL)
|
||||
return;
|
||||
do
|
||||
{
|
||||
/* Clean the entry */
|
||||
next = ifa->ifa_next;
|
||||
ipcom_ifaddrs_free(ifa);
|
||||
ifa = next;
|
||||
}
|
||||
while(ifa != IP_NULL);
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_ifaddrs_empty_file = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,525 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_job_queue_pipe.c,v $ $Revision: 1.12.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_job_queue_pipe.c,v $
|
||||
* $Author: csun $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* IPCOM job queue pipes implementation. Supports one reader and multiple
|
||||
* writers. A job queue pipe is an IPCOM pipe implementation where
|
||||
* pipe is being read in a job posted to a job queue.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_JOB_QUEUE
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_job_queue.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_pipe.h>
|
||||
#include <ipcom_spinlock.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Returns if an "enum Ipcom_job_queue_status" means success or
|
||||
failure */
|
||||
#define IPCOM_JOB_QUEUE_OP_SUCCESS(s) ((s) >= 0)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_pipe_job_queue
|
||||
*===========================================================================
|
||||
* Job queue pipe
|
||||
*/
|
||||
typedef struct Ipcom_pipe_job_queue_struct
|
||||
{
|
||||
Ipcom_spinlock lock; /* protects all members of
|
||||
this struct */
|
||||
void **msgs; /* array of where the
|
||||
messages are stored */
|
||||
int next_send_slot; /* index of the first free
|
||||
slot in the pipe */
|
||||
int next_recv_slot; /* index of next next message
|
||||
to return from this pipe */
|
||||
int msg_limit; /* Maximum number of
|
||||
messages this pipe can
|
||||
hold */
|
||||
Ip_bool wakeup_reader; /* Set to IP_TRUE while
|
||||
holding "lock" to wakeup
|
||||
the task reading on this
|
||||
pipe */
|
||||
Ipcom_singleton_job_t job; /* job to read this pipe */
|
||||
Ipcom_singleton_job_t resume_job; /* job to continue reading
|
||||
this pipe when the "job"
|
||||
handler has exceeded its
|
||||
budget */
|
||||
int writer_cnt; /* Number of tasks that are
|
||||
sleeping or will sleep
|
||||
on the "writer_sem" */
|
||||
Ipcom_sem writer_sem; /* Semaphore writers can
|
||||
sleep on until the pipe
|
||||
becomes writable */
|
||||
Ip_pid_t creator_pid; /* PID of the creator */
|
||||
}
|
||||
Ipcom_pipe_job_queue;
|
||||
|
||||
|
||||
/* Possible outcome of send and receive operations */
|
||||
enum Ipcom_job_queue_status {
|
||||
IPCOM_JOB_QUEUE_F_FULL = -1, /* Failed, pipe is full */
|
||||
IPCOM_JOB_QUEUE_S_DONE = 0, /* Success */
|
||||
IPCOM_JOB_QUEUE_S_NEED_WAKEUP = 1, /* Success, need to wakeup
|
||||
blocked readers */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ipcom_pipe_job_queue_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_try_recv_locked
|
||||
*===========================================================================
|
||||
* Description: Tries to receive a message from the pipe.
|
||||
* Parameters: pipe - the pipe the message should be received from
|
||||
* pmsg - pointer to where the message pointer should be
|
||||
* stored if the call is successful.
|
||||
* Returns: -1 = operation failed, pipe is empty
|
||||
* 0 = operation successful
|
||||
* 0> = operation successful, need to wake return value
|
||||
* of writers.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_job_queue_pipe_try_recv_locked(Ipcom_pipe *pipe, void **pmsg)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
int next_recv_slot = p->next_recv_slot;
|
||||
|
||||
if (next_recv_slot == p->next_send_slot)
|
||||
/* Pipe is empty */
|
||||
return -1;
|
||||
|
||||
*pmsg = p->msgs[next_recv_slot];
|
||||
p->next_recv_slot = next_recv_slot + 1;
|
||||
if (p->next_recv_slot == p->msg_limit)
|
||||
p->next_recv_slot = 0;
|
||||
|
||||
if (p->next_recv_slot == p->next_send_slot && p->writer_cnt > 0)
|
||||
{
|
||||
/* Pipe empty and there is at least one task waiting to write
|
||||
this pipe. NOTE: waiting writers are only woken when the
|
||||
pipe gets empty to avoid too much context switches between
|
||||
taskes. */
|
||||
int writer_cnt = p->writer_cnt;
|
||||
|
||||
p->writer_cnt = 0;
|
||||
return writer_cnt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_try_send_locked
|
||||
*===========================================================================
|
||||
* Description: Tries to send one message to the specified pipe. This
|
||||
* function must only be called with pipe lock the be held.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns: IPCOM_JOB_QUEUE_F_FULL - operation failed, no messages
|
||||
* IPCOM_JOB_QUEUE_S_DONE - operation successful
|
||||
* IPCOM_JOB_QUEUE_S_NEED_WAKEUP - operation successful,
|
||||
* need to wakeup pending readers.
|
||||
*
|
||||
*/
|
||||
IP_STATIC enum Ipcom_job_queue_status
|
||||
ipcom_job_queue_pipe_try_send_locked(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
int next_send_slot;
|
||||
int this_send_slot;
|
||||
|
||||
this_send_slot = p->next_send_slot;
|
||||
next_send_slot = this_send_slot + 1;
|
||||
if (next_send_slot == p->msg_limit)
|
||||
next_send_slot = 0;
|
||||
|
||||
if (IP_UNLIKELY(next_send_slot == p->next_recv_slot))
|
||||
/* Pipe is full */
|
||||
return IPCOM_JOB_QUEUE_F_FULL;
|
||||
|
||||
p->msgs[this_send_slot] = msg;
|
||||
p->next_send_slot = next_send_slot;
|
||||
|
||||
if (this_send_slot == p->next_recv_slot)
|
||||
/* First message queued to this pipe, let's schedule a net
|
||||
job to read this pipe */
|
||||
return IPCOM_JOB_QUEUE_S_NEED_WAKEUP;
|
||||
|
||||
return IPCOM_JOB_QUEUE_S_DONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_dtor_helper
|
||||
*===========================================================================
|
||||
* Description: Destroys a job queue pipe.
|
||||
* Parameters: pipe - the pipe do destroy
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_job_queue_pipe_dtor_helper(Ipcom_pipe_job_queue *p)
|
||||
{
|
||||
if (p->job)
|
||||
ipcom_job_queue_singleton_delete(p->job);
|
||||
if (p->resume_job)
|
||||
ipcom_job_queue_singleton_delete(p->resume_job);
|
||||
if (p->lock != IPCOM_SPINLOCK_INVALID)
|
||||
ipcom_spinlock_delete(&p->lock);
|
||||
if (p->lock != IPCOM_SEM_INVALID)
|
||||
ipcom_sem_delete(&p->writer_sem);
|
||||
ipcom_free(p->msgs);
|
||||
ipcom_free(p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_dtor
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_job_queue_pipe_dtor(Ipcom_pipe *pipe)
|
||||
{
|
||||
ipcom_job_queue_pipe_dtor_helper(pipe->p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_new
|
||||
*===========================================================================
|
||||
* Description: Creates a new job queue pipe.
|
||||
* Parameters: msg_limit - maximum number of messages this pipe can hold
|
||||
* job_queue_func - handler that knows how to process the
|
||||
* jobs queued on this pipe.
|
||||
* Returns: Pointer the the newly created pipe or
|
||||
* IPCOM_PIPE_INVALID if a new pipe could not be created.
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ipcom_pipe_job_queue *
|
||||
ipcom_job_queue_pipe_new(int msg_limit, Ipcom_job_action job_queue_func)
|
||||
{
|
||||
Ipcom_pipe_job_queue *pipe;
|
||||
|
||||
pipe = ipcom_calloc(1, sizeof(Ipcom_pipe_job_queue));
|
||||
if (pipe == IP_NULL)
|
||||
return IPCOM_PIPE_INVALID;
|
||||
|
||||
pipe->msgs = ipcom_calloc(msg_limit, sizeof(void*));
|
||||
if (pipe->msgs == IP_NULL)
|
||||
goto errout;
|
||||
|
||||
if (ipcom_spinlock_create(&pipe->lock) != IPCOM_SUCCESS)
|
||||
goto errout;
|
||||
|
||||
if (ipcom_sem_create(&pipe->writer_sem, 0) != IPCOM_SUCCESS)
|
||||
goto errout;
|
||||
|
||||
pipe->job
|
||||
= ipcom_job_queue_singleton_new(job_queue_func,
|
||||
IPCOM_JOB_PRIO_NORMAL);
|
||||
pipe->resume_job
|
||||
= ipcom_job_queue_singleton_new(job_queue_func,
|
||||
IPCOM_JOB_PRIO_LOW);
|
||||
if (pipe->job == IP_NULL || pipe->resume_job == IP_NULL)
|
||||
goto errout;
|
||||
|
||||
pipe->msg_limit = msg_limit;
|
||||
pipe->creator_pid = ipcom_getpid();
|
||||
|
||||
return pipe;
|
||||
|
||||
errout:
|
||||
ipcom_job_queue_pipe_dtor_helper(pipe);
|
||||
return IPCOM_PIPE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_send
|
||||
*===========================================================================
|
||||
* Description: Sends one message to the specified pipe.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_job_queue_pipe_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
enum Ipcom_job_queue_status status;
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
status = ipcom_job_queue_pipe_try_send_locked(pipe, msg);
|
||||
if (IPCOM_JOB_QUEUE_OP_SUCCESS(status))
|
||||
break;
|
||||
/* else: Failed to send message since the pipe was full */
|
||||
|
||||
++p->writer_cnt;
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
/* Wait until the pipe can take more messages */
|
||||
ipcom_sem_wait(p->writer_sem);
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
}
|
||||
|
||||
if (status == IPCOM_JOB_QUEUE_S_NEED_WAKEUP)
|
||||
ipcom_job_queue_schedule_singleton(p->job);
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_try_send
|
||||
*===========================================================================
|
||||
* Description: Tries to send one message to the specified pipe.
|
||||
* Parameters: pipe - a pipe
|
||||
* msg - the message to send
|
||||
* Returns: IP_TRUE - message was successfully sent
|
||||
* IP_FALSE - operation was aborted before the message
|
||||
* got sent
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_bool
|
||||
ipcom_job_queue_pipe_try_send(Ipcom_pipe *pipe, void *msg)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
enum Ipcom_job_queue_status status;
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
status = ipcom_job_queue_pipe_try_send_locked(pipe, msg);
|
||||
|
||||
if (status == IPCOM_JOB_QUEUE_S_NEED_WAKEUP)
|
||||
ipcom_job_queue_schedule_singleton(p->job);
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
|
||||
return IPCOM_JOB_QUEUE_OP_SUCCESS(status);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_try_recv
|
||||
*===========================================================================
|
||||
* Description: Receives one message from a pipe, the operation will
|
||||
* be aborted if nothing is received within a
|
||||
* specific duration.
|
||||
* Parameters: pipe - the pipe to receive from
|
||||
* psmg - pointer to where a pointer to the message
|
||||
* should be stored
|
||||
* tv - maximum duration to wait for a message, IP_NULL
|
||||
* means wait forever. NOT USED
|
||||
* Returns: IPCOM_SUCCESS - message was received
|
||||
* IPCOM_ERR_WOULDBLOCK - no messages in the pipe
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_job_queue_pipe_try_recv(Ipcom_pipe *pipe, void **pmsg, struct Ip_timeval *tv)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
int writer_cnt;
|
||||
|
||||
IPCOM_UNUSED_ARG(tv);
|
||||
|
||||
ipcom_spinlock_lock(&p->lock);
|
||||
|
||||
writer_cnt = ipcom_job_queue_pipe_try_recv_locked(pipe, pmsg);
|
||||
|
||||
ipcom_spinlock_unlock(&p->lock);
|
||||
|
||||
while (writer_cnt > 0)
|
||||
{
|
||||
ipcom_sem_post(p->writer_sem);
|
||||
--writer_cnt;
|
||||
}
|
||||
|
||||
/* writer_cnt is negative if the receive call failed */
|
||||
return writer_cnt == 0 ? IPCOM_SUCCESS : IPCOM_ERR_WOULDBLOCK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_recv
|
||||
*===========================================================================
|
||||
* Description: The blocking version of pipe receive cannot be used
|
||||
* toghether with a job queue since the job queue daemon
|
||||
* is not allowed to block.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_job_queue_pipe_recv(Ipcom_pipe *pipe, void **pmsg)
|
||||
{
|
||||
IPCOM_UNUSED_ARG(pipe);
|
||||
IPCOM_UNUSED_ARG(pmsg);
|
||||
|
||||
IP_PANIC();
|
||||
return IPCOM_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pipe_job_queue_create
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ipcom_pipe_job_queue_create(Ipcom_pipe *pipe, Ipcom_pipe_attr *attr)
|
||||
{
|
||||
static Ipcom_pipe_ops ipcom_job_queue_pipe_ops = {
|
||||
ipcom_job_queue_pipe_dtor,
|
||||
ipcom_job_queue_pipe_send,
|
||||
ipcom_job_queue_pipe_try_send,
|
||||
ipcom_job_queue_pipe_recv,
|
||||
ipcom_job_queue_pipe_try_recv,
|
||||
};
|
||||
|
||||
pipe->p = ipcom_job_queue_pipe_new(attr->msg_limit, attr->handler);
|
||||
if (pipe->p == IPCOM_PIPE_INVALID)
|
||||
return IPCOM_ERR_FAILED;
|
||||
|
||||
pipe->ops = &ipcom_job_queue_pipe_ops;
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_pipe_schedule
|
||||
*===========================================================================
|
||||
* Description: Explicitly schedule a job that will poll the pipe.
|
||||
* Parameters: pipe - pipe to poll in the near future.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_job_queue_pipe_schedule(Ipcom_pipe *pipe)
|
||||
{
|
||||
Ipcom_pipe_job_queue *p = pipe->p;
|
||||
|
||||
ipcom_job_queue_schedule_singleton(p->resume_job);
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_job_queue_pipe_empty_file;
|
||||
#endif /* IPCOM_USE_JOB_QUEUE */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_mktime.c,v $ $Revision: 1.11 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_mktime.c,v $
|
||||
* $Author: markus $ $Date: 2004-11-29 14:13:04 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by John Lawitzke <jhl@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define SECS_IN_MIN 60
|
||||
#define MINS_IN_HR 60
|
||||
#define HRS_IN_DAY 24
|
||||
#define DAYS_IN_NON_LEAP_YR 365
|
||||
|
||||
#define SECS_IN_HR (SECS_IN_MIN * MINS_IN_HR)
|
||||
#define SECS_IN_DAY (SECS_IN_HR * HRS_IN_DAY)
|
||||
#define SECS_IN_NON_LEAP_YR (SECS_IN_DAY * DAYS_IN_NON_LEAP_YR)
|
||||
|
||||
#define LEAP_YEAR(yr) ((((yr) & 0x3) == 0 && ((yr) % 100) != 0) || ((yr) % 400) == 0)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mktime_secs_in_prev_mons_cumul
|
||||
*===========================================================================
|
||||
*/
|
||||
#if defined(IPCOM_MKTIME) && IPCOM_MKTIME == 1
|
||||
IP_STATIC Ip_time_t ipcom_mktime_secs_in_prev_mons_cumul[12] =
|
||||
{
|
||||
0,
|
||||
( 31 * SECS_IN_DAY),
|
||||
( 59 * SECS_IN_DAY),
|
||||
( 90 * SECS_IN_DAY),
|
||||
(120 * SECS_IN_DAY),
|
||||
(151 * SECS_IN_DAY),
|
||||
(181 * SECS_IN_DAY),
|
||||
(212 * SECS_IN_DAY),
|
||||
(243 * SECS_IN_DAY),
|
||||
(273 * SECS_IN_DAY),
|
||||
(304 * SECS_IN_DAY),
|
||||
(334 * SECS_IN_DAY)
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mktime
|
||||
*===========================================================================
|
||||
* Description: Converts a broken down time structure for local time to
|
||||
* calendar time. Calendar time is defined as the number of
|
||||
* seconds elapsed since 00:00:00 on January 1, 1970 UTC
|
||||
* Parameters: struct Ip_tm *tm - broken down local time structure
|
||||
* Returns: Ip_time_t - seconds since 00:00:00, Jan. 1, 1970 UTC
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MKTIME) && IPCOM_MKTIME == 1
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipcom_mktime(struct Ip_tm *tm)
|
||||
{
|
||||
Ip_time_t secs;
|
||||
int yrs_since_1970;
|
||||
int leap_yrs_since_1970;
|
||||
|
||||
/* Handle previous full years since beginning of 1970. */
|
||||
yrs_since_1970 = (int)(tm->tm_year - 70);
|
||||
secs = (Ip_time_t)(yrs_since_1970 * SECS_IN_NON_LEAP_YR);
|
||||
|
||||
/* Non-intuitive +1 follows, we're working on previous years here
|
||||
* and not the current year.
|
||||
* Note: this will break in 2400AD, which is not a leap year
|
||||
*/
|
||||
leap_yrs_since_1970 = (yrs_since_1970 + 1) / 4;
|
||||
secs += (Ip_time_t)(leap_yrs_since_1970 * SECS_IN_DAY);
|
||||
|
||||
/* Handle previous full days in this year. */
|
||||
secs += ipcom_mktime_secs_in_prev_mons_cumul[tm->tm_mon];
|
||||
secs += (Ip_time_t)((tm->tm_mday - 1) * SECS_IN_DAY);
|
||||
|
||||
/* If this year is a leap year and we're past February 29, add the day in. */
|
||||
if (LEAP_YEAR(tm->tm_year + 1900) && tm->tm_mon > 1) /* tm->mon is zero-based */
|
||||
secs += SECS_IN_DAY;
|
||||
|
||||
/* If daylight savings time is in effect, subtract 1 hour. */
|
||||
if (tm->tm_isdst != 0)
|
||||
secs -= SECS_IN_HR;
|
||||
|
||||
/* Handle the current day. */
|
||||
secs += (Ip_time_t)(tm->tm_hour * SECS_IN_HR);
|
||||
secs += (Ip_time_t)(tm->tm_min * SECS_IN_MIN);
|
||||
secs += (Ip_time_t)tm->tm_sec;
|
||||
|
||||
/*!! TODO - adjust for local time zone from GMT */
|
||||
|
||||
return secs;
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_mktime_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_normpath.c,v $ $Revision: 1.2.12.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_normpath.c,v $
|
||||
* $Author: rboden $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger.boden@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
|
||||
#include "ipcom_file.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_normpath
|
||||
*===========================================================================
|
||||
* Description: This function will resolve '..' components of paths and also
|
||||
* remove '/./' and '//' components. Some examples:,
|
||||
* ./donald///./duck/../. => donald
|
||||
* kalle/.. => .
|
||||
* kalle/../../ => ..
|
||||
* Parameters: path: the path that shall be 'normalized'
|
||||
* resolved_path: either a pointer to a buffer where the normalized
|
||||
* path shall be stored. The buffer must be at least
|
||||
* as long as the length of path. In case
|
||||
* resolved_path is IP_NULL, a new buffer will be
|
||||
* allocated.
|
||||
* Returns:
|
||||
* A pointer to resolved_path or IP_NULL if the path cannot be
|
||||
* normalized (e.g. out of memory).
|
||||
*/
|
||||
IP_PUBLIC char*
|
||||
ipcom_normpath(const char* path, char* resolved_path)
|
||||
{
|
||||
char* buf;
|
||||
char* ret;
|
||||
char* p;
|
||||
char** vec;
|
||||
int i;
|
||||
int j;
|
||||
int path_components;
|
||||
Ip_bool abs_path;
|
||||
|
||||
buf = ipcom_strdup(path);
|
||||
ret = ipcom_calloc(1, ipcom_strlen(path)+2);
|
||||
if (!buf || !ret)
|
||||
{
|
||||
if (buf)
|
||||
ipcom_free(buf);
|
||||
if (ret)
|
||||
ipcom_free(ret);
|
||||
(void)ipcom_errno_set(IP_ERRNO_ENOMEM);
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
abs_path = (path[0] == '/' ? IP_TRUE : IP_FALSE);
|
||||
|
||||
for(path_components=0, p=buf;ipcom_strtok_r(p, "/", &p); path_components++);
|
||||
vec=ipcom_calloc(path_components, sizeof(char*));
|
||||
|
||||
/* Split new path into vector */
|
||||
ipcom_strcpy(buf, path);
|
||||
for(i=0, p=buf; i<path_components; i++)
|
||||
vec[i]=ipcom_strtok_r(p, "/", &p);
|
||||
|
||||
/* Normalize (remove /../, /./ etc.) */
|
||||
for (i = 0; i < path_components; i++)
|
||||
{
|
||||
if (vec[i] != IP_NULL)
|
||||
{
|
||||
if (ipcom_strcmp(vec[i], ".") == 0)
|
||||
{
|
||||
/* Redundant */
|
||||
vec[i] = IP_NULL;
|
||||
}
|
||||
else if (ipcom_strcmp(vec[i], "..") == 0)
|
||||
{
|
||||
/* Up one level */
|
||||
for (j = i - 1; j >= 0 && vec[j] == IP_NULL; j--)
|
||||
{
|
||||
}
|
||||
|
||||
if (j < 0)
|
||||
{ /* this '..' component is in the beginning of the path */
|
||||
if (abs_path)
|
||||
{
|
||||
vec[i] = IP_NULL; /* Trying to go above root, ignore this '..' component */
|
||||
continue;
|
||||
}
|
||||
continue; /* Relative path, leave this '..' component */
|
||||
}
|
||||
if (ipcom_strcmp(vec[j], "..") == 0)
|
||||
continue; /* The previous component is also '..', hence we have a sequence of '..' components in the beginning */
|
||||
vec[i] = IP_NULL;
|
||||
vec[j] = IP_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Enter into buffer */
|
||||
if (abs_path)
|
||||
*ret = '/';
|
||||
for (i = 0; i < path_components; i++)
|
||||
{
|
||||
if (vec[i] != IP_NULL)
|
||||
{
|
||||
ipcom_strcat(ret, vec[i]);
|
||||
ipcom_strcat(ret, "/");
|
||||
}
|
||||
}
|
||||
if (ipcom_strlen(ret) == 0)
|
||||
ipcom_strcpy(ret, ".");
|
||||
else
|
||||
{
|
||||
if (ipcom_strcmp(ret, "/") != 0 && ret[ipcom_strlen(ret)-1] == '/')
|
||||
ret[ipcom_strlen(ret)-1] = 0;
|
||||
}
|
||||
|
||||
ipcom_free(buf);
|
||||
ipcom_free(vec);
|
||||
if (resolved_path)
|
||||
{
|
||||
ipcom_strcpy(resolved_path, ret);
|
||||
ipcom_free(ret);
|
||||
return resolved_path;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_perror.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_perror.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_errno.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_perror
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_PERROR) && IPCOM_PERROR == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_perror(const char *s)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM || IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
if(s != IP_NULL)
|
||||
ipcom_fprintf(ip_stderr, "%s: ", s);
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
ipcom_fprintf(ip_stderr, "%d"IP_LF, ipcom_errno);
|
||||
#else
|
||||
ipcom_fprintf(ip_stderr, "%s"IP_LF, ipcom_strerror(ipcom_errno));
|
||||
#endif
|
||||
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
perror(s);
|
||||
#else
|
||||
(void)s;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_perror_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_printf.c,v $ $Revision: 1.23 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_printf.c,v $
|
||||
* $Author: kenneth $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
#include "ipcom_file.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_shell.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_printf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_PRINTF) && IPCOM_PRINTF == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_printf(const char *format, /* args*/ ...)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
||||
(void)format;
|
||||
return -1;
|
||||
#else
|
||||
va_list ap;
|
||||
char *buf;
|
||||
int retval;
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE + 1);
|
||||
if (buf == IP_NULL)
|
||||
return -1;
|
||||
|
||||
va_start(ap, format);
|
||||
retval = ipcom_vsnprintf(buf, IPCOM_STDIO_BUFSIZE, format, ap);
|
||||
retval = IP_MIN(retval, (int) IPCOM_STDIO_BUFSIZE);
|
||||
va_end(ap);
|
||||
|
||||
if (retval > 0)
|
||||
{
|
||||
#if IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
retval = ipcom_shell_fwrite(buf, retval, 1, ip_stdout);
|
||||
#else
|
||||
retval = ipcom_fwrite(buf, retval, 1, ip_stdout);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
retval = -1;
|
||||
|
||||
ipcom_free(buf);
|
||||
return retval;
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_NONE */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fprintf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_FPRINTF) && IPCOM_FPRINTF == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_fprintf(IP_FILE *stream, const char *format, /* args*/ ...)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NONE && IPCOM_USE_FILE == IPCOM_FILE_NONE
|
||||
(void)stream;
|
||||
(void)format;
|
||||
return -1;
|
||||
#else
|
||||
va_list ap;
|
||||
char *buf;
|
||||
int retval;
|
||||
|
||||
#ifndef IP_PORT_UNIX
|
||||
if (stream == IP_NULL)
|
||||
return -1;
|
||||
#endif /* IP_PORT_UNIX */
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE + 1);
|
||||
if (buf == IP_NULL)
|
||||
{
|
||||
ipcom_errno = IP_ERRNO_ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
va_start(ap, format);
|
||||
|
||||
retval = ipcom_vsnprintf(buf, IPCOM_STDIO_BUFSIZE, format, ap);
|
||||
|
||||
if (retval > 0)
|
||||
{
|
||||
retval = IP_MIN(retval, (int) IPCOM_STDIO_BUFSIZE);
|
||||
#if IPCOM_USE_SHELL != IPCOM_SHELL_NONE
|
||||
if (stream == ip_stdout || stream == ip_stderr)
|
||||
retval = ipcom_shell_fwrite(buf, retval, 1, stream);
|
||||
else
|
||||
#endif
|
||||
retval = ipcom_fwrite(buf, retval, 1, stream);
|
||||
|
||||
}
|
||||
else
|
||||
retval = -1;
|
||||
|
||||
ipcom_free(buf);
|
||||
va_end(ap);
|
||||
|
||||
return retval;
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_NONE && IPCOM_USE_FILE == IPCOM_FILE_NONE */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,542 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_random.c,v $ $Revision: 1.47.10.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_random.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_random.c,v $ $Revision: 1.47.10.5 $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_KERNEL
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_hash.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_time.h>
|
||||
#include <ipcom_tmo.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
#ifdef IPCOM_USE_EGD
|
||||
#ifdef IPMCRYPTO
|
||||
#include <ip/openssl/md5.h>
|
||||
#else
|
||||
#ifdef OPENSSL_FIPS
|
||||
#include <openssl/sha.h>
|
||||
#else
|
||||
#include <openssl/md5.h>
|
||||
#endif /* OPENSSL_FIPS */
|
||||
#endif /* IPMCRYPTO */
|
||||
#endif /* IPCOM_USE_EGD */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && (CPU==SIMLINUX || CPU==SIMNT || CPU==SIMSOLARIS || CPU==SIMSPARCSOLARIS) \
|
||||
|| defined(IP_PORT_UNIX)
|
||||
|
||||
# ifndef IPCOM_RANDOM_LAPS
|
||||
# define IPCOM_RANDOM_LAPS 16
|
||||
# endif
|
||||
# define IPCOM_EGD_SLEEP_TIME 950
|
||||
#else
|
||||
# ifndef IPCOM_RANDOM_LAPS
|
||||
# define IPCOM_RANDOM_LAPS 128
|
||||
# endif
|
||||
# define IPCOM_EGD_SLEEP_TIME 450
|
||||
#endif
|
||||
|
||||
/* #define IPCOM_EGD_DEBUG */
|
||||
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define ipcom_egd_hash_init SHA1_Init
|
||||
#define ipcom_egd_hash_update SHA1_Update
|
||||
#define ipcom_egd_hash_final SHA1_Final
|
||||
#define Ipcom_egd_hash_ctx SHA_CTX
|
||||
#else
|
||||
#define ipcom_egd_hash_init MD5_Init
|
||||
#define ipcom_egd_hash_update MD5_Update
|
||||
#define ipcom_egd_hash_final MD5_Final
|
||||
#define Ipcom_egd_hash_ctx MD5_CTX
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#ifdef IP_PORT_UNIX
|
||||
extern Ip_u32 pthread_self(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL Ip_err ipcom_random_init(void);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_EGD
|
||||
IP_STATIC int ipcom_egd_laps;
|
||||
#ifdef OPENSSL_FIPS
|
||||
IP_STATIC Ip_u8 ipcom_random_state[20];
|
||||
#else
|
||||
IP_STATIC Ip_u8 ipcom_random_state[16];
|
||||
#endif
|
||||
IP_STATIC volatile int ipcom_egd_tmo_flag;
|
||||
|
||||
#ifdef IPCOM_EGD_DEBUG
|
||||
IP_STATIC Ip_s32 ipcom_egd_raw_data[IPCOM_RANDOM_LAPS];
|
||||
#endif
|
||||
#else
|
||||
IP_STATIC Ip_u32 ipcom_rnd_seed = 1;
|
||||
IP_STATIC Ip_u32 ipcom_rnd_state = 0;
|
||||
#endif /* IPCOM_USE_EGD */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_EGD
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random_tmo_handler
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_s32
|
||||
ipcom_random_tmo_handler(struct Ipcom_tmo_struct *tmo, void* cookie)
|
||||
{
|
||||
int* ptmo_flag = (int*) cookie;
|
||||
|
||||
(void) tmo;
|
||||
|
||||
*ptmo_flag = 1;
|
||||
|
||||
/* Do not request another timeout. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random_bingo_lotto
|
||||
*===========================================================================
|
||||
* Description: This function gathers random data. This is achieved by requesting a timeout
|
||||
* callback each 50 milli second and counting the number of laps the process
|
||||
* is able to perform before the timeout signal. Since the process runs
|
||||
* as a low priority process many other processes will be scheduled in before
|
||||
* ipcom_egd gets any CPU cycles. This is actually the "phenomenon" that
|
||||
* creates the randomness.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC Ip_s32
|
||||
ipcom_random_bingo_lotto(void)
|
||||
{
|
||||
int laps = 0;
|
||||
|
||||
while(ipcom_egd_tmo_flag == 0)
|
||||
{
|
||||
#ifdef IP_PORT_LYNXOS
|
||||
yield();
|
||||
#else
|
||||
#if (defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)) && (defined(IP_TARGET_SOFT) || defined(softOSE) || defined(IP_TARGET_SOLARIS2) || defined(IP_TARGET_LINUX) || defined(IP_TARGET_WIN32) || defined(IP_TARGET_BSD))
|
||||
delay(1);
|
||||
#endif
|
||||
#endif
|
||||
laps++;
|
||||
}
|
||||
|
||||
return laps;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_random_get(Ip_u8 *buf)
|
||||
{
|
||||
Ipcom_egd_hash_ctx ctx;
|
||||
static Ip_u32 counter = 0;
|
||||
|
||||
counter++;
|
||||
ipcom_egd_hash_init(&ctx);
|
||||
ipcom_egd_hash_update(&ctx, ipcom_random_state, sizeof(ipcom_random_state));
|
||||
ipcom_egd_hash_update(&ctx, (void*) &counter, sizeof(counter));
|
||||
ipcom_egd_hash_final(ipcom_random_state, &ctx);
|
||||
|
||||
ipcom_memcpy(buf, ipcom_random_state, sizeof(ipcom_random_state));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_egd
|
||||
*===========================================================================
|
||||
* Description: This process gathers random data by calling ipcom_random_bingo_lotto()
|
||||
*
|
||||
* Applications can access the random data before the full entropy
|
||||
* has been gathered. This will of course mean that the quality of
|
||||
* the random data will not be as good, but in some situations that
|
||||
* may be a better trade-off than no random data at all.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC
|
||||
IPCOM_PROCESS(ipcom_egd)
|
||||
{
|
||||
Ipcom_egd_hash_ctx md5_ctx;
|
||||
Ipcom_egd_hash_ctx tmp_md5_ctx;
|
||||
Ip_s32 rnd;
|
||||
Ipcom_tmo tmo;
|
||||
#ifdef IPCOM_EGD_DEBUG
|
||||
int i;
|
||||
#endif
|
||||
|
||||
ipcom_proc_init();
|
||||
|
||||
IPCOM_LOG0(DEBUG, "ipcom_egd :: starting");
|
||||
IPCOM_TMO_INIT(&tmo);
|
||||
ipcom_egd_hash_init(&md5_ctx);
|
||||
ipcom_egd_laps = 0;
|
||||
#ifdef IPCOM_EGD_DEBUG
|
||||
ipcom_memset(ipcom_egd_raw_data, 0, sizeof(ipcom_egd_raw_data));
|
||||
#endif
|
||||
|
||||
while(ipcom_egd_laps < IPCOM_RANDOM_LAPS)
|
||||
{
|
||||
ipcom_egd_tmo_flag = 0;
|
||||
if(ipcom_tmo_request(&tmo, ipcom_random_tmo_handler, (int*)&ipcom_egd_tmo_flag, 50) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ipcom_egd :: timeout request failed, seed aborted");
|
||||
goto exit;
|
||||
}
|
||||
rnd = ipcom_random_bingo_lotto();
|
||||
#ifdef IPCOM_EGD_DEBUG
|
||||
ipcom_egd_raw_data[ipcom_egd_laps] = rnd;
|
||||
#endif
|
||||
ipcom_egd_hash_update(&md5_ctx, (void*) &rnd, sizeof(Ip_u32));
|
||||
ipcom_memcpy(&tmp_md5_ctx, &md5_ctx, sizeof(Ipcom_egd_hash_ctx));
|
||||
ipcom_egd_hash_final(ipcom_random_state, &tmp_md5_ctx);
|
||||
ipcom_egd_laps++;
|
||||
ipcom_millisleep(IPCOM_EGD_SLEEP_TIME);
|
||||
}
|
||||
|
||||
exit:
|
||||
#ifdef IPCOM_EGD_DEBUG
|
||||
for (i=0; i < ipcom_egd_laps; i++)
|
||||
{
|
||||
IPCOM_LOG2(INFO, "ipcom_egd_raw_data[%d] = %d", i, ipcom_egd_raw_data[i]);
|
||||
ipcom_millisleep(100);
|
||||
}
|
||||
#endif
|
||||
IPCOM_LOG0(DEBUG, "ipcom_egd :: terminating");
|
||||
|
||||
ipcom_proc_exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_egd_random
|
||||
*===========================================================================
|
||||
* Description: This function will return the required number of random data,
|
||||
* regardless of the seed state. A caller that requires high quality
|
||||
* random data should check the random seed state first by calling
|
||||
* ipcom_egd_random_seed_state().
|
||||
* Parameters: rand_size:
|
||||
* the number of random bytes requested.
|
||||
* buf:
|
||||
* the buffer to store the random data in.
|
||||
* Returns:
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_egd_random(Ip_u8 *buf, Ip_s32 rand_size)
|
||||
{
|
||||
Ip_u8 tmp_buf[sizeof(ipcom_random_state)];
|
||||
|
||||
while(rand_size >= (Ip_s32) sizeof(ipcom_random_state))
|
||||
{
|
||||
ipcom_random_get(buf);
|
||||
buf += sizeof(ipcom_random_state);
|
||||
rand_size -= (Ip_s32)sizeof(ipcom_random_state);
|
||||
}
|
||||
|
||||
if(rand_size > 0)
|
||||
{
|
||||
ipcom_random_get(tmp_buf);
|
||||
ipcom_memcpy(buf, tmp_buf, rand_size);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* IPCOM_USE_EGD */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ipcom_random_init(void)
|
||||
{
|
||||
struct Ip_timeval tv;
|
||||
Ip_err rc = IPCOM_SUCCESS;
|
||||
unsigned h;
|
||||
unsigned *stack_addr = &h;
|
||||
|
||||
/*
|
||||
* Make sure we have some random seed at boot. It does not have to
|
||||
* very good, IPNET will add additional information to the
|
||||
* seed (like the MAC addresses of physical network interfaces) to
|
||||
* make sure that two different nodes will not generate the same
|
||||
* sequence of pseudo random numbers.
|
||||
*/
|
||||
(void) ipcom_gettimeofday(&tv, IP_NULL);
|
||||
h = ipcom_hash_update(&tv, sizeof(tv), (unsigned)ipcom_getpid());
|
||||
h = ipcom_hash_update(&stack_addr, sizeof(stack_addr), h);
|
||||
ipcom_srandom(h);
|
||||
|
||||
#ifdef IPCOM_USE_EGD
|
||||
{
|
||||
Ipcom_proc_attr attr;
|
||||
|
||||
ipcom_proc_attr_init(&attr);
|
||||
attr.priority = IPCOM_PRIORITY_BACKGROUND;
|
||||
rc = ipcom_proc_acreate("ipcom_egd", ipcom_egd, &attr, IP_NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random
|
||||
*===========================================================================
|
||||
* Description: Returns a pseudo-random number in the range [0..4294967295]
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_RANDOM) && IPCOM_RANDOM == 1
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_random(void)
|
||||
{
|
||||
Ip_u32 random_val;
|
||||
|
||||
#ifdef IPVALGRIND
|
||||
random_val = 0;
|
||||
#else
|
||||
#ifdef IPCOM_USE_EGD
|
||||
ipcom_egd_random((Ip_u8*)&random_val, sizeof(random_val));
|
||||
#else
|
||||
random_val = ipcom_rnd_state;
|
||||
|
||||
#ifdef IPCOM_USE_TIME
|
||||
{
|
||||
struct Ip_tms tms;
|
||||
random_val += (Ip_u32)ipcom_times(&tms);
|
||||
}
|
||||
#endif
|
||||
|
||||
random_val = (Ip_u32)ipcom_hash_update(&random_val,
|
||||
sizeof(random_val),
|
||||
ipcom_rnd_seed);
|
||||
ipcom_rnd_state = random_val;
|
||||
#endif
|
||||
#endif /* IPVALGRIND */
|
||||
|
||||
return random_val;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_srandom
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_SRANDOM) && IPCOM_SRANDOM == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_srandom(unsigned int seed)
|
||||
{
|
||||
#ifdef IPCOM_USE_EGD
|
||||
Ip_u8 *pseed;
|
||||
unsigned int i;
|
||||
int j;
|
||||
|
||||
pseed = (Ip_u8*)&seed;
|
||||
|
||||
for (i=0,j=0; i<sizeof(ipcom_random_state); i++)
|
||||
{
|
||||
ipcom_random_state[i] = (Ip_u8)(ipcom_random_state[i] + pseed[j]);
|
||||
j++;
|
||||
if (j%sizeof(unsigned int) == 0)
|
||||
j = 0;
|
||||
}
|
||||
|
||||
#else
|
||||
/*
|
||||
* POSIX.1-2001. requires that the same sequence has to be
|
||||
* generated given the same seed.
|
||||
*/
|
||||
ipcom_rnd_seed = seed;
|
||||
ipcom_rnd_state = 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_rand
|
||||
*===========================================================================
|
||||
* Description: Returns a pseudo-random number in the range [0..IP_RAND_MAX]
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_RAND) && IPCOM_RAND == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_rand(void)
|
||||
{
|
||||
long rnd = ipcom_random();
|
||||
if (rnd < 0)
|
||||
rnd = -rnd;
|
||||
return (int)((unsigned)rnd % ((unsigned)IP_RAND_MAX + 1u));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_srand
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_SRAND) && IPCOM_SRAND == 1
|
||||
IP_PUBLIC void
|
||||
ipcom_srand(unsigned int seed)
|
||||
{
|
||||
ipcom_srandom(seed);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_random_seed_state
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Returns a percentage (0-100) indicating how far the seeding of the
|
||||
* random generator has proceeded.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_s32
|
||||
ipcom_random_seed_state(void)
|
||||
{
|
||||
#ifdef IPCOM_USE_EGD
|
||||
return (ipcom_egd_laps*100) / IPCOM_RANDOM_LAPS;
|
||||
#else
|
||||
return 100;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_setvbuf.c,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_setvbuf.c,v $
|
||||
* $Author: kenneth $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* setvbuf implementation (required by IPSSL crypto/rand/rand_win.c).
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NONE
|
||||
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE && \
|
||||
(defined(IP_PORT_OSE) || defined(IP_PORT_OSE5) || defined(IP_PORT_VXWORKS) || defined(IP_PORT_UNIX))
|
||||
#include "stdio.h"
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_file.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_setvbuf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_setvbuf(IP_FILE *file, char *buffer, int mode, Ip_size_t bufsize)
|
||||
{
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE && (defined(IP_PORT_OSE) \
|
||||
|| defined(IP_PORT_VXWORKS) \
|
||||
|| defined(IP_PORT_UNIX))
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if(file == ip_stdin || file == ip_stdout || file == ip_stderr)
|
||||
{
|
||||
(void)file;
|
||||
(void)buffer;
|
||||
(void)mode;
|
||||
(void)bufsize;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return setvbuf((FILE *)file, buffer, mode, (size_t)bufsize);
|
||||
#else
|
||||
return setvbuf((FILE *)file, buffer, mode, (size_t)bufsize);
|
||||
#endif
|
||||
#else
|
||||
(void)file;
|
||||
(void)buffer;
|
||||
(void)mode;
|
||||
(void)bufsize;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_setvbuf_empty_file;
|
||||
#endif /* IPCOM_USE_FILE != IPCOM_FILE_NONE */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_signal.c,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_signal.c,v $
|
||||
* $Author: lob $ $Date: 2004-10-11 11:44:31 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Firstname Lastname <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 IP_PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_signal
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_SIGNAL) && IPCOM_SIGNAL == 1
|
||||
IP_PUBLIC void
|
||||
(*ipcom_signal(int sig, void (*compat)(int)))(int)
|
||||
{
|
||||
(void)sig;
|
||||
(void)compat;
|
||||
|
||||
/* do nothing. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_signal_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_snprintf.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_snprintf.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_PORT_LKM
|
||||
IP_EXTERN int ipcom_vsprintf(char *s, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_vsnprintf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if (defined(IPCOM_VSNPRINTF) && IPCOM_VSNPRINTF == 1) || (defined(IPCOM_SNPRINTF) && IPCOM_SNPRINTF == 1)
|
||||
IP_PUBLIC int
|
||||
ipcom_vsnprintf(char *s, Ip_size_t n, const char *format, va_list ap)
|
||||
{
|
||||
int retval;
|
||||
char *buf;
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE + 1);
|
||||
if(buf == IP_NULL)
|
||||
return -1;
|
||||
|
||||
/* WARNING: This is NOT a save operation, it may overflow the buffer! */
|
||||
retval = ipcom_vsprintf(buf, format, ap);
|
||||
|
||||
ip_assert(retval < (int) IPCOM_STDIO_BUFSIZE);
|
||||
if(retval > 0 && retval < (int) n)
|
||||
{
|
||||
ipcom_memcpy(s, buf, retval);
|
||||
s[retval] = '\0';
|
||||
}
|
||||
|
||||
ipcom_free(buf);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_snprintf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_SNPRINTF) && IPCOM_SNPRINTF == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_snprintf(char *s, Ip_size_t n, const char *format, /*args*/ ...)
|
||||
{
|
||||
va_list ap;
|
||||
int retval;
|
||||
|
||||
va_start(ap, format);
|
||||
retval = ipcom_vsnprintf(s, n, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_stdio.c,v $ $Revision: 1.15.164.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_stdio.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE || defined(IP_PORT_VXWORKS)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_type.h"
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_sock.h"
|
||||
#endif
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
#include "ipcom_shell.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* These file pointers do not need to point to a valid file object. We
|
||||
* only need to recognize them
|
||||
*/
|
||||
IP_STATIC IP_FILE* ipcom_stdin_file = (IP_FILE *) &ipcom_stdin_file;
|
||||
IP_STATIC IP_FILE* ipcom_stdout_file = (IP_FILE *) &ipcom_stdout_file;
|
||||
IP_STATIC IP_FILE* ipcom_stderr_file = (IP_FILE *) &ipcom_stderr_file;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_shell_stdio
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if !defined(IP_PORT_VXWORKS) && IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
IP_STATIC IP_FILE *
|
||||
ipcom_shell_stdio(int fd)
|
||||
{
|
||||
Ipcom_proc *proc;
|
||||
|
||||
proc = ipcom_proc_self();
|
||||
if(proc && (proc->shell_fd != IP_INVALID_SOCKET))
|
||||
{
|
||||
switch (fd)
|
||||
{
|
||||
case 0: /* stdin */
|
||||
return ipcom_stdin_file;
|
||||
case 1: /* stdout */
|
||||
return ipcom_stdout_file;
|
||||
case 2: /* stderr */
|
||||
return ipcom_stderr_file;
|
||||
}
|
||||
}
|
||||
return IP_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_stdout
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_FILE *
|
||||
ipcom_stdout(void)
|
||||
{
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
return (IP_FILE *)stdout;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
return ipcom_shell_stdio(1);
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
return IP_FILE_STDOUT;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
||||
return (IP_FILE *)IP_NULL;
|
||||
#else
|
||||
return (IP_FILE *)stdout;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_stderr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_FILE *
|
||||
ipcom_stderr(void)
|
||||
{
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
return (IP_FILE *)stderr;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
return ipcom_shell_stdio(2);
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
return IP_FILE_STDERR;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
||||
return (IP_FILE *)IP_NULL;
|
||||
#else
|
||||
return (IP_FILE *)stderr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_stdin
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_FILE *
|
||||
ipcom_stdin(void)
|
||||
{
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
return (IP_FILE *)stdin;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
return ipcom_shell_stdio(0);
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
||||
return IP_FILE_STDIN;
|
||||
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
||||
return (IP_FILE *)IP_NULL;
|
||||
#else
|
||||
return (IP_FILE *)stdin;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strcasecmp.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strcasecmp.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Firstname Lastname <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strcasecmp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRCASECMP) && IPCOM_STRCASECMP == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
while(ipcom_toupper(*s1) == ipcom_toupper(*s2))
|
||||
{
|
||||
if(*s1 == '\0')
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return ipcom_toupper(*s1) - ipcom_toupper(*s2);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strncasecmp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRNCASECMP) && IPCOM_STRNCASECMP == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_strncasecmp(const char *s1, const char *s2, Ip_size_t n)
|
||||
{
|
||||
if(n != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(ipcom_toupper(*s1) != ipcom_toupper(*s2))
|
||||
return (ipcom_toupper(*s1) - ipcom_toupper(*s2));
|
||||
if(*s1 == '\0')
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
while(--n != 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strdup.c,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strdup.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#define IPCOM_DMALLOC_C
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strdup
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRDUP) && IPCOM_STRDUP == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_strdup(const char *s1)
|
||||
{
|
||||
char *s2;
|
||||
|
||||
s2 = ipcom_malloc(ipcom_strlen(s1) + 1);
|
||||
if(s2 == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
ipcom_strcpy(s2, s1);
|
||||
return s2;
|
||||
}
|
||||
#else
|
||||
int ipcom_strdup_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
***************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,547 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strerror.c,v $ $Revision: 1.26.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strerror.c,v $
|
||||
* $Author: fguo $ $Date: 2012-07-04 06:59:05 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
#include <vxWorks.h>
|
||||
#include <symLib.h>
|
||||
#include <stdlib.h>
|
||||
#include <sysSymTbl.h>
|
||||
#if IP_PORT_VXWORKS >= 69
|
||||
#include <private/symLibP.h>
|
||||
#else
|
||||
#include <private/funcBindP.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_errno.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65 && USE_STRERROR_IF
|
||||
extern char *strerrorIf(int errcode);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if (defined(IPCOM_STRERROR) && IPCOM_STRERROR == 1) || \
|
||||
(defined(IPCOM_STRERROR_R) && IPCOM_STRERROR_R == 1)
|
||||
#define IPCOM_USE_STRERROR_CODE
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_USE_STRERROR_CODE
|
||||
/* to avoid compiler warning */
|
||||
int ipcom_strerror_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef IPCOM_USE_STRERROR_CODE
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strerror_int
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC char *
|
||||
ipcom_strerror_int(int errnum)
|
||||
{
|
||||
switch(errnum)
|
||||
{
|
||||
#ifdef IP_ERRNO_EPERM
|
||||
case IP_ERRNO_EPERM: return "Operation not permitted";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOENT
|
||||
case IP_ERRNO_ENOENT: return "No such file or directory";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ESRCH
|
||||
case IP_ERRNO_ESRCH: return "No such process";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EINTR
|
||||
case IP_ERRNO_EINTR: return "Interrupted system call";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EIO
|
||||
case IP_ERRNO_EIO: return "Input/output error";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENXIO
|
||||
case IP_ERRNO_ENXIO: return "Device not configured";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_E2BIG
|
||||
case IP_ERRNO_E2BIG: return "Argument list too long";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOEXEC
|
||||
case IP_ERRNO_ENOEXEC: return "Exec format error";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EBADF
|
||||
case IP_ERRNO_EBADF: return "Bad file descriptor";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ECHILD
|
||||
case IP_ERRNO_ECHILD: return "No child processes";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EDEADLK
|
||||
case IP_ERRNO_EDEADLK: return "Resource deadlock avoided";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOMEM
|
||||
case IP_ERRNO_ENOMEM: return "Cannot allocate memory";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EACCES
|
||||
case IP_ERRNO_EACCES: return "Permission denied";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EFAULT
|
||||
case IP_ERRNO_EFAULT: return "Bad address";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTBLK
|
||||
case IP_ERRNO_ENOTBLK: return "Block device required";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EBUSY
|
||||
case IP_ERRNO_EBUSY: return "Device busy";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EEXIST
|
||||
case IP_ERRNO_EEXIST: return "File exists";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EXDEV
|
||||
case IP_ERRNO_EXDEV: return "Cross-device link";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENODEV
|
||||
case IP_ERRNO_ENODEV: return "Operation not supported by device";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTDIR
|
||||
case IP_ERRNO_ENOTDIR: return "Not a directory";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EISDIR
|
||||
case IP_ERRNO_EISDIR: return "Is a directory";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EINVAL
|
||||
case IP_ERRNO_EINVAL: return "Invalid argument";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENFILE
|
||||
case IP_ERRNO_ENFILE: return "Too many open files in system";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EMFILE
|
||||
case IP_ERRNO_EMFILE: return "Too many open files";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTTY
|
||||
case IP_ERRNO_ENOTTY: return "Inappropriate ioctl for device";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ETXTBSY
|
||||
case IP_ERRNO_ETXTBSY: return "Text file busy";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EFBIG
|
||||
case IP_ERRNO_EFBIG: return "File too large";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOSPC
|
||||
case IP_ERRNO_ENOSPC: return "No space left on device";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ESPIPE
|
||||
case IP_ERRNO_ESPIPE: return "Illegal seek";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EROFS
|
||||
case IP_ERRNO_EROFS: return "Read-only file system";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EMLINK
|
||||
case IP_ERRNO_EMLINK: return "Too many links";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPIPE
|
||||
case IP_ERRNO_EPIPE: return "Broken pipe";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EDOM
|
||||
case IP_ERRNO_EDOM: return "Numerical argument out of domain";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ERANGE
|
||||
case IP_ERRNO_ERANGE: return "Result too large";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EAGAIN
|
||||
case IP_ERRNO_EAGAIN: return "Resource temporarily unavailable";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EINPROGRESS
|
||||
case IP_ERRNO_EINPROGRESS: return "Operation now in progress";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EALREADY
|
||||
case IP_ERRNO_EALREADY: return "Operation already in progress";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTSOCK
|
||||
case IP_ERRNO_ENOTSOCK: return "Socket operation on non-socket";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EDESTADDRREQ
|
||||
case IP_ERRNO_EDESTADDRREQ: return "Destination address required";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EMSGSIZE
|
||||
case IP_ERRNO_EMSGSIZE: return "Message too long";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROTOTYPE
|
||||
case IP_ERRNO_EPROTOTYPE: return "Protocol wrong type for socket";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOPROTOOPT
|
||||
case IP_ERRNO_ENOPROTOOPT: return "Protocol not available";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROTONOSUPPORT
|
||||
case IP_ERRNO_EPROTONOSUPPORT: return "Protocol not supported";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ESOCKTNOSUPPORT
|
||||
case IP_ERRNO_ESOCKTNOSUPPORT: return "Socket type not supported";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EOPNOTSUPP
|
||||
case IP_ERRNO_EOPNOTSUPP: return "Operation not supported";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPFNOSUPPORT
|
||||
case IP_ERRNO_EPFNOSUPPORT: return "Protocol family not supported";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EAFNOSUPPORT
|
||||
case IP_ERRNO_EAFNOSUPPORT: return "Address family not supported by protocol family";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EADDRINUSE
|
||||
case IP_ERRNO_EADDRINUSE: return "Address already in use";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EADDRNOTAVAIL
|
||||
case IP_ERRNO_EADDRNOTAVAIL:return "Can't assign requested address";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENETDOWN
|
||||
case IP_ERRNO_ENETDOWN: return "Network is down";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENETUNREACH
|
||||
case IP_ERRNO_ENETUNREACH: return "Network is unreachable";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENETRESET
|
||||
case IP_ERRNO_ENETRESET: return "Network dropped connection on reset";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ECONNABORTED
|
||||
case IP_ERRNO_ECONNABORTED: return "Software caused connection abort";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ECONNRESET
|
||||
case IP_ERRNO_ECONNRESET: return "Connection reset by peer";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOBUFS
|
||||
case IP_ERRNO_ENOBUFS: return "No buffer space available";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EISCONN
|
||||
case IP_ERRNO_EISCONN: return "Socket is already connected";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTCONN
|
||||
case IP_ERRNO_ENOTCONN: return "Socket is not connected";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ESHUTDOWN
|
||||
case IP_ERRNO_ESHUTDOWN: return "Can't send after socket shutdown";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ETOOMANYREFS
|
||||
case IP_ERRNO_ETOOMANYREFS: return "Too many references: can't splice";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ETIMEDOUT
|
||||
case IP_ERRNO_ETIMEDOUT: return "Operation timed out";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ECONNREFUSED
|
||||
case IP_ERRNO_ECONNREFUSED: return "Connection refused";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ELOOP
|
||||
case IP_ERRNO_ELOOP: return "Too many levels of symbolic links";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENAMETOOLONG
|
||||
case IP_ERRNO_ENAMETOOLONG: return "File name too long";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EHOSTDOWN
|
||||
case IP_ERRNO_EHOSTDOWN: return "Host is down";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EHOSTUNREACH
|
||||
case IP_ERRNO_EHOSTUNREACH: return "No route to host";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOTEMPTY
|
||||
case IP_ERRNO_ENOTEMPTY: return "Directory not empty";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROCLIM
|
||||
case IP_ERRNO_EPROCLIM: return "Too many processes";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EUSERS
|
||||
case IP_ERRNO_EUSERS: return "Too many users";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EDQUOT
|
||||
case IP_ERRNO_EDQUOT: return "Disc quota exceeded";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ESTALE
|
||||
case IP_ERRNO_ESTALE: return "Stale NFS file handle";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EREMOTE
|
||||
case IP_ERRNO_EREMOTE: return "Too many levels of remote in path";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EBADRPC
|
||||
case IP_ERRNO_EBADRPC: return "RPC struct is bad";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ERPCMISMATCH
|
||||
case IP_ERRNO_ERPCMISMATCH: return "RPC version wrong";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROGUNAVAIL
|
||||
case IP_ERRNO_EPROGUNAVAIL: return "RPC prog. not avail";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROGMISMATCH
|
||||
case IP_ERRNO_EPROGMISMATCH:return "Program version wrong";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EPROCUNAVAIL
|
||||
case IP_ERRNO_EPROCUNAVAIL: return "Bad procedure for program";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOLCK
|
||||
case IP_ERRNO_ENOLCK: return "No locks available";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOSYS
|
||||
case IP_ERRNO_ENOSYS: return "Function not implemented";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EFTYPE
|
||||
case IP_ERRNO_EFTYPE: return "Inappropriate file type or format";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EAUTH
|
||||
case IP_ERRNO_EAUTH: return "Authentication error";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENEEDAUTH
|
||||
case IP_ERRNO_ENEEDAUTH: return "Need authenticator";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EIDRM
|
||||
case IP_ERRNO_EIDRM: return "Identifier removed";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_ENOMSG
|
||||
case IP_ERRNO_ENOMSG: return "No message of desired type";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EOVERFLOW
|
||||
case IP_ERRNO_EOVERFLOW: return "Value too large for data type";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EILSEQ
|
||||
case IP_ERRNO_EILSEQ: return "Illegal byte sequence";
|
||||
#endif
|
||||
#ifdef IP_ERRNO_EINTERNAL
|
||||
case IP_ERRNO_EINTERNAL: return "Internal error";
|
||||
#endif
|
||||
#if defined(IP_ERRNO_EWOULDBLOCK) && IP_ERRNO_EWOULDBLOCK != IP_ERRNO_EAGAIN
|
||||
case IP_ERRNO_EWOULDBLOCK: return "Operation would block";
|
||||
#endif
|
||||
|
||||
default:
|
||||
return IP_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strerror_int_vxworks
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 60
|
||||
IP_STATIC char *
|
||||
ipcom_strerror_int_vxworks(int errnum)
|
||||
{
|
||||
char *name;
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 65 && USE_STRERROR_IF
|
||||
|
||||
#ifdef IP_USE_TRADITIONAL_STRERROR
|
||||
if (errnum > 0x0000ffff)
|
||||
name = strerrorIf(errnum);
|
||||
else
|
||||
name = ipcom_strerror_int(errnum);
|
||||
#else
|
||||
name = strerrorIf(errnum);
|
||||
#endif /* IP_USE_TRADITIONAL_STRERROR */
|
||||
|
||||
#else /* IP_PORT_VXWORKS < 65 */
|
||||
|
||||
if (errnum > 0x0000ffff)
|
||||
{
|
||||
name = NULL;
|
||||
|
||||
if ((_func_symFindSymbol != NULL) && statSymTbl != NULL)
|
||||
{
|
||||
char * statName;
|
||||
SYM_VALUE value;
|
||||
SYMBOL_ID symId;
|
||||
long lerrnum = errnum;
|
||||
|
||||
(* _func_symFindSymbol) (statSymTbl, NULL, (void *)lerrnum,
|
||||
SYM_MASK_NONE, SYM_MASK_NONE, &symId);
|
||||
(* _func_symNameGet) (symId, &statName);
|
||||
(* _func_symValueGet) (symId, &value);
|
||||
|
||||
if (value == (SYM_VALUE)lerrnum)
|
||||
name = statName;
|
||||
}
|
||||
}
|
||||
else
|
||||
name = ipcom_strerror_int(errnum);
|
||||
|
||||
#endif /* IP_PORT_VXWORKS < 65 */
|
||||
|
||||
return name;
|
||||
}
|
||||
#endif /* IP_PORT_VXWORKS */
|
||||
|
||||
#endif /* IPCOM_USE_STRERROR_CODE */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strerror_r
|
||||
*===========================================================================
|
||||
* Description: Reentrant version of ipcom_strerror()
|
||||
* Parameters: <errnum> is the error code.
|
||||
* <buf> points to a buffer of length <buflen> in which to
|
||||
* return the error string corresponding to <errnum>.
|
||||
* Returns: 0 on success, -1 if <buf> is NULL, or ERANGE if buflen is
|
||||
* too small to hold the error string.
|
||||
*/
|
||||
#if defined(IPCOM_STRERROR_R) && IPCOM_STRERROR_R == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_strerror_r(int errnum, char * buf, Ip_size_t buflen)
|
||||
{
|
||||
char * name;
|
||||
int n;
|
||||
|
||||
if (buf == NULL)
|
||||
return -1;
|
||||
|
||||
#if IP_PORT_VXWORKS >= 60
|
||||
name = ipcom_strerror_int_vxworks(errnum);
|
||||
#else
|
||||
name = ipcom_strerror_int(errnum);
|
||||
#endif
|
||||
|
||||
if (name)
|
||||
{
|
||||
ipcom_strncpy(buf, name, buflen);
|
||||
buf[buflen-1] = '\0';
|
||||
n = (int)ipcom_strlen(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
n = ipcom_snprintf(buf, buflen, "errno = %#x", errnum);
|
||||
#else
|
||||
n = ipcom_snprintf(buf, buflen, "Unknown error: %d", 0xffff & errnum);
|
||||
#endif
|
||||
}
|
||||
|
||||
return (n < buflen) ? 0 : IP_ERRNO_ERANGE;
|
||||
}
|
||||
#endif /* #if defined(IPCOM_STRERROR_R) && IPCOM_STRERROR_R == 1 */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strerror
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRERROR) && IPCOM_STRERROR == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_strerror(int errnum)
|
||||
{
|
||||
static char buf[128];
|
||||
char *name;
|
||||
|
||||
#if defined(IP_PORT_VXWORKS) && IP_PORT_VXWORKS >= 60
|
||||
name = ipcom_strerror_int_vxworks(errnum);
|
||||
#else
|
||||
name = ipcom_strerror_int(errnum);
|
||||
#endif
|
||||
if (name != IP_NULL)
|
||||
return name;
|
||||
|
||||
#ifdef IP_PORT_VXWORKS
|
||||
ipcom_sprintf(buf, "errno = %#x", errnum);
|
||||
#else
|
||||
ipcom_sprintf(buf, "Unknown error: %d", 0xffff & errnum);
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif /* #if defined(IPCOM_STRERROR) && IPCOM_STRERROR == 1 */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strftime.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strftime.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strftime
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRFTIME) && IPCOM_STRFTIME == 1
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_strftime(char *buf, Ip_size_t maxsize, const char *format, const struct Ip_tm *tm)
|
||||
{
|
||||
Ip_size_t size = 0;
|
||||
const char *add;
|
||||
char addbuf[32];
|
||||
static const char *day_name[8] =
|
||||
{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "ERR" };
|
||||
static const char *abbr_day_name[8] =
|
||||
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "ERR" };
|
||||
static const char *month_name[13] =
|
||||
{ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "ERR" };
|
||||
static const char *abbr_month_name[13] =
|
||||
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ERR" };
|
||||
|
||||
ip_assert(buf != IP_NULL);
|
||||
ip_assert(format != IP_NULL);
|
||||
|
||||
for(; *format && size < maxsize; format++)
|
||||
{
|
||||
if(*format != '%')
|
||||
{
|
||||
buf[size++] = *format;
|
||||
continue;
|
||||
}
|
||||
|
||||
format++;
|
||||
add = addbuf;
|
||||
switch(*format)
|
||||
{
|
||||
case 'A': /* full weekday name */
|
||||
add = day_name[IP_MIN(tm->tm_wday, 7)];
|
||||
break;
|
||||
case 'a': /* abbreviated weekday name */
|
||||
add = abbr_day_name[IP_MIN(tm->tm_wday, 7)];
|
||||
break;
|
||||
case 'B': /* full month name */
|
||||
add = month_name[IP_MIN(tm->tm_mon, 12)];
|
||||
break;
|
||||
case 'b': /* abbreviated month name */
|
||||
case 'h':
|
||||
add = abbr_month_name[IP_MIN(tm->tm_mon, 12)];
|
||||
break;
|
||||
case 'm': /* month as a decimal number [01,12] */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_mon);
|
||||
break;
|
||||
case 'd': /* day of the month as a decimal number [01,31]. */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_mday);
|
||||
break;
|
||||
case 'Y': /* year with century as a decimal number */
|
||||
ipcom_sprintf(addbuf, "%4d", tm->tm_year + 1900);
|
||||
break;
|
||||
case 'y': /* year without century as a decimal number [00,99] */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_year % 100);
|
||||
break;
|
||||
case 'H': /* hour (24-hour clock) as a decimal number [00,23] */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_hour);
|
||||
break;
|
||||
case 'M': /* minute as a decimal number [00,59] */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_min);
|
||||
break;
|
||||
case 'S': /* second as a decimal number [00,61] */
|
||||
ipcom_sprintf(addbuf, "%.2d", tm->tm_sec);
|
||||
break;
|
||||
case 'D': /* date in the format ``%m/%d/%y */
|
||||
ipcom_sprintf(addbuf, "%.2d/%.2d/%.2d", tm->tm_mon, tm->tm_mday, tm->tm_year % 100);
|
||||
break;
|
||||
case 'T': /* time in the format ``%H:%M:%S'' */
|
||||
ipcom_sprintf(addbuf, "%.2d:%.2d:%.2d", tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
break;
|
||||
default:
|
||||
ipcom_sprintf(addbuf, "%%%c", *format);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Add field. */
|
||||
for(; *add && size < maxsize; size++)
|
||||
{
|
||||
buf[size] = *add;
|
||||
add++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Null terminate 'buf'. */
|
||||
if(size < maxsize)
|
||||
buf[size] = '\0';
|
||||
else
|
||||
goto overflow;
|
||||
|
||||
/* Succcess. */
|
||||
return size;
|
||||
|
||||
overflow:
|
||||
IP_PANIC2();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_strftime_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_string_mem.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_string_mem.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_ASM
|
||||
IP_PUBLIC void *ipcom_memcpy_asm(void *s1, const void *s2, Ip_size_t n);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memcpy
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MEMCPY) && IPCOM_MEMCPY == 1
|
||||
IP_PUBLIC void *
|
||||
ipcom_memcpy(void *s1, const void *s2, Ip_size_t n)
|
||||
{
|
||||
#ifdef IPCOM_USE_ASM
|
||||
return ipcom_memcpy_asm(s1, s2, n);
|
||||
#else
|
||||
return memcpy(s1, s2, n);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memcmp
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MEMCMP) && IPCOM_MEMCMP == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_memcmp(const void *s1, const void *s2, Ip_size_t n)
|
||||
{
|
||||
return memcmp(s1, s2, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memmove
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MEMMOVE) && IPCOM_MEMMOVE == 1
|
||||
IP_PUBLIC void *
|
||||
ipcom_memmove(void *s1, const void *s2, Ip_size_t n)
|
||||
{
|
||||
return memmove(s1, s2, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memset
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MEMSET) && IPCOM_MEMSET == 1
|
||||
IP_PUBLIC void *
|
||||
ipcom_memset(void *s, int c, Ip_size_t n)
|
||||
{
|
||||
return memset(s, c, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_memchr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_MEMCHR) && IPCOM_MEMCHR == 1
|
||||
IP_PUBLIC void *
|
||||
ipcom_memchr(const void *s, int c, Ip_size_t n)
|
||||
{
|
||||
return memchr(s, c, n);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strl.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strl.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#define IPCOM_DMALLOC_C
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strlcat
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRLCAT) && IPCOM_STRLCAT == 1
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_strlcat(char *d, const char *s, Ip_size_t size)
|
||||
{
|
||||
Ip_size_t l1 = ipcom_strlen(d);
|
||||
Ip_size_t l2 = ipcom_strlen(s);
|
||||
Ip_size_t ret = l1 + l2;
|
||||
|
||||
if (l1 >= size)
|
||||
return 0;
|
||||
|
||||
if (l1+l2 >= size)
|
||||
l2 = size - (l1 + 1);
|
||||
|
||||
if (l2 > 0)
|
||||
{
|
||||
ipcom_memcpy(d + l1, s, l2);
|
||||
d[l1+l2] = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int ipcom_strlcat_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strlcpy
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRLCPY) && IPCOM_STRLCPY == 1
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_strlcpy(char *d, const char *s, Ip_size_t size)
|
||||
{
|
||||
Ip_size_t l = ipcom_strlen(s);
|
||||
Ip_size_t ret = l;
|
||||
|
||||
if (size <= 0)
|
||||
return 0;
|
||||
|
||||
if (l >= size)
|
||||
l = size - 1;
|
||||
|
||||
ipcom_memcpy(d, s, l);
|
||||
d[l] = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int ipcom_strlcpy_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
***************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strsep.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strsep.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Firstname Lastname <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strsep
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRSEP) && IPCOM_STRSEP == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_strsep(char **cp, const char *d)
|
||||
{
|
||||
char *s, *tok;
|
||||
const char *spanp;
|
||||
Ip_s32 c, sc;
|
||||
|
||||
s = *cp;
|
||||
if(s == IP_NULL)
|
||||
return IP_NULL;
|
||||
|
||||
for(tok = s;;)
|
||||
{
|
||||
c = *s++;
|
||||
spanp = d;
|
||||
do
|
||||
{
|
||||
sc = *spanp++;
|
||||
if(sc == c)
|
||||
{
|
||||
if(c == 0)
|
||||
s = IP_NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
*cp = s;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
while(sc != 0);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_strsep_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strto.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strto.c,v $
|
||||
* $Author: ulf $ $Date: 2008-10-13 15:05:23 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_LONG_MAX ((long)(((unsigned long) -1L) >> 1))
|
||||
#define IPCOM_LONG_MIN (~IPCOM_LONG_MAX)
|
||||
#define IPCOM_ULONG_MAX ((unsigned long)~0UL)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strtol
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRTOL) && IPCOM_STRTOL == 1
|
||||
IP_PUBLIC long
|
||||
ipcom_strtol(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long cutoff;
|
||||
unsigned long acc;
|
||||
int neg = 0;
|
||||
int cutlim;
|
||||
int any;
|
||||
int c;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do
|
||||
{
|
||||
c = *s++;
|
||||
}
|
||||
while (ipcom_isspace (c));
|
||||
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
{
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
if (((base == 0) || (base == 16)) &&
|
||||
(c == '0') &&
|
||||
((*s == 'x') || (*s == 'X')))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
{
|
||||
base = (c == '0' ? 8 : 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the cutoff value between legal numbers and illegal
|
||||
* numbers. That is the largest legal value, divided by the
|
||||
* base. An input number that is greater than this value, if
|
||||
* followed by a legal input character, is too big. One that
|
||||
* is equal to this value may be valid or not; the limit
|
||||
* between valid and invalid numbers is then based on the last
|
||||
* digit. For instance, if the range for longs is
|
||||
* [-2147483648..2147483647] and the input base is 10,
|
||||
* cutoff will be set to 214748364 and cutlim to either
|
||||
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
|
||||
* a value > 214748364, or equal but the next digit is > 7 (or 8),
|
||||
* the number is too big, and we will return a range error.
|
||||
*
|
||||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
|
||||
cutoff = (neg ? -(unsigned long)IPCOM_LONG_MIN : IPCOM_LONG_MAX);
|
||||
cutlim = cutoff % (unsigned long)base;
|
||||
cutoff /= (unsigned long)base;
|
||||
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (ipcom_isdigit (c))
|
||||
{
|
||||
c -= '0';
|
||||
}
|
||||
else if (ipcom_isalpha (c))
|
||||
{
|
||||
c -= (ipcom_isupper(c) ? 'A' - 10 : 'a' - 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (c >= base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ((any < 0) || (acc > cutoff) || ((acc == cutoff) && (c > cutlim)))
|
||||
{
|
||||
any = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (any < 0)
|
||||
{
|
||||
acc = (neg ? IPCOM_LONG_MIN : IPCOM_LONG_MAX);
|
||||
}
|
||||
else if (neg)
|
||||
{
|
||||
acc = -acc;
|
||||
}
|
||||
|
||||
if (endptr != 0)
|
||||
{
|
||||
*endptr = (char *)(any ? (s - 1) : nptr);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strtoul
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_STRTOUL) && IPCOM_STRTOUL == 1
|
||||
IP_PUBLIC unsigned long
|
||||
ipcom_strtoul(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
unsigned long cutoff;
|
||||
unsigned long acc;
|
||||
int neg = 0;
|
||||
int cutlim;
|
||||
int any;
|
||||
int c;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do
|
||||
{
|
||||
c = *s++;
|
||||
}
|
||||
while (ipcom_isspace (c));
|
||||
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
{
|
||||
c = *s++;
|
||||
}
|
||||
|
||||
if (((base == 0) || (base == 16)) &&
|
||||
(c == '0') &&
|
||||
((*s == 'x') || (*s == 'X')))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
{
|
||||
base = (c == '0' ? 8 : 10);
|
||||
}
|
||||
|
||||
cutoff = (unsigned long)IPCOM_ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (unsigned long)IPCOM_ULONG_MAX % (unsigned long)base;
|
||||
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (ipcom_isdigit (c))
|
||||
{
|
||||
c -= '0';
|
||||
}
|
||||
else if (ipcom_isalpha (c))
|
||||
{
|
||||
c -= (ipcom_isupper (c) ? 'A' - 10 : 'a' - 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (c >= base)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ((any < 0) || (acc > cutoff) || ((acc == cutoff) && (c > cutlim)))
|
||||
{
|
||||
any = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (any < 0)
|
||||
{
|
||||
acc = IPCOM_ULONG_MAX;
|
||||
}
|
||||
else if (neg)
|
||||
{
|
||||
acc = -acc;
|
||||
}
|
||||
|
||||
if (endptr != 0)
|
||||
{
|
||||
*endptr = (char *)(any ? (s - 1) : nptr);
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atoi
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ATOI) && IPCOM_ATOI == 1
|
||||
IP_PUBLIC int
|
||||
ipcom_atoi(const char *s)
|
||||
{
|
||||
return (int)ipcom_strtol (s, IP_NULL, 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atol
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_ATOL) && IPCOM_ATOL == 1
|
||||
IP_PUBLIC long
|
||||
ipcom_atol(const char *s)
|
||||
{
|
||||
return ipcom_strtol (s, IP_NULL, 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_strtok_r.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_strtok_r.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-10 17:31:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Firstname Lastname <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_strtok_r
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
#if defined(IPCOM_STRTOK_R) && IPCOM_STRTOK_R == 1
|
||||
IP_PUBLIC char *
|
||||
ipcom_strtok_r(char *s, const char *st, char **last)
|
||||
{
|
||||
char *start;
|
||||
char *stop;
|
||||
|
||||
start = s ? s : *last;
|
||||
while (*start != '\0' && ipcom_strchr(st, *start) != IP_NULL)
|
||||
start++;
|
||||
stop = start;
|
||||
while (*stop != '\0' && ipcom_strchr(st, *stop) == IP_NULL)
|
||||
stop++;
|
||||
if (*stop != '\0')
|
||||
*stop++ = '\0';
|
||||
*last = stop;
|
||||
|
||||
return ipcom_strlen(start) ? start : IP_NULL;
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_strtok_r_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_termios.c,v $ $Revision: 1.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_termios.c,v $
|
||||
* $Author: lob $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_IPCOM && \
|
||||
(defined(IP_PORT_OSE) || defined(IP_PORT_OSE5) || defined(IP_PORT_UNIX))
|
||||
#ifndef IPCOM_USE_TERMIOS
|
||||
#define IPCOM_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_USE_TERMIOS
|
||||
#include <termios.h>
|
||||
#else
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_file.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_IPCOM
|
||||
IP_PUBLIC int ipcom_tcgetattr(Ip_fd fd, struct Ip_termios *termios_p);
|
||||
IP_PUBLIC int ipcom_tcsetattr(Ip_fd fd, int optional_actions, const struct Ip_termios *termios_p);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_tcgetattr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_tcgetattr(Ip_fd fd, struct Ip_termios *termios_p)
|
||||
{
|
||||
#ifdef IPCOM_USE_TERMIOS
|
||||
return tcgetattr((int)fd, (struct termios *)termios_p);
|
||||
#else
|
||||
(void)fd;
|
||||
ipcom_memset(termios_p, 0, sizeof(struct Ip_termios));
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_tcsetattr
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_tcsetattr(Ip_fd fd, int optional_actions, const struct Ip_termios *termios_p)
|
||||
{
|
||||
#ifdef IPCOM_USE_TERMIOS
|
||||
return tcsetattr((int)fd, optional_actions, (const struct termios *)termios_p);
|
||||
#else
|
||||
(void)fd;
|
||||
(void)optional_actions;
|
||||
(void)termios_p;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_times.c,v $ $Revision: 1.3.172.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_times.c,v $
|
||||
* $Author: jren $ $Date: 2023-10-20 05:48:41 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_times
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_TIMES) && IPCOM_TIMES == 1
|
||||
IP_PUBLIC Ip_clock_t
|
||||
ipcom_times(struct Ip_tms *buf)
|
||||
{
|
||||
struct Ip_timeval tv;
|
||||
Ip_time_t now;
|
||||
static Ip_time_t start = 0;
|
||||
|
||||
ipcom_microtime(&tv);
|
||||
|
||||
if(start == 0)
|
||||
start = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
|
||||
now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
|
||||
/* Fix for clock being set back in time. */
|
||||
if(start > now)
|
||||
start = now;
|
||||
|
||||
/*!! NOTE: Nonsense values. */
|
||||
if (buf != IP_NULL)
|
||||
{
|
||||
buf->tms_utime = now;
|
||||
buf->tms_stime = now;
|
||||
buf->tms_cutime = now;
|
||||
buf->tms_cstime = now;
|
||||
}
|
||||
|
||||
return (Ip_clock_t)(now - start); /* milliseconds since system start. */
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_times_empty_file;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_uname.c,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_uname.c,v $
|
||||
* $Author: lob $ $Date: 2004-08-12 15:35:14 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_uname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_uname(struct Ip_utsname *info)
|
||||
{
|
||||
ipcom_memset(info, 0, sizeof(*info));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_vr.c,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_vr.c,v $
|
||||
* $Author: jhorteli $ $Date: 2007-11-30 08:37:59 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef IP_PORT_LKM
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
#include <ose.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if !defined(IP_PORT_LAS)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_proc_vr_get
|
||||
*===========================================================================
|
||||
* Description: Get VR id for this process.
|
||||
* Parameters: -
|
||||
* Returns: VR
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_proc_vr_get(void)
|
||||
{
|
||||
return ipcom_getenv_as_int("VR", 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(IP_PORT_LAS)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_proc_vr_set
|
||||
*===========================================================================
|
||||
* Description: Set VR id for this process.
|
||||
* Parameters: VR id
|
||||
* Returns: -
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_proc_vr_set(int vr)
|
||||
{
|
||||
(void)ipcom_setenv_as_int("VR", vr, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_proc_vr_get_for
|
||||
*===========================================================================
|
||||
* Description: Get VR id for specified process.
|
||||
* Parameters: Process ID.
|
||||
* Returns: VR
|
||||
*/
|
||||
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
IP_PUBLIC int
|
||||
ipcom_proc_vr_get_for(Ip_pid_t pid)
|
||||
{
|
||||
#if defined(IP_PORT_OSE) || defined(IP_PORT_OSE5)
|
||||
char *env;
|
||||
int vr = 0;
|
||||
|
||||
env = get_env((PROCESS)pid, "VR");
|
||||
if (env != IP_NULL)
|
||||
{
|
||||
vr = ipcom_atoi(env);
|
||||
free_buf((union SIGNAL **)&env);
|
||||
}
|
||||
return vr;
|
||||
#else
|
||||
IP_PANIC();
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
int ipcom_vr_empty_file;
|
||||
#endif /*! IP_PORT_LKM */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_xtime.c,v $ $Revision: 1.16 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_xtime.c,v $
|
||||
* $Author: jonas $ $Date: 2008-08-20 14:00:41 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IPCOM_CLOCK) && defined(IPCOM_TIME)
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#else
|
||||
#include <time.h>
|
||||
#if !defined(IP_PORT_WIN32) && !defined(IP_PORT_VXWORKS) && !defined(IP_PORT_RTCORE)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_time.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_clock
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_CLOCK) && IPCOM_CLOCK == 1
|
||||
IP_PUBLIC Ip_clock_t
|
||||
ipcom_clock(void)
|
||||
{
|
||||
struct Ip_timeval tv;
|
||||
|
||||
ipcom_microtime(&tv);
|
||||
|
||||
/* Return microseconds since CLOCKS_PER_SEC = 1000000 in ANSI C/POSIX */
|
||||
return tv.tv_sec * 1000000 + tv.tv_usec;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_time
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IPCOM_TIME) && IPCOM_TIME == 1
|
||||
IP_PUBLIC Ip_time_t
|
||||
ipcom_time(Ip_time_t *tp)
|
||||
{
|
||||
struct Ip_timeval tv;
|
||||
|
||||
(void)ipcom_gettimeofday(&tv, IP_NULL);
|
||||
|
||||
if (tp != IP_NULL)
|
||||
*tp = (Ip_time_t)tv.tv_sec;
|
||||
|
||||
return (Ip_time_t)tv.tv_sec;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_xtoyz.c,v $ $Revision: 1.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_xtoyz.c,v $
|
||||
* $Author: lob $ $Date: 2006-09-20 08:30:04 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_sock.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_htons
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u16
|
||||
ipcom_htons(Ip_u16 host)
|
||||
{
|
||||
return ip_htons(host);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ntohs
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u16
|
||||
ipcom_ntohs(Ip_u16 net)
|
||||
{
|
||||
return ip_ntohs(net);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_htonl
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_htonl(Ip_u32 host)
|
||||
{
|
||||
return ip_htonl(host);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ntohl
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_ntohl(Ip_u32 net)
|
||||
{
|
||||
return ip_ntohl(net);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pautoconf.h,v $ $Revision: 1.11.10.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/config/ipcom_pautoconf.h,v $
|
||||
* $Author: hxie $ $Date: 2013-07-16 07:23:42 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PAUTOCONF_H
|
||||
#define IPCOM_PAUTOCONF_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create translation from VSB defines in autoconf.h. This is required to
|
||||
* make the defines available in a VIP.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* When building an OPT=-basic system, the VSB defines don't match the
|
||||
* included product makefiles (some makefiles are not included). This
|
||||
* means that we cannot enable the product defines below since the
|
||||
* corresponding include paths may be missing when compiling.
|
||||
*/
|
||||
#if defined(_WRS_KERNEL) && !defined(IPBASIC)
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IP8021X) || defined( _WRS_CONFIG_COMPONENT_USR_IP8021X)) && !defined(IP8021X)
|
||||
#define IP8021X
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPAPPL) || defined( _WRS_CONFIG_COMPONENT_USR_IPAPPL)) && !defined(IPAPPL)
|
||||
#define IPAPPL
|
||||
#endif
|
||||
|
||||
#if defined (_WRS_CONFIG_IPFTP_USE_TLS) && !defined(IPFTP_TLS)
|
||||
#define IPFTP_TLS
|
||||
#endif
|
||||
|
||||
#if ( defined(_WRS_CONFIG_COMPONENT_IPCRYPTO) || defined(_WRS_CONFIG_COMPONENT_USR_IPCRYPTO)) && !defined(IPCRYPTO)
|
||||
#define IPCRYPTO
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDHCPC6) || defined(_WRS_CONFIG_COMPONENT_USR_IPDHCPC6)) && !defined(IPDHCPC6)
|
||||
#define IPDHCPC6
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDHCPR) || defined(_WRS_CONFIG_COMPONENT_USR_IPDHCPR)) && !defined(IPDHCPR)
|
||||
#define IPDHCPR
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDHCPS) ||defined( _WRS_CONFIG_COMPONENT_USR_IPDHCPS)) && !defined(IPDHCPS)
|
||||
#define IPDHCPS
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDHCPS6) || defined(_WRS_CONFIG_COMPONENT_USR_IPDHCPS6)) && !defined(IPDHCPS6)
|
||||
#define IPDHCPS6
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDIAMETERC) || defined(_WRS_CONFIG_COMPONENT_USR_IPDIAMETERC)) && !defined(IPDIAMETERC)
|
||||
#define IPDIAMETERC
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPDIAMETERP) ||defined( _WRS_CONFIG_COMPONENT_USR_IPDIAMETERP)) && !defined(IPDIAMETERP)
|
||||
#define IPDIAMETERP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPEAP) ||defined(_WRS_CONFIG_COMPONENT_USR_IPEAP)) && !defined(IPEAP)
|
||||
#define IPEAP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPFIREWALL) || defined(_WRS_CONFIG_COMPONENT_USR_IPFIREWALL)) && !defined(IPFIREWALL)
|
||||
#define IPFIREWALL
|
||||
#endif
|
||||
|
||||
#if( defined(_WRS_CONFIG_COMPONENT_IPHWCRYPTO) ||defined(_WRS_CONFIG_COMPONENT_USR_IPHWCRYPTO)) && !defined(IPHWCRYPTO)
|
||||
#define IPHWCRYPTO
|
||||
#endif
|
||||
|
||||
#if( defined(_WRS_CONFIG_COMPONENT_IPIKE) || defined(_WRS_CONFIG_COMPONENT_USR_IPIKE)) && !defined(IPIKE)
|
||||
#define IPIKE
|
||||
#endif
|
||||
|
||||
#if( defined(_WRS_CONFIG_COMPONENT_IPIPSEC) || defined(_WRS_CONFIG_COMPONENT_USR_IPIPSEC)) && !defined(IPIPSEC)
|
||||
#define IPIPSEC
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPL2TP) ||defined( _WRS_CONFIG_COMPONENT_USR_IPL2TP) )&& !defined(IPL2TP)
|
||||
#define IPL2TP
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPLITE) ||defined (_WRS_CONFIG_COMPONENT_USR_IPLITE)) && !defined(IPLITE)
|
||||
#define IPLITE
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPMCP) || defined(_WRS_CONFIG_COMPONENT_USR_IPMCP)) && !defined(IPMCP)
|
||||
#define IPMCP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIP) ||defined (_WRS_CONFIG_COMPONENT_USR_IPMIP)) && !defined(IPMIP)
|
||||
#define IPMIP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIP4) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIP4)) && !defined(IPMIP4)
|
||||
#define IPMIP4
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIP6) || defined(_WRS_CONFIG_COMPONENT_USR_IPMIP6)) && !defined(IPMIP6)
|
||||
#define IPMIP6
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIP6HA) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIP6HA)) && !defined(IPMIP6HA)
|
||||
#define IPMIP6HA
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPMIP6MN) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIP6MN)) && !defined(IPMIP6MN)
|
||||
#define IPMIP6MN
|
||||
#endif
|
||||
|
||||
#if(defined(_WRS_CONFIG_COMPONENT_IPMIP6PM) ||defined (_WRS_CONFIG_COMPONENT_USR_IPMIP6PM)) && !defined(IPMIP6PM)
|
||||
#define IPMIP6PM
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIPFA) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIPFA)) && !defined(IPMIPFA)
|
||||
#define IPMIPFA
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIPHA) ||defined (_WRS_CONFIG_COMPONENT_USR_IPMIPHA)) && !defined(IPMIPHA)
|
||||
#define IPMIPHA
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPMIPMN) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIPMN)) && !defined(IPMIPMN)
|
||||
#define IPMIPMN
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMIPPM) ||defined( _WRS_CONFIG_COMPONENT_USR_IPMIPPM)) && !defined(IPMIPPM)
|
||||
#define IPMIPPM
|
||||
#endif
|
||||
|
||||
#if( defined(_WRS_CONFIG_COMPONENT_IPMPLS) ||defined (_WRS_CONFIG_COMPONENT_USR_IPMPLS)) && !defined(IPMPLS)
|
||||
#define IPMPLS
|
||||
#endif
|
||||
|
||||
#if( defined(_WRS_CONFIG_COMPONENT_IPNET) ||defined (_WRS_CONFIG_COMPONENT_USR_IPNET)) && !defined(IPNET)
|
||||
#define IPNET
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPPPP) ||defined( _WRS_CONFIG_COMPONENT_USR_IPPPP)) && !defined(IPPPP)
|
||||
#define IPPPP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPRADIUS) ||defined( _WRS_CONFIG_COMPONENT_USR_IPRADIUS)) && !defined(IPRADIUS)
|
||||
#define IPRADIUS
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPRIP) || defined(_WRS_CONFIG_COMPONENT_USR_IPRIP)) && !defined(IPRIP)
|
||||
#define IPRIP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPRIPNG) ||defined (_WRS_CONFIG_COMPONENT_USR_IPRIPNG)) && !defined(IPRIPNG)
|
||||
#define IPRIPNG
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPROHC) ||defined( _WRS_CONFIG_COMPONENT_USR_IPROHC)) && !defined(IPROHC)
|
||||
#define IPROHC
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPSCTP) ||defined (_WRS_CONFIG_COMPONENT_USR_IPSCTP)) && !defined(IPSCTP)
|
||||
#define IPSCTP
|
||||
#endif
|
||||
|
||||
#if (defined (_WRS_CONFIG_COMPONENT_IPSNTP) ||defined (_WRS_CONFIG_COMPONENT_USR_IPSNTP)) && !defined(IPSNTP)
|
||||
#define IPSNTP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPNTP) || defined(_WRS_CONFIG_COMPONENT_USR_IPNTP)) && !defined(IPNTP)
|
||||
#define IPNTP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPSSH) ||defined (_WRS_CONFIG_COMPONENT_USR_IPSSH)) && !defined(IPSSH)
|
||||
#define IPSSH
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPSSL) ||defined (_WRS_CONFIG_COMPONENT_USR_IPSSL)) && !defined(IPSSL)
|
||||
#define IPSSL
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPTCP) ||defined (_WRS_CONFIG_COMPONENT_USR_IPTCP)) && !defined(IPTCP)
|
||||
#define IPTCP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPWPS) ||defined (_WRS_CONFIG_COMPONENT_USR_IPWPS)) && !defined(IPWPS)
|
||||
#define IPWPS
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPXINC) ||defined( _WRS_CONFIG_COMPONENT_USR_IPXINC)) && !defined(IPXINC)
|
||||
#define IPXINC
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_SECURITY) || defined(_WRS_CONFIG_COMPONENT_USR_SECURITY)) && !defined(SECURITY)
|
||||
#define SECURITY
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_VXCOMPAT) || defined(_WRS_CONFIG_COMPONENT_USR_VXCOMPAT)) && !defined(VXCOMPAT)
|
||||
#define VXCOMPAT
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_VXCOREIP) ||defined (_WRS_CONFIG_COMPONENT_USR_VXCOREIP)) && !defined(VXCOREIP)
|
||||
#define VXCOREIP
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_VXMUX) || defined(_WRS_CONFIG_COMPONENT_USR_VXMUX)) && !defined(VXMUX)
|
||||
#define VXMUX
|
||||
#endif
|
||||
|
||||
#if defined(_WRS_CONFIG_COMPONENT_IPBRIDGE) && !defined(IPBRIDGE)
|
||||
#define IPBRIDGE
|
||||
#endif
|
||||
|
||||
#if (defined(_WRS_CONFIG_COMPONENT_IPMACSEC) || defined(_WRS_CONFIG_COMPONENT_USR_IPMACSEC)) && !defined(IPMACSEC)
|
||||
#define IPMACSEC
|
||||
#endif
|
||||
|
||||
#if (_WRS_CONFIG_COMPONENT_VRRP) && !defined(IPVRRP)
|
||||
#define IPVRRP
|
||||
#endif
|
||||
|
||||
#endif /* _WRS_KERNEL && !IPBASIC */
|
||||
|
||||
#if (defined(_WRS_CONFIG_FEATURE_IPNET_INET6) || defined(_WRS_CONFIG_FEATURE_IPNET_USR_INET6) || \
|
||||
defined(_WRS_CONFIG_FEATURE_IPNET_INET6_ONLY) || defined(_WRS_CONFIG_FEATURE_IPNET_USR_INET6_ONLY) ||\
|
||||
defined(_WRS_CONFIG_FEATURE_IPLITE_INET6)) && !defined(IPCOM_USE_INET6)
|
||||
#define IPCOM_USE_INET6
|
||||
#endif
|
||||
|
||||
#if defined(_WRS_CONFIG_FEATURE_IPNET_INET6_ONLY) && !defined(IPCOM_EXCLUDE_INET)
|
||||
#define IPCOM_EXCLUDE_INET
|
||||
#endif
|
||||
|
||||
#if !defined(_WRS_CONFIG_BUILD_MODE_speed) && !defined(_WRS_CONFIG_BUILD_MODE_speed_d) && !defined(IP_DEBUG) && !defined(IPLITE)
|
||||
#define IP_DEBUG
|
||||
#endif
|
||||
|
||||
/* This definition is deprecated, please use IPCOM_VXWORKS_USE_MSP */
|
||||
#if _WRS_CONFIG_MSP_KERNEL && !defined(IPNET_MSP_DISTRIBUTION)
|
||||
#define IPNET_MSP_DISTRIBUTION
|
||||
#endif
|
||||
|
||||
#if _WRS_CONFIG_MSP_KERNEL && !defined(IPCOM_VXWORKS_USE_MSP)
|
||||
#define IPCOM_VXWORKS_USE_MSP
|
||||
#endif
|
||||
|
||||
#if defined(_VSB_CONFIG_FILE) && !defined(IP_WB_BUILD)
|
||||
#define IP_WB_BUILD
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_PAUTOCONF_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pconfig.h,v $ $Revision: 1.139.10.13 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/config/ipcom_pconfig.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2018-09-12 23:34:42 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PCONFIG_H
|
||||
#define IPCOM_PCONFIG_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 67
|
||||
#include <vsbConfig.h> /* Include the VxWorks VSB configuration */
|
||||
#include <ipcom_pautoconf.h> /* Translate VSB configuration macros */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SMP
|
||||
*===========================================================================
|
||||
* Define IPCOM_USE_SMP if IPCOM is built against a SMP version of VxWorks.
|
||||
*/
|
||||
#if defined(_WRS_CONFIG_SMP) || defined(_WRS_VX_SMP)
|
||||
# define IPCOM_USE_SMP
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Port services
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/* Valid values: IPCOM_FILE_IPCOM | IPCOM_FILE_NATIVE | IPCOM_FILE_NONE */
|
||||
#ifndef IPCOM_USE_FILE
|
||||
# if defined(IPBASIC) || !defined(_WRS_KERNEL)
|
||||
# define IPCOM_USE_FILE IPCOM_FILE_NONE
|
||||
# elif defined(_WRS_CONFIG_LP64)
|
||||
# define IPCOM_USE_FILE IPCOM_FILE_NATIVE
|
||||
# else
|
||||
# define IPCOM_USE_FILE IPCOM_FILE_NATIVE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Valid values: IPCOM_SHELL_IPCOM | IPCOM_SHELL_NATIVE | IPCOM_SHELL_NONE */
|
||||
/* IPCOM_SHELL_NATIVE only supported on VxWorks-6.5 or later */
|
||||
#ifndef IPCOM_USE_SHELL
|
||||
# if defined(IPBASIC) || !defined(_WRS_KERNEL)
|
||||
# define IPCOM_USE_SHELL IPCOM_SHELL_NONE
|
||||
# else
|
||||
# if IP_PORT_VXWORKS >= 65
|
||||
# define IPCOM_USE_SHELL IPCOM_SHELL_NATIVE
|
||||
|
||||
# if defined(_WRS_CONFIG_NO_IP)
|
||||
# define IPCOM_USE_SHELL IPCOM_SHELL_NONE
|
||||
# endif
|
||||
|
||||
# else
|
||||
# define IPCOM_USE_SHELL IPCOM_SHELL_IPCOM
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* IPCOM_USE_SOCK automatically set in ipcom_config.h */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_NATIVE_SOCK_API
|
||||
*===========================================================================
|
||||
* When this define is set, the ipcom_socket* API is mapped by the
|
||||
* pre-processor directly to the VxWorks sockLib.
|
||||
*/
|
||||
#define IPCOM_USE_NATIVE_SOCK_API
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SOCK_COMPAT
|
||||
*===========================================================================
|
||||
* Set this define if you want to register IPNET/IPLITE as a socket backend.
|
||||
* This makes Interpeak stacks binary compatible with windnet
|
||||
* (vxworks "default" stack), regarding basic socket calls.
|
||||
* This define must not be set when using the windnet stack.
|
||||
*/
|
||||
#if defined(IPNET) || defined(IPLITE)
|
||||
#define IPCOM_USE_SOCK_COMPAT
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPNET_SO_WAKEUP_HOOK
|
||||
*===========================================================================
|
||||
* Set this define if you want to use legacy sowakeupHook.
|
||||
*/
|
||||
#if defined(IP_PORT_VXWORKS) && defined(IPCOM_USE_SOCK_COMPAT)
|
||||
/* #define IPNET_SO_WAKEUP_HOOK */
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_RAM_DISK
|
||||
*===========================================================================
|
||||
* Controls whether the ipcom initialization function should define and set
|
||||
* up a vxWorks RAM disk. This can thus only be used with
|
||||
* IPCOM_USE_FILE == IPCOM_FILE_NATIVE
|
||||
* and shall not be confused with IPCOM_FILE_IPCOM, which is the IPCOM RAM
|
||||
* file system.
|
||||
*/
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE
|
||||
#define IPCOM_USE_RAM_DISK
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_RAM_DISK_xx
|
||||
*===========================================================================
|
||||
* Ram disk block size and number of blocks.
|
||||
*/
|
||||
#ifdef IPCOM_USE_RAM_DISK
|
||||
|
||||
/* Block size */
|
||||
#ifndef IPCOM_RAM_DISK_BLOCK_SIZE
|
||||
# define IPCOM_RAM_DISK_BLOCK_SIZE 512
|
||||
#endif
|
||||
|
||||
/* Number of blocks */
|
||||
#ifndef IPCOM_RAM_DISK_NO_BLOCK
|
||||
# ifdef IPSSH
|
||||
# define IPCOM_RAM_DISK_NO_BLOCK 1024
|
||||
# else
|
||||
# define IPCOM_RAM_DISK_NO_BLOCK 64
|
||||
# endif
|
||||
#endif /* IPCOM_RAM_DISK_NO_BLOCK */
|
||||
|
||||
#endif /* #ifdef IPCOM_USE_RAM_DISK */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_FILE_NATIVE_ROOT
|
||||
*===========================================================================
|
||||
* File system root when using native file system.
|
||||
*/
|
||||
#define IPCOM_FILE_NATIVE_ROOT "/ram/"
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_HW_CHECKSUM
|
||||
*===========================================================================
|
||||
* Define if support for checksumming in hardware should be enabled.
|
||||
* It is safe to define this even if the target hardware does not support
|
||||
* checksumming in hardware.
|
||||
*
|
||||
*/
|
||||
#define IPCOM_USE_HW_CHECKSUM
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_HW_VLAN_TAGGING
|
||||
*===========================================================================
|
||||
* Define if hardware supports VLAN tag insertion and stripping.
|
||||
* For driver that supports stripping VLAN tag from the received frame,
|
||||
* the VLAN tag will be stored in m_blk->mBlkPktHdr.vlan (in host-byte
|
||||
* order) and an untagged frame will be sent to the stack. Therefore, this
|
||||
* define must be enabled by default so that the stack can inter-operate
|
||||
* correctly with those vlan-capable driver. It is safe to define this even
|
||||
* if the driver does not support vlan offloading. Hardware vlan capability
|
||||
* will be determined when the interface is attached to the MUX.
|
||||
*/
|
||||
#ifdef IPNET
|
||||
#ifdef IPNET_MSP_DISTRIBUTION
|
||||
#define IPCOM_USE_HW_VLAN_TAGGING
|
||||
#endif /* IPNET_MSP_DISTRIBUTION */
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_HW_CAPS
|
||||
*===========================================================================
|
||||
* Define if hardware capabilities should be considered.
|
||||
* This is currently defined if hardware checksumming and/or vlan offloading
|
||||
* are enabled.
|
||||
*/
|
||||
#if defined(IPCOM_USE_HW_CHECKSUM) || defined(IPCOM_USE_HW_VLAN_TAGGING)
|
||||
#define IPCOM_USE_HW_CAPS
|
||||
#endif /* IPCOM_USE_HW_CHECKSUM || IPCOM_USE_HW_VLAN_TAGGING */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_JOB_QUEUE
|
||||
*===========================================================================
|
||||
* Define to make all stack processing be done by as a VxWorks netJob.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 67
|
||||
#define IPCOM_USE_JOB_QUEUE
|
||||
#endif
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPFORWARDER
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_FORWARDER_NAE
|
||||
* IPCOM_FORWARDER_AMP
|
||||
* IPCOM_FORWARDER_SMP
|
||||
*===========================================================================
|
||||
* IPCOM_FORWARDER_NAE
|
||||
* Define to make a stack for an NAE (Network Acceleration Engine)
|
||||
* IPCOM_FORWARDER_AMP
|
||||
* Define to make a stack for an AMP forwarder
|
||||
* IPCOM_FORWARDER_SMP
|
||||
* Define to make a stack for an SMP forwarder
|
||||
#define IPCOM_FORWARDER_AMP
|
||||
#define IPCOM_FORWARDER_NAE
|
||||
#define IPCOM_FORWARDER_SMP
|
||||
*/
|
||||
|
||||
#if defined(_WRS_CONFIG_IPCOM_FORWARDER_AMP)
|
||||
# define IPCOM_FORWARDER_AMP
|
||||
#elif defined(_WRS_CONFIG_IPCOM_FORWARDER_NAE)
|
||||
# define IPCOM_FORWARDER_NAE
|
||||
|
||||
#ifdef _WRS_MIPS_N32_ABI
|
||||
#define IPCOM_USE_STANDARD_MIPC
|
||||
#define IPCOM_MIPC_PRINTF
|
||||
#define IPNET_USE_SHOW
|
||||
#endif
|
||||
|
||||
#elif defined(_WRS_CONFIG_IPCOM_FORWARDER_SMP)
|
||||
# define IPCOM_FORWARDER_SMP
|
||||
#else
|
||||
# error Missing forwarder selection, must be one of AMP, NAE or SMP
|
||||
#endif
|
||||
|
||||
#ifdef _WRS_CONFIG_MAX_NAES
|
||||
#define IPCOM_MAX_NAE _WRS_CONFIG_MAX_NAES
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_FORWARDER_NAE
|
||||
#ifdef IPCOM_USE_JOB_QUEUE
|
||||
#undef IPCOM_USE_JOB_QUEUE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Defines for the P4080 port */
|
||||
#define IPCOM_USE_P4080_ORP /* Enable Order Restoration */
|
||||
#define IPCOM_USE_MANY_INPUT_FQ /* Spread traffic over multiple queues */
|
||||
/* */
|
||||
|
||||
#endif /* _WRS_CONFIG_COMPONENT_IPFORWARDER */
|
||||
|
||||
#if defined(_WRS_MIPS_N32_ABI) && \
|
||||
(defined(_WRS_CONFIG_COMPONENT_IFPROXY) || \
|
||||
defined(_WRS_CONFIG_COMPONENT_IPFORWARDER))
|
||||
#define IPCOM_USE_APPENDED_FWTAG
|
||||
#define IPCOM_USE_2BYTE_ALIGN_PKT
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPFORWARDER_IPSEC
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_FORWARDER_IPSEC
|
||||
*===========================================================================
|
||||
* Define to enable the IP forwarder IPsec feature
|
||||
*
|
||||
#define IPCOM_USE_FORWARDER_IPSEC
|
||||
*/
|
||||
#ifndef IPBASIC
|
||||
#define IPCOM_USE_FORWARDER_IPSEC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SVCONFIG_CMD
|
||||
*===========================================================================
|
||||
* Define to compile the svconfig command.
|
||||
* The svconfig command is used by the Network Acceleration Platform (NAP) Management OS
|
||||
* to configure VLAN stacking.
|
||||
#define IPCOM_SVCONFIG_CMD
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_VXSEM_SCALABLE
|
||||
*===========================================================================
|
||||
* Set IPCOM_USE_VXSEM_SCALABLE if you want ipcom to use scalable vxWorks
|
||||
* semaphores and mutexes.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 67 && defined (IPCOM_USE_SMP) && !defined (_WRS_CONFIG_DETERMINISTIC)
|
||||
#define IPCOM_USE_VXSEM_SCALABLE
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_VXSEM_INLINE
|
||||
*===========================================================================
|
||||
* Set IPCOM_USE_VXSEM_INLINE if you want ipcom to use inline vxWorks
|
||||
* semaphores and mutexes. This option is disabled by default since it
|
||||
* increases the text segment size by about 7kb for diab builds. This
|
||||
* option is also incompatible with IPCOM_USE_VXSEM_SCALABLE.
|
||||
*/
|
||||
#if 0 && IP_PORT_VXWORKS >= 67 && defined (IPCOM_USE_SMP) && \
|
||||
!defined (IPCOM_USE_VXSEM_SCALABLE)
|
||||
#define IPCOM_USE_VXSEM_INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VXSEM_MUTEX_OPTS
|
||||
*===========================================================================
|
||||
* If scalable or inline VxWorks semaphores and mutexes are used, the inline
|
||||
* options used with the mutexes need to be configured. The default choice
|
||||
* below does not provide priority inheritance (SEM_INVERSION_SAFE), and also
|
||||
* omits object ID validation, some error checking, and system viewer
|
||||
* instrumentation. SEM_DELETE_SAFE is however enabled to allow tasks to be
|
||||
* asynchronously killed while doing stack calls.
|
||||
*
|
||||
*/
|
||||
#if defined (IPCOM_USE_VXSEM_INLINE) || defined (IPCOM_USE_VXSEM_SCALABLE)
|
||||
#define IPCOM_VXSEM_MUTEX_OPTS \
|
||||
(SEM_DELETE_SAFE | \
|
||||
SEM_Q_PRIORITY | \
|
||||
SEM_NO_ID_VALIDATE | \
|
||||
SEM_NO_ERROR_CHECK | \
|
||||
SEM_NO_SYSTEM_VIEWER | \
|
||||
SEM_NO_EVENT_SEND)
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SPINLOCK_ISR_ND
|
||||
*===========================================================================
|
||||
* Set IPCOM_USE_SPINLOCK_ISR_ND if you want ipcom to use
|
||||
* nondeterministic ISR spinlocks. These spinlocks are typically
|
||||
* faster than the standard ISR spinlocks, but do not guarantee fair,
|
||||
* deterministic access to a lock in the presence of strong
|
||||
* contention.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 67 && !defined (_WRS_CONFIG_DETERMINISTIC) && defined(IPCOM_USE_SMP)
|
||||
#define IPCOM_USE_SPINLOCK_ISR_ND
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SPINLOCK_BUSY_PERSIST
|
||||
*===========================================================================
|
||||
* Due to current limitations on which VxWorks kernel functions can be called
|
||||
* while holding a VxWorks spinlock, and due to other performance factors,
|
||||
* in the SMP build 'Ipcom_spinlock' spinlocks are presently implemented
|
||||
* based upon an atomic variable and a VxWorks binary semaphore. This
|
||||
* implementation is likely to change in a future VxWorks release.
|
||||
*
|
||||
* Note that neither task preemption nor interrupts are locked during the
|
||||
* interval when a task either owns or attempts to acquire an Ipcom_spinlock.
|
||||
*
|
||||
* Define IPCOM_SPINLOCK_BUSY_PERSIST if you want ipcom_spinlock_lock() to
|
||||
* busy-wait for a bit when the spinlock is not immediately available,
|
||||
* before giving up and taking the VxWorks semaphore underlying
|
||||
* the 'Ipcom_spinlock' in the SMP build. This improves stack performance
|
||||
* in most SMP scenarios.
|
||||
*
|
||||
* There is, however, a potential case in which the busy-wait choice will
|
||||
* hurt performance. If the task owning the 'spinlock' is preempted by another
|
||||
* task on the same CPU that tries to take the same spinlock, the busy-wait
|
||||
* done by the new taker degrades performance (although it does not cause
|
||||
* full deadlock since the number of busy-wait loops is bounded).
|
||||
*
|
||||
* When IPCOM_SPINLOCK_BUSY_PERSIST is defined, its value is the number
|
||||
* of busy wait loops for which the caller of ipcom_spinlock_lock()
|
||||
* will spin when the spinlock is not available, before giving up and
|
||||
* taking the semaphore. See ipcom_spinlock.c for the detailed algorithm.
|
||||
*
|
||||
* When IPCOM_SPINLOCK_BUSY_PERSIST is not defined, busy waiting is
|
||||
* not done.
|
||||
*
|
||||
* This macro does not affect the uniprocessor build.
|
||||
*/
|
||||
#define IPCOM_SPINLOCK_BUSY_PERSIST (1024)
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VXWORKS_STATS
|
||||
*===========================================================================
|
||||
* Controls whether statistic collection for the vxWorks ipcom port shall be
|
||||
* compiled in.
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
#define IPCOM_VXWORKS_STATS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_DRV_ETH_STATS
|
||||
*===========================================================================
|
||||
* Description: Enable Ethernet driver statistics (drv_stats shell command)
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#if defined(IP_DEBUG) && (defined(IPNET) || defined(IPLITE))
|
||||
#define IPCOM_DRV_ETH_STATS
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_HOST_FROM_LOCALTBL
|
||||
*===========================================================================
|
||||
* This macro controles whether host info is to be retrieved from the static
|
||||
* host database. If IPDNSC is defined, host info is to be searched in the
|
||||
* local host database before calling into IPDNSC.
|
||||
*/
|
||||
#define IPCOM_HOST_FROM_LOCALTBL
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Stack sizes
|
||||
*===========================================================================
|
||||
* The stack size is defined as an Ip_u16. This means that the stack
|
||||
* definitions below must be updated with caution. Hence the max value for
|
||||
* IPCOM_PROC_STACK_MAX is currently 21845 with the IPCOM_STACK_ADJUST macro
|
||||
* has been accounted for. IPCOM_STACK_ADJUST can give a times 3 multiplication,
|
||||
* and 21845*3 = 65535.
|
||||
*/
|
||||
#if !defined(IPCOM_STACK_ADJUST)
|
||||
# if !defined(CPU)
|
||||
# define IPCOM_STACK_ADJUST(x) x /* User mode builds--stacksize never used */
|
||||
# elif IP_PORT_VXWORKS < 60
|
||||
# define IPCOM_STACK_ADJUST(x) x /* No need for big stacks in 5.x */
|
||||
# elif IP_PORT_VXWORKS < 66
|
||||
# if _WRS_MIPS_64BIT_CPU
|
||||
# define IPCOM_STACK_ADJUST(x) (x * 2) /* 64-bit CPUs get 2x stacks */
|
||||
# else
|
||||
# define IPCOM_STACK_ADJUST(x) x /* Other CPUs get 1x */
|
||||
# endif
|
||||
# else
|
||||
# if _WRS_MIPS_64BIT_CPU || defined(_WRS_CONFIG_LP64)
|
||||
# define IPCOM_STACK_ADJUST(x) (x * 3) /* 64-bit on 6.6 and above get 3x */
|
||||
# else
|
||||
# define IPCOM_STACK_ADJUST(x) ((x * 3) / 2) /* Other CPUs on 6.6 and above get 1.5x */
|
||||
# endif
|
||||
# endif /* !defined(CPU) */
|
||||
#endif /* !defined(IPCOM_STACK_ADJUST) */
|
||||
|
||||
#define IPCOM_PROC_STACK_MIN IPCOM_STACK_ADJUST(1024)
|
||||
#define IPCOM_PROC_STACK_SMALL IPCOM_STACK_ADJUST(2048)
|
||||
#define IPCOM_PROC_STACK_DEFAULT IPCOM_STACK_ADJUST(4096)
|
||||
#define IPCOM_PROC_STACK_LARGE IPCOM_STACK_ADJUST(8192)
|
||||
#define IPCOM_PROC_STACK_MAX IPCOM_STACK_ADJUST(21845)
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Process priorities
|
||||
*===========================================================================
|
||||
* IPCOM has seven process priorities where 7 is highest and 1 lowest.
|
||||
* Define the corresponding RTOS priorities below:
|
||||
* VxWorks 6.x uses different priorities for the nettask, compared to VxWorks
|
||||
* 5.x. The best network performance is obtained if Interpeak task priorities
|
||||
* are synchronized with the VxWorks priorities.
|
||||
* Please note, changing task priority is not officially supported on vxworks
|
||||
* 6.x, there may be undesired consequences, such as poor performance.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 60
|
||||
#ifndef IPCOM_PROC_PRIO_1
|
||||
#define IPCOM_PROC_PRIO_1 254 /* lowest */
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_2
|
||||
#define IPCOM_PROC_PRIO_2 90
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_3
|
||||
#define IPCOM_PROC_PRIO_3 80
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_4
|
||||
#define IPCOM_PROC_PRIO_4 50
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_5
|
||||
#define IPCOM_PROC_PRIO_5 40
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_6
|
||||
#define IPCOM_PROC_PRIO_6 30
|
||||
#endif
|
||||
#ifndef IPCOM_PROC_PRIO_7
|
||||
#define IPCOM_PROC_PRIO_7 20 /* highest */
|
||||
#endif
|
||||
#else
|
||||
/* VxWorks 5.4 and 5.5 */
|
||||
#define IPCOM_PROC_PRIO_1 254 /* lowest */
|
||||
#define IPCOM_PROC_PRIO_2 90
|
||||
#define IPCOM_PROC_PRIO_3 80
|
||||
#define IPCOM_PROC_PRIO_4 70
|
||||
#define IPCOM_PROC_PRIO_5 60
|
||||
#define IPCOM_PROC_PRIO_6 50
|
||||
#define IPCOM_PROC_PRIO_7 40 /* highest */
|
||||
#endif
|
||||
|
||||
#define IPCOM_PROC_PRIO_BACKGROUND 255 /* EGD daemon (background proc) */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPC
|
||||
*===========================================================================
|
||||
* IPSSH process names can be up to 51 characters.
|
||||
*/
|
||||
#define IPCOM_IPC_MAX_NAME 64
|
||||
|
||||
/*
|
||||
* *===========================================================================
|
||||
* IPCOM_CCIVALIDATE_TEST_
|
||||
* ===========================================================================
|
||||
* Includes the command to include cci library validation tests thru the
|
||||
* ipcom shell.
|
||||
* #define IPCOM_CCIVALIDATE_TEST
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* *===========================================================================
|
||||
* IPCOM_CCIVALIDATE_TEST_
|
||||
* ===========================================================================
|
||||
* Includes the command to add cci provider performance benchmark cmd to the
|
||||
* ipcom shell.
|
||||
* #define IPCOM_CCIPERFORMANCE_TEST
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 SYSTEM VIEWER
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_WV_INSTRUMENTATION
|
||||
*===========================================================================
|
||||
* To build the stack without system viewer instrumentation, use OPT=-fr or
|
||||
* OPT=-inet6_fr on the Make command line; or add -D_FREE_VERSION to
|
||||
* the compiler flags; or undefine IPCOM_WV_INSTRUMENTATION below.
|
||||
*
|
||||
* For library builds we don't define INCLUDE_WINDVIEW and INCLUDE_WVNETD.
|
||||
* Those will be defined in VIP projects or BSP config files.
|
||||
*/
|
||||
|
||||
#if IP_PORT_VXWORKS >= 65
|
||||
# ifndef _WRS_CONFIG_SV_INSTRUMENTATION
|
||||
# ifndef _FREE_VERSION
|
||||
# define _FREE_VERSION
|
||||
# endif
|
||||
# endif
|
||||
# ifndef _FREE_VERSION
|
||||
# define IPCOM_WV_INSTRUMENTATION
|
||||
# endif
|
||||
# ifdef IPCOM_WV_INSTRUMENTATION
|
||||
# if defined(WRS_IPNET) || defined(IPBSPBUILD)
|
||||
# ifndef INCLUDE_WVNETD
|
||||
# define INCLUDE_WVNETD
|
||||
# endif
|
||||
# endif /* defined(WRS_IPNET) || defined(IPBSPBUILD) */
|
||||
# endif /* #ifdef IPCOM_WV_INSTRUMENTATION */
|
||||
#endif /* IP_PORT_VXWORKS >= 65 */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_WV_INSTRUMENTATION_TEST
|
||||
*===========================================================================
|
||||
* Define to include system viewer test command.
|
||||
#define IPCOM_WV_INSTRUMENTATION_TEST
|
||||
*/
|
||||
|
||||
#if defined(IPCOM_WV_INSTRUMENTATION_TEST) && !defined(IPCOM_FILE_NATIVE)
|
||||
#error 'IPCOM_WV_INSTRUMENTATION_TEST requires native file system'
|
||||
#endif
|
||||
|
||||
|
||||
/* Increase RAM disk size */
|
||||
#if defined(IPCOM_WV_INSTRUMENTATION_TEST) && defined(IPCOM_USE_RAM_DISK)
|
||||
# ifdef IPCOM_RAM_DISK_NO_BLOCK
|
||||
# undef IPCOM_RAM_DISK_NO_BLOCK
|
||||
# endif
|
||||
# define IPCOM_RAM_DISK_NO_BLOCK 1024
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 IPCOM DRIVER CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VXWORKS_DRV_NULLPOOL
|
||||
*===========================================================================
|
||||
* Support use of nullpool.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 65
|
||||
#define IPCOM_VXWORKS_DRV_NULLPOOL
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_MUX2
|
||||
*===========================================================================
|
||||
* Use MUX2 interface.
|
||||
*/
|
||||
#if IP_PORT_VXWORKS >= 67
|
||||
#define IPCOM_USE_MUX2
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VXWORKS_DRV_ETH_PROMISCUOUS
|
||||
*===========================================================================
|
||||
* Set driver in promiscuous mode (for Ethernet chips who have problems with
|
||||
* programming multicast groups).
|
||||
#define IPCOM_VXWORKS_DRV_ETH_PROMISCUOUS
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_SYSVAR_EXT
|
||||
*===========================================================================
|
||||
* Used to set sets an array of values for interface-specific parameters.
|
||||
*/
|
||||
#define IPCOM_USE_SYSVAR_EXT
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_USE_VXSHELL_CMD
|
||||
*===========================================================================
|
||||
* Include vxshell command in IPCOM shell.
|
||||
*/
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM && IP_PORT_VXWORKS >= 65
|
||||
#define IPCOM_USE_VXSHELL_CMD
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_VXWORKS_USE_MUX_L2
|
||||
*===========================================================================
|
||||
* Define to enable VxWorks MUX-L2 IEEE 802.1Q VLAN support.
|
||||
*
|
||||
* #define IPCOM_VXWORKS_USE_MUX_L2
|
||||
*/
|
||||
|
||||
#ifdef REMOVE_THIS_IFDEF_WHEN_SUPPORTING_IPBRIDGE
|
||||
/*
|
||||
*===========================================================================
|
||||
* INCLUDE_IPFIREWALL_SUPPORT
|
||||
*===========================================================================
|
||||
* Define to enable Firewall support in the bridge.
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_COMPONENT_IPFIREWALL_SUPPORT
|
||||
#define INCLUDE_IPFIREWALL_SUPPORT
|
||||
#define IPCOM_STORE_PHYSICAL_IF
|
||||
#define IPFIREWALL_PHYSICAL_IF_SUPPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* INCLUDE_IPBRIDGE_VLAN_SUPPORT
|
||||
*===========================================================================
|
||||
* Define to enable 802.1Q Bridge support in the bridge.
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_COMPONENT_BRIDGE_VLAN_SUPPORT
|
||||
#define INCLUDE_IPBRIDGE_VLAN_SUPPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPBRIDGE_FILTERING_DB_SIZE
|
||||
*===========================================================================
|
||||
* Define to specify the maximum size of the bridge filtering database.
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_BRIDGE_STATS
|
||||
#define IPBRIDGE_USE_STATS
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPBRIDGE_FILTERING_DB_SIZE
|
||||
*===========================================================================
|
||||
* Define to specify the maximum size of the bridge filtering database.
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_BRIDGE_FILTERING_DATABASE_SIZE
|
||||
#define IPBRIDGE_FILTERING_DB_SIZE _WRS_CONFIG_BRIDGE_FILTERING_DATABASE_SIZE
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPBRIDGE_MAX_PORTS
|
||||
*===========================================================================
|
||||
* Define to specify the maximum number of allowed bridge ports.
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_BRIDGE_MAX_PORTS
|
||||
#define IPBRIDGE_MAX_PORTS _WRS_CONFIG_BRIDGE_MAX_PORTS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_ZEROCOPY
|
||||
*===========================================================================
|
||||
* Include the ZeroCopy API by default to enable it in GPP.
|
||||
*/
|
||||
#ifndef WRS_IPLITE
|
||||
#ifndef IPCOM_ZEROCOPY
|
||||
#define IPCOM_ZEROCOPY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SIMPLE_MEM_SIZE
|
||||
*===========================================================================
|
||||
* Define to specify the size of simple memory
|
||||
*
|
||||
*/
|
||||
#ifdef _WRS_CONFIG_IPCOM_SIMPLE_MEM_SIZE
|
||||
#define IPCOM_SIMPLE_MEM_SIZE _WRS_CONFIG_IPCOM_SIMPLE_MEM_SIZE
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IPCOM_SPINLOCK_USE_MUTEX
|
||||
*===========================================================================
|
||||
* Define to implement ipcom_spinlocks as mutex semaphores with
|
||||
* protection enabled against unbounded priority inversion. Undefine
|
||||
* this macro to use a generally faster atomic test-and-set strategy.
|
||||
* However, this alternate strategy is susceptible to unbounded priority
|
||||
* inversion, and therefore cannot be used in systems requiring
|
||||
* real-time guarantees.
|
||||
*/
|
||||
#define IPCOM_SPINLOCK_USE_MUTEX
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,12 @@
|
||||
IPTARGETS := lib
|
||||
ifneq ($(IPMAKEFILE),)
|
||||
include $(IPMAKEFILE)
|
||||
else
|
||||
include $(IPCOM_ROOT)/Makefile
|
||||
endif
|
||||
include vxworks.mk
|
||||
include $(IPCOM_ROOT)/gmake/ipcom_make.mk
|
||||
|
||||
lib: dirs $(IPLIBFILE)
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_vxworks_config.mk,v $ $Revision: 1.28.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/gmake/ipcom_vxworks_config.mk,v $
|
||||
# $Author: dlkrejsa $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# GENERAL
|
||||
#############################################################################
|
||||
|
||||
# Define target
|
||||
ifneq ($(WR_IPTARGET),)
|
||||
IPTARGET = $(WR_IPTARGET)
|
||||
else
|
||||
IPTARGET = simlinux
|
||||
endif
|
||||
|
||||
# Define VxWorks version
|
||||
#ifneq ($(WR_IPCOM_VERSION),)
|
||||
#IPVER = $(WR_IPCOM_VERSION)
|
||||
#else
|
||||
IPVER = 6_9
|
||||
#endif
|
||||
|
||||
IPINCL_SYM_TBL = yes
|
||||
IP_MAP_FILE = yes
|
||||
|
||||
# Define board
|
||||
ifneq ($(WIND_IPNET),true)
|
||||
ifneq ($(WIND_IPLITE),true)
|
||||
|
||||
ifeq ($(IPTARGET),mips)
|
||||
# Examples: malta4kc_mips32sf, malta4kec_mips32sf, malta4kec_mips32sfle
|
||||
IPBOARD = malta4kc_mips32sf
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),simlinux)
|
||||
IPBOARD = linux
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),simpc)
|
||||
IPBOARD = simpc
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),pentium)
|
||||
IPBOARD = pcPentium3-IP
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),cf)
|
||||
IPBOARD = m54x5evb
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),ppc)
|
||||
IPBOARD = cds85xx
|
||||
IPARCH = powerpc
|
||||
endif
|
||||
|
||||
endif # not WIND_IPLITE
|
||||
endif # not WIND_IPNET
|
||||
|
||||
ifeq ($(IPTARGET),ppc)
|
||||
IPARCH = powerpc
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),arm)
|
||||
IPARCH = arm
|
||||
endif
|
||||
|
||||
ifneq ($(IPBOARD),)
|
||||
IPDEFINE += -DIPBSPBUILD
|
||||
endif
|
||||
|
||||
ifeq ($(IPTARGET),pentium)
|
||||
ifeq ($(_WRS_CONFIG_LP64),y)
|
||||
IPARCH=pentium64
|
||||
else
|
||||
IPARCH=pentium
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_VXWORKS_CONFIG.MK
|
||||
#############################################################################
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_vxworks_make.mk,v $ $Revision: 1.79.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/gmake/ipcom_vxworks_make.mk,v $
|
||||
# $Author: hxie $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# DEFINE
|
||||
#############################################################################
|
||||
|
||||
# Assign IP_PORT_VXWORKS a numerical value to be used in #if (55, 60, etc.)
|
||||
ifneq ($(IPGMAKE),yes)
|
||||
IPDEFINE += -DIP_PORT_VXWORKS=$(subst _,,$(IPVER))
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
# ADD SCTP HW CRC CALC
|
||||
############################################################################
|
||||
|
||||
ifneq ($(OCTEON_ROOT),)
|
||||
IPCFLAGS += -march=octeon
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# ENDIAN
|
||||
#############################################################################
|
||||
|
||||
# Includes the definition of TOOL
|
||||
ifneq ($(IPBOARD),)
|
||||
-include $(WIND_BASE)/target/config/$(IPBOARD)/Makefile
|
||||
|
||||
MACH_EXTRA = $(filter-out ipcom_vxworks.o,$(MACH_EXTRA))
|
||||
endif
|
||||
|
||||
ifeq ($(TGT_DIR),)
|
||||
TGT_DIR = $(WIND_BASE)/target
|
||||
endif
|
||||
|
||||
CC_WARNINGS = $(CC_WARNINGS_LOW)
|
||||
IPCOMPILER = $(TOOL)
|
||||
|
||||
ifneq ($(IPGMAKE),yes)
|
||||
include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE)
|
||||
include $(TGT_DIR)/h/make/defs.default
|
||||
include $(TGT_DIR)/h/make/defs.option
|
||||
include $(TGT_DIR)/h/make/defs.options
|
||||
include $(TGT_DIR)/h/tool/$(TOOL_FAMILY)/make.$(CPU)$(TOOL)
|
||||
endif
|
||||
|
||||
# Set endianness
|
||||
ifeq ($(IPTARGET),ppc)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),cf)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),i386)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),mips)
|
||||
ifeq ($(_WRS_CONFIG_ENDIAN),little)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
else
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
endif
|
||||
ifeq ($(IPTARGET),arm)
|
||||
ifeq ($(_WRS_CONFIG_ENDIAN),big)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
else
|
||||
ifeq ($(_WRS_CONFIG_ENDIAN),be8)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
else
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(IPTARGET),sh)
|
||||
ifeq ($(_WRS_CONFIG_ENDIAN),little)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
else
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
endif
|
||||
ifeq ($(IPTARGET),sparc)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),68k)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),simso)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),simpc)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),pentium)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),simlinux)
|
||||
IPDEFINE += -DIP_LITTLE_ENDIAN
|
||||
endif
|
||||
ifeq ($(IPTARGET),cf)
|
||||
IPDEFINE += -DIP_BIG_ENDIAN
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
#############################################################################
|
||||
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/port/$(IPPORT)/config
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/port/$(IPPORT)/include
|
||||
|
||||
|
||||
#############################################################################
|
||||
# SYMBOL TABLE
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(IPINCL_SYM_TBL),yes)
|
||||
IPEXTRA_DEFINE += -DSTANDALONE_NET
|
||||
IPVXBINARY = vxWorks.st
|
||||
else
|
||||
IPVXBINARY = vxWorks
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPCOM INITIALIZATION
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(findstring IPCOM_CCIPERFORMANCE_TEST,$(IPEXTRACFLAGS)),IPCOM_CCIPERFORMANCE_TEST)
|
||||
IPEXTRA_DEFINE += -DINCLUDE_USER_APPL -DUSER_APPL_INIT='do {extern int ipcom_create(void); ipcom_create(); usrCciInit(); } while(0)'
|
||||
else
|
||||
ifeq ($(findstring IPCOM_CCIVALIDATE_TEST,$(IPEXTRACFLAGS)),IPCOM_CCIVALIDATE_TEST)
|
||||
IPEXTRA_DEFINE += -DINCLUDE_USER_APPL -DUSER_APPL_INIT='do {extern int ipcom_create(void); ipcom_create(); usrCciInit(); } while(0)'
|
||||
else
|
||||
IPEXTRA_DEFINE += -DINCLUDE_USER_APPL -DUSER_APPL_INIT='do {extern int ipcom_create(void); ipcom_create(); } while(0)'
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(findstring IPNET,$(filter-out -DIPNETPERF -DIPNET_MSP_DISTRIBUTION,$(IPDEFINE))),IPNET)
|
||||
IPEXTRA_DEFINE += -DIPNET
|
||||
endif
|
||||
|
||||
ifeq ($(findstring IPLITE,$(IPDEFINE)),IPLITE)
|
||||
IPEXTRA_DEFINE += -DIPLITE
|
||||
endif
|
||||
|
||||
ifeq ($(findstring IPTCP,$(IPDEFINE)),IPTCP)
|
||||
IPEXTRA_DEFINE += -DIPTCP
|
||||
endif
|
||||
|
||||
# Add Windview facilities (requires RAMDISK)
|
||||
ifeq ($(findstring IPCOM_WV_INSTRUMENTATION_TEST,$(IPEXTRACFLAGS)),IPCOM_WV_INSTRUMENTATION_TEST)
|
||||
IPEXTRA_DEFINE += -DINCLUDE_XBD
|
||||
IPEXTRA_DEFINE += -DINCLUDE_XBD_PART_LIB
|
||||
IPEXTRA_DEFINE += -DINCLUDE_XBD_BLK_DEV
|
||||
IPEXTRA_DEFINE += -DINCLUDE_XBD_RAMDRV
|
||||
IPEXTRA_DEFINE += -DINCLUDE_DOSFS_MAIN
|
||||
IPEXTRA_DEFINE += -DINCLUDE_DOSFS_FAT
|
||||
IPEXTRA_DEFINE += -DINCLUDE_DOSFS_DIR_VFAT
|
||||
IPEXTRA_DEFINE += -DINCLUDE_DISK_UTIL
|
||||
IPEXTRA_DEFINE += -DINCLUDE_WVNETD
|
||||
IPEXTRA_DEFINE += -DINCLUDE_WINDVIEW
|
||||
IPEXTRA_DEFINE += -DINCLUDE_WINDVIEW_CLASS
|
||||
IPEXTRA_DEFINE += -DINCLUDE_WVUPLOAD_ALL
|
||||
IPEXTRA_DEFINE += -DINCLUDE_TRIGGERING
|
||||
IPEXTRA_DEFINE += -DINCLUDE_RBUFF
|
||||
IPEXTRA_DEFINE += -DINCLUDE_TIMESTAMP
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SYS_TIMESTAMP
|
||||
endif
|
||||
|
||||
|
||||
|
||||
ifeq ($(findstring IPCOM_CCIPERFORMANCE_TEST,$(IPEXTRACFLAGS)),IPCOM_CCIPERFORMANCE_TEST)
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_COREAPI
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_DEFAULT_PROVIDER
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AES
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AESKW
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AES_CMAC
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_BLOWFISH
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_CAST
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_DES
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_CRC32
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD2
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD5
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_RIP128
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_RIP160
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA1
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA224
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA256
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA384
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA512
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_AESXCBC
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_MD4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_MD5
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_RIP128
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_RIP160
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA1
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA224
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA256
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA384
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA512
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_INTEGER
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_IPSEC_SINGLEPASS
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_NULL
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_PRNG
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_PUBLICKEY_RSA
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_RC4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_RC4TKIP
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_PERFORMANCE
|
||||
IPEXTRA_DEFINE += -DINCLUDE_OBJ_INFO
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_EVENTS
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_EXCHANGE
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_INFO
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_SHOW
|
||||
EXTRA_INCLUDE += -I$(WIND_BASE)/target/config/comps/src/net
|
||||
EXTRA_INCLUDE += -I$(WIND_BASE)/target/h
|
||||
endif
|
||||
|
||||
ifeq ($(findstring IPCOM_CCIVALIDATE_TEST,$(IPEXTRACFLAGS)),IPCOM_CCIVALIDATE_TEST)
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_COREAPI
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_DEFAULT_PROVIDER
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AES
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AESKW
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_AES_CMAC
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_BLOWFISH
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_CAST
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_DES
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_CRC32
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD2
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_MD5
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_RIP128
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_RIP160
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA1
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA224
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA256
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA384
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HASH_SHA512
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_AESXCBC
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_MD4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_MD5
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_RIP128
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_RIP160
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA1
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA224
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA256
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA384
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_HMAC_SHA512
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_INTEGER
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_IPSEC_SINGLEPASS
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_NULL
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_PRNG
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_PUBLICKEY_RSA
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_RC4
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_IMPORT_RC4TKIP
|
||||
IPEXTRA_DEFINE += -DINCLUDE_CCI_VALIDATE
|
||||
IPEXTRA_DEFINE += -DINCLUDE_OBJ_INFO
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_EVENTS
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_EXCHANGE
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_INFO
|
||||
IPEXTRA_DEFINE += -DINCLUDE_SEM_SHOW
|
||||
EXTRA_INCLUDE += -I$(WIND_BASE)/target/config/comps/src/net
|
||||
EXTRA_INCLUDE += -I$(WIND_BASE)/target/h
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# COMPILE
|
||||
#############################################################################
|
||||
|
||||
ifeq ($(TOOL_FAMILY),)
|
||||
ifeq ($(findstring gnu,$(TOOL)),gnu)
|
||||
TOOL_FAMILY = gnu
|
||||
else
|
||||
ifeq ($(findstring diab,$(TOOL)),diab)
|
||||
TOOL_FAMILY = diab
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WIND_IPNET),true)
|
||||
CC_DEFINES += $(OPTION_DEFINE_MACRO)_WRS_LIB_BUILD
|
||||
endif
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
CC_DEFINES += $(OPTION_DEFINE_MACRO)_WRS_LIB_BUILD
|
||||
endif
|
||||
|
||||
IPCC = $(CC)
|
||||
IPCPP = $(IPCC) -E
|
||||
IPAS = $(CC)
|
||||
IPAR = $(AR)
|
||||
IPRANLIB = $(RANLIB)
|
||||
IPLD = $(LD)
|
||||
|
||||
#ifeq ($(IPNGC),yes)
|
||||
#IPCFLAGS += -nostdinc
|
||||
#endif
|
||||
IPCFLAGS += -c $(CFLAGS) $(CC_SDA_FLAGS)
|
||||
IPASFLAGS += -c $(CFLAGS_AS)
|
||||
IPARFLAGS = r
|
||||
IPINCLDFLAGS = -r -nostartfiles -nostdlib
|
||||
|
||||
ifeq ($(IP_MAP_FILE),yes)
|
||||
ifeq ($(IPVER),5_4)
|
||||
IP_MAP_FILE_FLAGS = \"-Wl,-Map $(IPOBJDIR)/mapfile.txt\"
|
||||
else
|
||||
# 5.5 and 6.0 compilers cannot convey linker flags that are longer than one character, output to stdout instead
|
||||
IP_MAP_FILE_FLAGS = -Wl,-X,--print-map,--cref,-Map,$(IPOBJDIR)/mapfile.txt
|
||||
endif # version 5_4
|
||||
endif
|
||||
|
||||
IP_LD_PARTIAL = $(LD_PARTIAL) $(IP_MAP_FILE_FLAGS)
|
||||
|
||||
EXTRA_INCLUDE += $(IPLIBINC)
|
||||
EXTRA_INCLUDE += -I$(IPCOM_ROOT)/port/vxworks/$(IPVER)/update
|
||||
#To get cci.h into ipcom include path for ipcom_cmd_ccivalidate
|
||||
EXTRA_INCLUDE += -I $(WIND_BASE)/target/h/wrn/cci
|
||||
|
||||
IPINCLUDE += -I$(IPCOM_ROOT)/port/vxworks/$(IPVER)/update
|
||||
ADDED_MODULES += $(IPOBJS) $(IPLIBS) $(IPLIBS) $(IPLIBS) $(IPLIBS)
|
||||
|
||||
#ifeq ($(IPNGC),yes)
|
||||
#ADDED_MODULES += -lm
|
||||
#endif
|
||||
|
||||
# Use the "make" command that is put in the path by "wrenv.sh"
|
||||
IPVXMAKE = make
|
||||
ifneq ($(IPBOARD),)
|
||||
IPBSPDIR = $(subst \,/,$(WIND_BASE)/target/config/$(IPBOARD))
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# IPBUILD
|
||||
#############################################################################
|
||||
# IPBUILD = debug | speed | debugspeed | size
|
||||
# The normal build includes -O2 optimization. This optimization flag is
|
||||
# removed for some build types below.
|
||||
|
||||
# General flags
|
||||
ifeq ($(findstring diab,$(TOOL)),diab)
|
||||
IPCFLAGS := $(subst -Xlint,,$(IPCFLAGS))
|
||||
IPCFLAGS += -ei1546 -ei4167 -ei4513 -ei4188 -ei4550 -Xdialect-c99
|
||||
else
|
||||
IPCFLAGS := $(subst -fvolatile,,$(IPCFLAGS))
|
||||
ifneq ($(IPVER),5_4)
|
||||
IPCFLAGS += -fno-strict-aliasing
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(IPBUILD),debug)
|
||||
IPCFLAGS += -g
|
||||
ifeq ($(findstring diab,$(TOOL)),diab)
|
||||
IPCFLAGS := $(subst -XO,,$(IPCFLAGS))
|
||||
else
|
||||
IPCFLAGS := $(subst -O2,,$(IPCFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(IPBUILD),debugspeed)
|
||||
IPCFLAGS += -g
|
||||
endif
|
||||
|
||||
ifeq ($(IPBUILD),speed)
|
||||
ifneq ($(findstring diab,$(TOOL)),diab)
|
||||
IPCFLAGS := $(subst -fvolatile,,$(IPCFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
# The vxWorks 5.4 compiler does not support -Os
|
||||
ifeq ($(IPBUILD),size)
|
||||
ifneq ($(IPVER),5_4)
|
||||
IPCFLAGS += -Os
|
||||
IPCFLAGS = $(subst -O2,,$(IPCFLAGS))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(IPGENDEPEND),yes)
|
||||
IPCFLAGS := $(IPCFLAGS) $(OPTION_DEPEND_GEN_D)
|
||||
IPASFLAGS := $(IPASFLAGS) $(OPTION_DEPEND_GEN_D)
|
||||
|
||||
IPOBJS_NODEP = $(foreach file, $(IPNODEPENDOBJS), $(IPOBJDIR)/$(file))
|
||||
|
||||
IPDEP_OBJS = $(filter-out $(IPOBJS_NODEP), $(IPLIBOBJS))
|
||||
|
||||
IPEXISTING_OBJS = $(foreach obj, $(IPDEP_OBJS), $(wildcard $(obj)))
|
||||
|
||||
IPDEP_FILES = $(filter %.d , $(IPEXISTING_OBJS:.o=.d))
|
||||
|
||||
IPEXISTING_DEP_FILES = $(foreach obj, $(IPDEP_FILES), $(wildcard $(obj)))
|
||||
|
||||
IPMISSING_DEP = $(filter-out $(IPEXISTING_DEP_FILES), $(IPDEP_FILES))
|
||||
|
||||
ifneq ($(strip $(IPMISSING_DEP)),)
|
||||
$(warning warning: missing dependency files $(IPMISSING_DEP))
|
||||
$(warning warning: run make depend to regenerate)
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(IPEXISTING_DEP_FILES)),)
|
||||
include $(IPEXISTING_DEP_FILES)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PORT USAGE
|
||||
#############################################################################
|
||||
|
||||
pusage:
|
||||
@$(IPECHO) "Port configuration:"
|
||||
@$(IPECHO) " WIND_BASE = $(WIND_BASE)"
|
||||
@$(IPECHO) " IPBOARD = $(IPBOARD)"
|
||||
@$(IPECHO) " IPINCL_SYM_TBL = $(IPINCL_SYM_TBL)"
|
||||
@$(IPECHO) " EXECUTABLE FILE = $(WIND_BASE)/target/config/$(IPBOARD)/$(IPVXBINARY)"
|
||||
|
||||
|
||||
#############################################################################
|
||||
# PORT CLEAN
|
||||
#############################################################################
|
||||
|
||||
pcleanobj:
|
||||
|
||||
ifneq ($(IPBOARD),)
|
||||
pcleanall:
|
||||
$(IPVXMAKE) -C $(IPBSPDIR) -o depend.$(BSP_NAME) clean
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# ALL
|
||||
#############################################################################
|
||||
|
||||
ifneq ($(IPSMP),)
|
||||
# Configure SMP make switches for BSP builds
|
||||
IPSMP_SWITCHES = VXBUILD=SMP
|
||||
ifeq ($(IPGMAKE),yes)
|
||||
IPCFLAGS += -D_WRS_VX_SMP -D_WRS_CONFIG_SMP
|
||||
endif
|
||||
else
|
||||
IPSMP_SWITCHES =
|
||||
endif
|
||||
|
||||
.PHONY: vxworks all
|
||||
|
||||
ifneq ($(IPBOARD),)
|
||||
vxworks:
|
||||
ifneq ($(IP_SKIP_BSP_CLEAN),yes)
|
||||
$(IPVXMAKE) -C $(IPBSPDIR) -o depend.$(BSP_NAME) clean
|
||||
endif
|
||||
$(IPVXMAKE) -C $(IPBSPDIR) $(IPSMP_SWITCHES) \
|
||||
EXTRA_INCLUDE="$(EXTRA_INCLUDE)" EXTRA_DEFINE="$(EXTRA_DEFINE) $(IPEXTRA_DEFINE)" \
|
||||
ADDED_MODULES="$(ADDED_MODULES)" LD_PARTIAL="$(IP_LD_PARTIAL)" IPOBJDIR="$(IPOBJDIR)" \
|
||||
-o depend.$(BSP_NAME) $(IPVXBINARY)
|
||||
endif
|
||||
|
||||
ifneq ($(IPBOARD),)
|
||||
all: liball objall vxworks
|
||||
else
|
||||
all: liball objall
|
||||
endif
|
||||
|
||||
.PHONY: depend.$(BSP_NAME)
|
||||
|
||||
depend.$(BSP_NAME):
|
||||
@$(ECHO) ""
|
||||
|
||||
|
||||
#############################################################################
|
||||
# END OF IPCOM_VXWORKS_MAKE.MK
|
||||
#############################################################################
|
||||
@@ -0,0 +1,113 @@
|
||||
#############################################################################
|
||||
# INTERPEAK MAKEFILE
|
||||
#
|
||||
# Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: vxworks.mk,v $ $Revision: 1.26.10.1 $
|
||||
# $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/gmake/vxworks.mk,v $
|
||||
# $Author: svc-cmnet $
|
||||
# $State: Exp $ $Locker: $
|
||||
#
|
||||
# INTERPEAK_COPYRIGHT_STRING
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
# PRODUCT
|
||||
###########################################################################
|
||||
|
||||
IPPROD ?= ipcom_vxworks
|
||||
include $(IPCOM_ROOT)/port/gmake/ipcom_port.mk
|
||||
|
||||
|
||||
#############################################################################
|
||||
# INCLUDE
|
||||
#############################################################################
|
||||
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/config/$(IPBOARD)
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/config/all
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/h
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/h
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/h/wrn/coreip
|
||||
IPLIBINCLUDE += -I$(WIND_BASE)/target/src/config
|
||||
|
||||
ifneq ($(CCK_ROOT),)
|
||||
IPLIBINCLUDE += -I$(CCK_ROOT)/external_interfaces/api
|
||||
endif
|
||||
|
||||
ifneq ($(BSPNAME),)
|
||||
-include $(WIND_BASE)/target/config/$(BSPNAME)/sdk_include.mk
|
||||
IPLIBINCLUDE += $(SDK_INCLUDE)
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# OBJECTS
|
||||
#############################################################################
|
||||
|
||||
IPLIBOBJECTS += ipcom_atomic.o
|
||||
IPLIBOBJECTS += ipcom_ccivalidate.o
|
||||
IPLIBOBJECTS += ipcom_cmd_vxshell.o
|
||||
IPLIBOBJECTS += ipcom_job_queue.o
|
||||
IPLIBOBJECTS += ipcom_pfile.o
|
||||
IPLIBOBJECTS += ipcom_drv_mux.o
|
||||
IPLIBOBJECTS += ipcom_pshell.o
|
||||
IPLIBOBJECTS += ipcom_psock.o
|
||||
IPLIBOBJECTS += ipcom_shellcmd_vxworks.o
|
||||
IPLIBOBJECTS += ipcom_spinlock.o
|
||||
IPLIBOBJECTS += ipcom_windnet_compat.o
|
||||
IPLIBOBJECTS += ipcom_windview.o
|
||||
IPLIBOBJECTS += zbufLib.o
|
||||
IPLIBOBJECTS += zbufSockLib.o
|
||||
IPLIBOBJECTS += ipcom_mutex.o
|
||||
IPLIBOBJECTS += ipcom_sem.o
|
||||
|
||||
ifeq ($(IPBOARD),)
|
||||
IPLIBOBJECTS += ipcom_vxworks.o
|
||||
endif
|
||||
|
||||
ifeq ($(WIND_IPNET),true)
|
||||
IPLIBOBJECTS += ipcom_mcmd_ifconfig.o
|
||||
IPLIBOBJECTS += ipcom_mcmd_route.o
|
||||
IPLIBOBJECTS += ipcom_ramdisk.o
|
||||
endif
|
||||
|
||||
ifeq ($(WIND_IPLITE),true)
|
||||
IPLIBOBJECTS += ipcom_ramdisk.o
|
||||
endif
|
||||
|
||||
|
||||
#############################################################################
|
||||
# Market Specific Platform
|
||||
###########################################################################
|
||||
|
||||
ifneq ($(FEATURE_SET),)
|
||||
ifneq ($(FEATURE_SET),gpp)
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_common.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_ctrl.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_data.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_mipc.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_svlan.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_nehalem_forwarder_ipsec.o
|
||||
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_common.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_ctrl.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_data.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_mipc.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_svlan.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_p4080_forwarder_ipsec.o
|
||||
|
||||
IPLIBOBJECTS += ipcom_ipc_spinlock.o
|
||||
IPLIBOBJECTS += ipcom_shared_mem.o
|
||||
|
||||
IPLIBOBJECTS += ipcom_nae_vxworks.o
|
||||
IPLIBOBJECTS += ipcom_nae_vxworks_cavium.o
|
||||
IPLIBOBJECTS += ipcom_mipc_vxworks_cavium.o
|
||||
IPLIBOBJECTS += ipcom_nae_vxworks_p4080.o
|
||||
IPLIBOBJECTS += ipcom_ctrlnae_vxworks_p4080.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_cavium_forwarder_svlan.o
|
||||
IPLIBOBJECTS += ipcom_vxworks_cavium_forwarder_ipsec.o
|
||||
endif
|
||||
endif
|
||||
|
||||
#############################################################################
|
||||
# END OF VXWORKS.MK
|
||||
#############################################################################
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ccivalidate.h,v $ $Revision: 1.3 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_ccivalidate.h,v $
|
||||
* $Author: braghava $ $Date: 2007-09-28 09:44:18 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* Copyright 2000-2007 Interpeak AB (http://www.interpeak.se). All rights reserved.
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_CCIVALIDATE_H
|
||||
#define IPCOM_CCIVALIDATE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipcom_cmd_ccivalidate(int argc, char **argv);
|
||||
IP_GLOBAL int ipcom_cmd_cciperformance(int argc, char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef IPCOM_CCIVALIDATE_H*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_clibmap.h,v $ $Revision: 1.29.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_clibmap.h,v $
|
||||
* $Author: jwang9 $ $Date: 2018-07-31 06:09:56 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_CLIBMAP_H
|
||||
#define IPCOM_CLIBMAP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IP_DEBUG) || defined(WRS_IPLITE)
|
||||
#define IPCOM_MALLOC 1
|
||||
#define IPCOM_CALLOC 1
|
||||
#define IPCOM_REALLOC 1
|
||||
#define IPCOM_FREE 1
|
||||
#ifdef WRS_IPLITE
|
||||
#define IPCOM_STRDUP 1
|
||||
#endif
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
#define IPCOM_RANDOM 1
|
||||
#define IPCOM_SRANDOM 1
|
||||
#define IPCOM_RAND 1
|
||||
#define IPCOM_SRAND 1
|
||||
|
||||
#define IPCOM_EXIT 1
|
||||
#define IPCOM_ABORT 1
|
||||
#define IPCOM_SIGNAL 1
|
||||
|
||||
#define IPCOM_GETUID 1
|
||||
|
||||
#define IPCOM_PERROR 1
|
||||
#define IPCOM_STRERROR 1
|
||||
#define IPCOM_STRERROR_R 1
|
||||
|
||||
#define IPCOM_STRCASECMP 1
|
||||
#define IPCOM_STRNCASECMP 1
|
||||
|
||||
#define IPCOM_QSORT 1
|
||||
#define IPCOM_BSEARCH 1
|
||||
#define IPCOM_ISASCII 1
|
||||
|
||||
#define IPCOM_MICROTIME 1
|
||||
#define IPCOM_TIMES 1
|
||||
#define IPCOM_GETTIMEOFDAY 1
|
||||
#define IPCOM_SETTIMEOFDAY 1
|
||||
#define IPCOM_ADJTIME 1
|
||||
#define IPCOM_ASCTIME_R ipcom_asctime_r_vxworks
|
||||
#define IPCOM_CTIME_R ipcom_ctime_r_vxworks
|
||||
|
||||
#define IPCOM_TZSET 1
|
||||
|
||||
#define IPCOM_NORMPATH 1
|
||||
|
||||
#if IP_PORT_VXWORKS <= 60
|
||||
#define IPCOM_SNPRINTF 1
|
||||
#define IPCOM_VSNPRINTF 1
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_FORWARDER_NAE
|
||||
|
||||
#ifdef IPCOM_USE_OCTEON_FORWARDER
|
||||
#define IPCOM_PRINTF ipcom_mipc_printf
|
||||
#define IPCOM_SYSLOG ipcom_mipc_syslog
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_USE_P4080_FORWARDER
|
||||
/* For now, only use hv printf on p4080 */
|
||||
#if defined(IPCOM_USE_FORWARDER) && defined(_WRS_CONFIG_WRHV_GUEST)
|
||||
/* use hypervisor printf */
|
||||
#define IPCOM_PRINTF ipcom_hv_printf
|
||||
#define IPCOM_SYSLOG ipcom_hv_syslog
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/* ipcom_ifproxy_proto.h - header defining protocol used with ifproxy driver */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute, modify or otherwise make use
|
||||
* of this software may be licensed only pursuant to the terms
|
||||
* of an applicable Wind River license agreement.
|
||||
*/
|
||||
|
||||
#ifndef __INCifproxy_protoh
|
||||
#define __INCifproxy_protoh
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IFPROXY_CMD_PACKET_OUT 0x04
|
||||
#define IFPROXY_CMD_HDR_HAS_FWD_TAG 0x1
|
||||
|
||||
typedef struct ifproxy_cmd_hdr_s
|
||||
{
|
||||
uint16_t PortIndex;
|
||||
uint8_t Flags;
|
||||
uint8_t Command;
|
||||
uint16_t EndOffset;
|
||||
uint16_t StartOffset;
|
||||
|
||||
} ifproxy_cmd_hdr_t;
|
||||
|
||||
|
||||
/*
|
||||
* ifproxy_initial_t is the format of the first message sent
|
||||
* by the control NAE on the control socket.
|
||||
*/
|
||||
typedef struct ifproxy_initial_s
|
||||
{
|
||||
uint16_t dataport; /* NAE data socket MIPC port number for this port */
|
||||
uint16_t running; /* Is port running (media active)? */
|
||||
uint8_t hw_addr[6]; /* MAC station address */
|
||||
|
||||
} ifproxy_initial_t;
|
||||
|
||||
/*
|
||||
* After receiving the ifproxy_initial_t message from the
|
||||
* control NAE, the ifproxy driver connects its data socket and
|
||||
* responds with an ifproxy_initresp_t message on the control
|
||||
* connection.
|
||||
*/
|
||||
typedef struct ifproxy_initresp_s
|
||||
{
|
||||
uint16_t dataport; /* MIPC port number for ifproxy driver data port */
|
||||
uint16_t if_index; /* Linux interface index for proxy port.
|
||||
TODO: should be 32 bits like dev->ifindex */
|
||||
uint32_t rsvd1;
|
||||
uint64_t polling_cores; /* what forwarder cores should poll this port */
|
||||
|
||||
} ifproxy_initresp_t;
|
||||
|
||||
/*
|
||||
* The ifproxy driver sends various control requests to the NAE
|
||||
* whose format is described by one of the ifproxy_ctrl_msg variants.
|
||||
*/
|
||||
#define IFPROXY_CTRL_DOWN 0x00 /* Tell the data-plane that the
|
||||
interface is bought down. No reply. */
|
||||
#define IFPROXY_CTRL_UP 0x01 /* Tell the data-plane that the
|
||||
interface is bought up. No reply. */
|
||||
#define IFPROXY_CTRL_GET_MAC 0x02 /* Get the MAC address of the real device
|
||||
* Reply contains only 6-byte MAC address.
|
||||
*/
|
||||
#define IFPROXY_CTRL_SET_MAC 0x03 /* Set the MAC address of the real device
|
||||
* to the value in the eth_addr member.
|
||||
* No reply expected.
|
||||
*/
|
||||
#define IFPROXY_CTRL_SET_MCLIST 0x04 /* Set the L2 multicast group list for
|
||||
* the real port. No reply expected.
|
||||
*/
|
||||
|
||||
#define IFPROXY_CTRL_RESULT 0xff /* Result of set operation */
|
||||
|
||||
/* ctrl 0x00, 01, 02 */
|
||||
typedef struct ifproxy_ctrl_msg_s
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t flags;
|
||||
#define IFPROXY_CTRL_FLAGS_ALLMULTI 1 /* for IFPROXY_CTRL_SET_MCLIST */
|
||||
uint16_t rsvd16;
|
||||
|
||||
} ifproxy_ctrl_msg_t;
|
||||
|
||||
/* ctrl 0x03 */
|
||||
typedef struct ifproxy_ctrl_set_mac_s
|
||||
{
|
||||
ifproxy_ctrl_msg_t hdr;
|
||||
unsigned char eth_addr[6];
|
||||
|
||||
} ifproxy_ctrl_set_mac_t;
|
||||
|
||||
/* ctrl 0x04 */
|
||||
typedef struct ifproxy_ctrl_set_mclist_s {
|
||||
ifproxy_ctrl_msg_t hdr;
|
||||
uint16_t num_addrs; /* 0xffff -> ALLMULTI */
|
||||
uint8_t eth_addrs [1]; /* variable length (6*num_addrs) */
|
||||
} ifproxy_ctrl_set_mclist_t;
|
||||
|
||||
/*
|
||||
* How to separate unsolicited messages sent by the control NAE
|
||||
* on the control connection (e.g. link state changes) from responses
|
||||
* to requests on the control connection? Maybe send such unsolicited
|
||||
* messages on the data socket, distinguished from incoming packets?
|
||||
*
|
||||
* For now, we send link state change notifications as express data
|
||||
* on the control connection.
|
||||
*/
|
||||
|
||||
#define IFPROXY_EXPRESS_DATA(cmd, data) \
|
||||
(((uint64_t)(cmd)) | (((uint64_t)(data)) << 8))
|
||||
#define IFPROXY_EXPRESS_CMD(expressdata) \
|
||||
((unsigned int)((expressdata) & 0xffULL))
|
||||
|
||||
#define IFPROXY_CTRL_EXPRESS_LSC 0U
|
||||
|
||||
#define IFPROXY_CTRL_EXPRESS_LSC_DATA_ACTIVE 0x100
|
||||
|
||||
|
||||
/*
|
||||
* Data connection messages from Control NAE to ifproxy driver.
|
||||
* For the most part, these are received packets, but
|
||||
* there may also be others such as link-state change notifications.
|
||||
*/
|
||||
|
||||
#define IFPROXY_DATA_PACKET_IN 0x00 /* Deliver a received packet */
|
||||
|
||||
/* data 0x00 */
|
||||
typedef struct ifproxy_data_msg_s
|
||||
{
|
||||
uint8_t cmd;
|
||||
uint8_t flags;
|
||||
} ifproxy_data_msg_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCifproxy_protoh */
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ipcom2bsd.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_ipcom2bsd.h,v $
|
||||
* $Author: kenneth $ $Date: 2007-02-16 15:38:46 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Maps the IPCOM socket API to the VxWorks native socket API (sockLib).
|
||||
* This file must always be included as the last header file in every file
|
||||
* that want to use the VxWorks native socket API through IPCOM.
|
||||
* NOTE: remeber to include ipcom_ipcom2bsd_finish.h last in the C file that
|
||||
* uses this header.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IPCOM_IPCOM2BSD
|
||||
#define IPCOM_IPCOM2BSD
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <inetLib.h>
|
||||
#include <selectLib.h>
|
||||
#include <sockLib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Arrange for test applications to use sockLib */
|
||||
|
||||
/*
|
||||
* Remap constant definitions
|
||||
*/
|
||||
#ifdef IP_FD_CLR
|
||||
# undef IP_FD_CLR
|
||||
#endif
|
||||
#ifdef IP_FD_ISSET
|
||||
# undef IP_FD_ISSET
|
||||
#endif
|
||||
#ifdef IP_FD_SET
|
||||
# undef IP_FD_SET
|
||||
#endif
|
||||
#ifdef IP_FD_ZERO
|
||||
# undef IP_FD_ZERO
|
||||
#endif
|
||||
#ifdef Ip_stat
|
||||
# undef Ip_stat
|
||||
#endif
|
||||
|
||||
#define IP_FD_CLR FD_CLR
|
||||
#define IP_FD_ISSET FD_ISSET
|
||||
#define IP_FD_SET FD_SET
|
||||
#define IP_FD_ZERO FD_ZERO
|
||||
|
||||
/* Required in order to implement FD_ZERO */
|
||||
#define bzero(buffer, nbytes) ipcom_memset(buffer, 0, nbytes)
|
||||
|
||||
|
||||
/*
|
||||
* Remap type definitions
|
||||
*/
|
||||
#define Ip_cmsghdr cmsghdr
|
||||
#define Ip_fd_set fd_set
|
||||
#define Ip_iovec iovec
|
||||
#define Ip_msghdr msghdr
|
||||
#define Ip_sockaddr sockaddr
|
||||
#define Ip_sockaddr_in sockaddr_in
|
||||
#define Ip_sockaddr_in6 sockaddr_in6
|
||||
#define Ip_socklen_t int
|
||||
#define Ip_timeval timeval
|
||||
#define Ip_stat stat
|
||||
|
||||
/*
|
||||
* Remap socket function calls
|
||||
*/
|
||||
#ifdef ipcom_accept
|
||||
# undef ipcom_accept
|
||||
#endif
|
||||
#ifdef ipcom_bind
|
||||
# undef ipcom_bind
|
||||
#endif
|
||||
#ifdef ipcom_connect
|
||||
# undef ipcom_connect
|
||||
#endif
|
||||
#ifdef ipcom_getpeername
|
||||
# undef ipcom_getpeername
|
||||
#endif
|
||||
#ifdef ipcom_getsockname
|
||||
# undef ipcom_getsockname
|
||||
#endif
|
||||
#ifdef ipcom_getsockopt
|
||||
# undef ipcom_getsockopt
|
||||
#endif
|
||||
#ifdef ipcom_listen
|
||||
# undef ipcom_listen
|
||||
#endif
|
||||
#ifdef ipcom_recv
|
||||
# undef ipcom_recv
|
||||
#endif
|
||||
#ifdef ipcom_recvfrom
|
||||
# undef ipcom_recvfrom
|
||||
#endif
|
||||
#ifdef ipcom_recvmsg
|
||||
# undef ipcom_recvmsg
|
||||
#endif
|
||||
#ifdef ipcom_socketselect
|
||||
# undef ipcom_socketselect
|
||||
#endif
|
||||
#ifdef ipcom_send
|
||||
# undef ipcom_send
|
||||
#endif
|
||||
#ifdef ipcom_sendmsg
|
||||
# undef ipcom_sendmsg
|
||||
#endif
|
||||
#ifdef ipcom_sendto
|
||||
# undef ipcom_sendto
|
||||
#endif
|
||||
#ifdef ipcom_setsockopt
|
||||
# undef ipcom_setsockopt
|
||||
#endif
|
||||
#ifdef ipcom_shutdown
|
||||
# undef ipcom_shutdown
|
||||
#endif
|
||||
#ifdef ipcom_socket
|
||||
# undef ipcom_socket
|
||||
#endif
|
||||
#ifdef ipcom_socketclose
|
||||
# undef ipcom_socketclose
|
||||
#endif
|
||||
#ifdef ipcom_socketioctl
|
||||
# undef ipcom_socketioctl
|
||||
#endif
|
||||
#ifdef ipcom_socketread
|
||||
# undef ipcom_socketread
|
||||
#endif
|
||||
#ifdef ipcom_socketwrite
|
||||
# undef ipcom_socketwrite
|
||||
#endif
|
||||
|
||||
/* Direct all ipcom socket calls to the sockLib */
|
||||
#define ipcom_accept accept
|
||||
#define ipcom_bind bind
|
||||
#define ipcom_connect connect
|
||||
#define ipcom_getpeername getpeername
|
||||
#define ipcom_getsockname getsockname
|
||||
#define ipcom_getsockopt getsockopt
|
||||
#define ipcom_listen listen
|
||||
#define ipcom_recv recv
|
||||
#define ipcom_recvfrom recvfrom
|
||||
#define ipcom_recvmsg recvmsg
|
||||
#define ipcom_send send
|
||||
#define ipcom_sendmsg sendmsg
|
||||
#define ipcom_sendto sendto
|
||||
#define ipcom_setsockopt setsockopt
|
||||
#define ipcom_shutdown shutdown
|
||||
#define ipcom_socket socket
|
||||
#define ipcom_socketclose close
|
||||
#define ipcom_socketread read
|
||||
#define ipcom_socketselect select
|
||||
#define ipcom_socketwrite write
|
||||
/* Cast to long instead of int in the 3:rd argument so we will
|
||||
get build error (or at least a warning) when building for
|
||||
64-bit where using an int is broken (sizeof(int) != sizeof(void*)
|
||||
on most 64-bit arch) */
|
||||
#define ipcom_socketioctl(fd, function, opt) ioctl(fd, function, (long) opt)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_IPCOM2BSD */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ipcom2bsd_finish.h,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_ipcom2bsd_finish.h,v $
|
||||
* $Author: kenneth $ $Date: 2006-12-23 14:24:55 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Reverts the IPCOM API back to standard IPCOM functions again.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef IPCOM_IPCOM2BSD
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Remove all defines done by ipcom_ipcom2bsd.h */
|
||||
#undef IPCOM_FD_CLR
|
||||
#undef IP_FD_ISSET
|
||||
#undef IP_FD_SET
|
||||
#undef IP_FD_ZERO
|
||||
|
||||
#undef bzero
|
||||
|
||||
#undef Ip_cmsghdr
|
||||
#undef Ip_fd_set
|
||||
#undef Ip_iovec
|
||||
#undef Ip_msghdr
|
||||
#undef Ip_sockaddr
|
||||
#undef Ip_sockaddr_in
|
||||
#undef Ip_sockaddr_in6
|
||||
#undef Ip_socklen_t
|
||||
#undef Ip_timeval
|
||||
|
||||
#undef ipcom_accept
|
||||
#undef ipcom_bind
|
||||
#undef ipcom_connect
|
||||
#undef ipcom_getpeername
|
||||
#undef ipcom_getsockname
|
||||
#undef ipcom_getsockopt
|
||||
#undef ipcom_listen
|
||||
#undef ipcom_recv
|
||||
#undef ipcom_recvfrom
|
||||
#undef ipcom_recvmsg
|
||||
#undef ipcom_send
|
||||
#undef ipcom_sendmsg
|
||||
#undef ipcom_sendto
|
||||
#undef ipcom_setsockopt
|
||||
#undef ipcom_shutdown
|
||||
#undef ipcom_socket
|
||||
#undef ipcom_socketclose
|
||||
#undef ipcom_socketioctl
|
||||
#undef ipcom_socketread
|
||||
#undef ipcom_socketselect
|
||||
#undef ipcom_socketwrite
|
||||
|
||||
|
||||
#undef IP_FD_SET_TYPE
|
||||
#undef IPCOM_IPCOM2BSD
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_IPCOM2BSD */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ipcom2coreip.h,v $ $Revision: 1.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_ipcom2coreip.h,v $
|
||||
* $Author: kenneth $ $Date: 2007-01-11 09:41:31 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Make ipcom socket calls go through the socket library when IPLITE/IPNET
|
||||
* is included. This is used to test the socket backend using the socktest
|
||||
* shell command.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_pconfig.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_VXWORKS_TEST_SOCKET_BACKEND
|
||||
/* Direct all ipcom socket calls to the socketlib via ipcom_psock.c */
|
||||
#define ipcom_accept ipcom_socklib_accept
|
||||
#define ipcom_bind ipcom_socklib_bind
|
||||
#define ipcom_connect ipcom_socklib_connect
|
||||
#define ipcom_getpeername ipcom_socklib_getpeername
|
||||
#define ipcom_getsockname ipcom_socklib_getsockname
|
||||
#define ipcom_getsockopt ipcom_socklib_getsockopt
|
||||
#define ipcom_listen ipcom_socklib_listen
|
||||
#define ipcom_recv ipcom_socklib_recv
|
||||
#define ipcom_recvfrom ipcom_socklib_recvfrom
|
||||
#define ipcom_recvmsg ipcom_socklib_recvmsg
|
||||
#define ipcom_send ipcom_socklib_send
|
||||
#define ipcom_sendto ipcom_socklib_sendto
|
||||
#define ipcom_sendmsg ipcom_socklib_sendmsg
|
||||
#define ipcom_setsockopt ipcom_socklib_setsockopt
|
||||
#define ipcom_shutdown ipcom_socklib_shutdown
|
||||
#define ipcom_socket ipcom_socklib_socket
|
||||
#define ipcom_socketclose ipcom_socklib_close
|
||||
#define ipcom_socketioctl ipcom_socklib_ioctl
|
||||
#define ipcom_socketread ipcom_socklib_read
|
||||
#define ipcom_socketselect ipcom_socklib_select
|
||||
#define ipcom_socketwrite ipcom_socklib_write
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_nae_vxworks_cavium.h,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_nae_vxworks_cavium.h,v $
|
||||
* $Author: ulf $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_NAE_VXWORKS_CAVIUM_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_OCTEON_POW_FORWARDER_GRP (13) /* 14, 15 used by END driver */
|
||||
|
||||
|
||||
IP_PUBLIC void *ipcom_forwarder_attach_nae_netif_cavium(int port, int if_index);
|
||||
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* End of file
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_perrno.h,v $ $Revision: 1.10 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_perrno.h,v $
|
||||
* $Author: lob $ $Date: 2007-01-02 14:25:36 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PERRNO_H
|
||||
#define IPCOM_PERRNO_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* errno
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IP_ERRNO_EPERM 1
|
||||
#define IP_ERRNO_ENOENT 2
|
||||
#define IP_ERRNO_ESRCH 3
|
||||
#define IP_ERRNO_EINTR 4
|
||||
#define IP_ERRNO_EIO 5
|
||||
#define IP_ERRNO_ENXIO 6
|
||||
#define IP_ERRNO_E2BIG 7
|
||||
#define IP_ERRNO_EBADF 9
|
||||
|
||||
#define IP_ERRNO_EAGAIN 11
|
||||
#define IP_ERRNO_ENOMEM 12
|
||||
#define IP_ERRNO_EACCES 13
|
||||
#define IP_ERRNO_EFAULT 14
|
||||
#define IP_ERRNO_ENOTEMPTY 15
|
||||
#define IP_ERRNO_EBUSY 16
|
||||
#define IP_ERRNO_EEXIST 17
|
||||
#define IP_ERRNO_ENODEV 19
|
||||
|
||||
#define IP_ERRNO_ENOTDIR 20
|
||||
#define IP_ERRNO_EISDIR 21
|
||||
#define IP_ERRNO_EINVAL 22
|
||||
#define IP_ERRNO_ENFILE 23
|
||||
#define IP_ERRNO_EMFILE 24
|
||||
#define IP_ERRNO_ENOTTY 25
|
||||
#define IP_ERRNO_ENAMETOOLONG 26
|
||||
#define IP_ERRNO_ENOSPC 28
|
||||
|
||||
#define IP_ERRNO_EPIPE 32
|
||||
#define IP_ERRNO_EMSGSIZE 36
|
||||
#define IP_ERRNO_EDOM 37
|
||||
#define IP_ERRNO_ERANGE 38
|
||||
|
||||
#define IP_ERRNO_EDESTADDRREQ 40
|
||||
#define IP_ERRNO_EPROTOTYPE 41
|
||||
#define IP_ERRNO_ENOPROTOOPT 42
|
||||
#define IP_ERRNO_EPROTONOSUPPORT 43
|
||||
#define IP_ERRNO_ESOCKTNOSUPPORT 44
|
||||
#define IP_ERRNO_EOPNOTSUPP 45
|
||||
#define IP_ERRNO_EPFNOSUPPORT 46
|
||||
#define IP_ERRNO_EAFNOSUPPORT 47
|
||||
#define IP_ERRNO_EADDRINUSE 48
|
||||
#define IP_ERRNO_EADDRNOTAVAIL 49
|
||||
|
||||
#define IP_ERRNO_ENETUNREACH 51
|
||||
#define IP_ERRNO_ENETRESET 52
|
||||
#define IP_ERRNO_ECONNABORTED 53
|
||||
#define IP_ERRNO_ECONNRESET 54
|
||||
#define IP_ERRNO_ENOBUFS 55
|
||||
#define IP_ERRNO_EISCONN 56
|
||||
#define IP_ERRNO_ENOTCONN 57
|
||||
#define IP_ERRNO_ESHUTDOWN 58
|
||||
#define IP_ERRNO_ETOOMANYREFS 59
|
||||
|
||||
#define IP_ERRNO_ETIMEDOUT 60
|
||||
#define IP_ERRNO_ECONNREFUSED 61
|
||||
#define IP_ERRNO_ENETDOWN 62
|
||||
#define IP_ERRNO_EHOSTUNREACH 65
|
||||
#define IP_ERRNO_ENOTBLK 66
|
||||
#define IP_ERRNO_EHOSTDOWN 67
|
||||
|
||||
#define IP_ERRNO_EINPROGRESS 68
|
||||
#define IP_ERRNO_EALREADY 69
|
||||
#define IP_ERRNO_EWOULDBLOCK 70
|
||||
#define IP_ERRNO_ENOSYS 71 /* Function not implemented */
|
||||
|
||||
#define IP_ERRNO_ENOMSG 80
|
||||
#define IP_ERRNO_EDQUOT 83
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pfile.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_pfile.h,v $
|
||||
* $Author: lob $ $Date: 2006-05-04 16:56:47 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PFILE_H
|
||||
#define IPCOM_PFILE_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_type.h"
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NATIVE
|
||||
#error ipcom_pfile_h_only_used_with_native_file_system
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* file open modes
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#undef IP_O_CREAT
|
||||
#define IP_O_CREAT 0x0200
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* object types
|
||||
*===========================================================================
|
||||
* Bitvalues for object types.
|
||||
*/
|
||||
|
||||
#undef IP_S_IFREG
|
||||
#define IP_S_IFREG 0x8000 /* regular */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Bitvalues for object access
|
||||
*===========================================================================
|
||||
*/
|
||||
#undef IP_S_IREAD
|
||||
#undef IP_S_IWRITE
|
||||
#undef IP_S_IEXEC
|
||||
|
||||
#undef IP_S_IARCH
|
||||
#undef IP_S_IRUSR
|
||||
#undef IP_S_IWUSR
|
||||
#undef IP_S_IXUSR
|
||||
#undef IP_S_IRGRP
|
||||
#undef IP_S_IWGRP
|
||||
#undef IP_S_IXGRP
|
||||
#undef IP_S_IROTH
|
||||
#undef IP_S_IWOTH
|
||||
#undef IP_S_IXOTH
|
||||
|
||||
#define IP_S_IREAD (IP_S_IRUSR | IP_S_IRGRP | IP_S_IROTH)
|
||||
#define IP_S_IWRITE (IP_S_IWUSR | IP_S_IWGRP | IP_S_IWOTH)
|
||||
#define IP_S_IEXEC (IP_S_IXUSR | IP_S_IXGRP | IP_S_IXOTH)
|
||||
|
||||
#define IP_S_IRUSR 0x0100 /* read permission, owner */
|
||||
#define IP_S_IWUSR 0x0080 /* write permission, owner */
|
||||
#define IP_S_IXUSR 0x0040 /* execute/search permission, owner */
|
||||
#define IP_S_IRGRP 0x0020 /* read permission, group */
|
||||
#define IP_S_IWGRP 0x0010 /* write permission, group */
|
||||
#define IP_S_IXGRP 0x0008 /* execute/search permission, group */
|
||||
#define IP_S_IROTH 0x0004 /* read permission, other */
|
||||
#define IP_S_IWOTH 0x0002 /* write permission, other */
|
||||
#define IP_S_IXOTH 0x0001 /* execute/search permission, other */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_port.h,v $ $Revision: 1.8 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_port.h,v $
|
||||
* $Author: ulf $ $Date: 2010-03-12 09:59:50 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PORT_H
|
||||
#define IPCOM_PORT_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Interpeak VxWorks port.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_vx32.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_ipc
|
||||
*===========================================================================
|
||||
* typedef struct Ipcom_ipc
|
||||
* {
|
||||
* Ip_u32 magic;
|
||||
* Ip_pid_t peer_pid;
|
||||
* }
|
||||
* Ipcom_ipc;
|
||||
*/
|
||||
#define IPCOM_IPC_TYPE_SIZE 2
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* process declaration
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/* Process prototype: */
|
||||
#ifdef __cplusplus
|
||||
#define IPCOM_PROCESS(xname) extern "C" void xname(void)
|
||||
#else
|
||||
#define IPCOM_PROCESS(xname) void xname(void)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef _WRS_CONFIG_LP64
|
||||
# define IP_S32 int
|
||||
# define IP_U32 unsigned int
|
||||
# define IP_SIZE_T unsigned long
|
||||
# define IP_SSIZE_T long
|
||||
# define IP_PID_T Ip_u64
|
||||
#else
|
||||
# define IP_S32 long
|
||||
# define IP_U32 unsigned long
|
||||
# define IP_SIZE_T unsigned int
|
||||
# define IP_SSIZE_T int
|
||||
# define IP_PID_T Ip_u32
|
||||
#endif
|
||||
|
||||
#if defined(__RTP__)
|
||||
# define IP_OFF_T long long
|
||||
#else
|
||||
# define IP_OFF_T long
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_psock.h,v $ $Revision: 1.9 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_psock.h,v $
|
||||
* $Author: lob $ $Date: 2004-05-04 12:02:18 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_PSOCK_H
|
||||
#define IPCOM_PSOCK_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* VxWorks WindNet TCP/IP stack defines.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SOCK != IPCOM_SOCK_NATIVE
|
||||
#error ipcom_psock_h_only_used_with_native_stack
|
||||
#endif
|
||||
|
||||
#include "ipcom_type.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* setsockopt
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
/* Standard option flags per-socket. */
|
||||
#define IP_SO_DEBUG 0x0001 /* Turn on debugging info recording. */
|
||||
#undef IP_SO_KEEPALIVE
|
||||
#define IP_SO_KEEPALIVE 0x0008 /* Keep TCP connections alive. */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* select
|
||||
*===========================================================================
|
||||
*/
|
||||
#undef IP_FD_SETSIZE
|
||||
#define IP_FD_SETSIZE 256 /* Default value for vxWorks */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* IOCTL requests/replies
|
||||
*===========================================================================
|
||||
* IOCTL requests/replies. Values taken from ioLib.h.
|
||||
*/
|
||||
#undef IP_FIONBIO
|
||||
#define IP_FIONBIO 16 /* FIONBIO set/clear non-blocking i/o */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_vx32.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_vx32.h,v $
|
||||
* $Author: ulf $ $Date: 2010-02-18 16:53:02 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_VX32_H
|
||||
#define IPCOM_VX32_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Interpeak VxWorks 32-bit compatibility macros.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Have to use hardcoded version while waiting for 6.9 to be implemented. */
|
||||
#define IPCOM_VX32_HARDCODED_VXWORKS_VERSION 69
|
||||
|
||||
#if defined(IPCOM_VX32_HARDCODED_VXWORKS_VERSION)
|
||||
# define IPCOM_VX32_VER IPCOM_VX32_HARDCODED_VXWORKS_VERSION
|
||||
#elif defined(IP_PORT_VXWORKS)
|
||||
# define IPCOM_VX32_VER IP_PORT_VXWORKS
|
||||
#else
|
||||
# include <version.h>
|
||||
# if defined(RUNTIME_64BIT_NAME) /* FIXME - Remove when _WRS_VXWORKS_MINOR is updated */
|
||||
# define IPCOM_VX32_VER 69
|
||||
# elif defined(_WRS_VXWORKS_MAJOR) && defined(_WRS_VXWORKS_MINOR)
|
||||
# define IPCOM_VX32_VER ((10 * _WRS_VXWORKS_MAJOR) + _WRS_VXWORKS_MINOR)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(IPCOM_VX32_VER)
|
||||
# error Cannot determine VxWorks version, please set IPCOM_VX32_HARDCODED_VXWORKS_VERSION
|
||||
#endif
|
||||
|
||||
#if IPCOM_VX32_VER < 69
|
||||
|
||||
# if !defined(DRV_CREATE_PTR)
|
||||
# define DRV_CREATE_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_REMOVE_PTR)
|
||||
# define DRV_REMOVE_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_OPEN_PTR)
|
||||
# define DRV_OPEN_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_CLOSE_PTR)
|
||||
# define DRV_CLOSE_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_READ_PTR)
|
||||
# define DRV_READ_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_WRITE_PTR)
|
||||
# define DRV_WRITE_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(DRV_IOCTL_PTR)
|
||||
# define DRV_IOCTL_PTR FUNCPTR
|
||||
# endif
|
||||
# if !defined(vxAtomic32Get)
|
||||
# define vxAtomic32Get vxAtomicGet
|
||||
# endif
|
||||
# if !defined(vxAtomic32Set)
|
||||
# define vxAtomic32Set vxAtomicSet
|
||||
# endif
|
||||
# if !defined(vxAtomic32Inc)
|
||||
# define vxAtomic32Inc vxAtomicInc
|
||||
# endif
|
||||
# if !defined(vxAtomic32Dec)
|
||||
# define vxAtomic32Dec vxAtomicDec
|
||||
# endif
|
||||
# if !defined(vxAtomic32Add)
|
||||
# define vxAtomic32Add vxAtomicAdd
|
||||
# endif
|
||||
# if !defined(vxAtomic32Sub)
|
||||
# define vxAtomic32Sub vxAtomicSub
|
||||
# endif
|
||||
# if !defined(vxAtomic32Cas)
|
||||
# define vxAtomic32Cas vxAtomicCas
|
||||
# endif
|
||||
# if !defined(vxAtomicCas)
|
||||
# define vxAtomicCas vxCas
|
||||
# endif
|
||||
# if !defined(atomic32_t)
|
||||
# define atomic32_t atomic_t
|
||||
# endif
|
||||
# if !defined(SOCK_LIB_INIT_RTN)
|
||||
# define SOCK_LIB_INIT_RTN FUNCPTR
|
||||
# endif
|
||||
# if !defined(SYM_VALUE)
|
||||
# define SYM_VALUE void *
|
||||
# endif
|
||||
# if !defined(VXB_METHOD_ID)
|
||||
# define VXB_METHOD_ID unsigned int
|
||||
# endif
|
||||
# if !defined(WD_RTN)
|
||||
# define WD_RTN void *
|
||||
# endif
|
||||
|
||||
# if !defined(IP_INT_SIZET)
|
||||
# define IP_INT_SIZET int
|
||||
# endif
|
||||
# if !defined(IP_INT_VOIDP)
|
||||
# define IP_INT_VOIDP int
|
||||
# endif
|
||||
# if !defined(IP_SEM_ID)
|
||||
# define IP_SEM_ID int
|
||||
# endif
|
||||
# if !defined(IP_TASK_ID)
|
||||
# define IP_TASK_ID int
|
||||
# endif
|
||||
|
||||
#if !defined(TASK_ID_ERROR)
|
||||
# define TASK_ID_ERROR ((TASK_ID)(-1))
|
||||
#endif
|
||||
|
||||
#elif defined(_WRS_KERNEL)
|
||||
|
||||
# if !defined(IP_INT_SIZET)
|
||||
# define IP_INT_SIZET size_t
|
||||
# endif
|
||||
# if !defined(IP_INT_VOIDP)
|
||||
# define IP_INT_VOIDP void *
|
||||
# endif
|
||||
# if !defined(IP_SEM_ID)
|
||||
# define IP_SEM_ID SEM_ID
|
||||
# endif
|
||||
# if !defined(IP_TASK_ID)
|
||||
# define IP_TASK_ID TASK_ID
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# if !defined(IP_INT_SIZET)
|
||||
# define IP_INT_SIZET int
|
||||
# endif
|
||||
# if !defined(IP_INT_VOIDP)
|
||||
# define IP_INT_VOIDP int
|
||||
# endif
|
||||
# if !defined(IP_SEM_ID)
|
||||
# define IP_SEM_ID int
|
||||
# endif
|
||||
# if !defined(IP_TASK_ID)
|
||||
# define IP_TASK_ID int
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,384 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_vxworks.h,v $ $Revision: 1.30.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_vxworks.h,v $
|
||||
* $Author: jren $ $Date: 2023-10-20 05:49:03 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_VXWORKS_H
|
||||
#define IPCOM_VXWORKS_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_hash.h"
|
||||
#include "ipcom_list.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_type.h"
|
||||
#ifdef IPCOM_USE_SPINLOCK_DEADLOCK_DETECTION
|
||||
#include "ipcom_atomic.h"
|
||||
#endif
|
||||
|
||||
#include "ipcom_pkt.h"
|
||||
|
||||
#ifdef IPNET_USE_VLAN_STACKING
|
||||
#include "ipcom_netif.h"
|
||||
#endif
|
||||
|
||||
#ifdef IPCOM_SOCK
|
||||
# include <vxWorks.h>
|
||||
# include <vwModNum.h>
|
||||
# include <selectLib.h>
|
||||
# ifdef _WRS_KERNEL
|
||||
# include <iosLib.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WRS_KERNEL
|
||||
#include <netBufLib.h>
|
||||
#endif
|
||||
|
||||
#include <taskLib.h>
|
||||
|
||||
#if !defined(_WRS_KERNEL) && !defined(IPCOM_KERNEL)
|
||||
#include <private/taskLibP.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_DRV_MAX_IFS 32
|
||||
|
||||
/*
|
||||
* Convert a non-zero Ip_err value to an errno value for use in backwards
|
||||
* compatibility wrappers, where returning the Ip_err value directly may
|
||||
* not be an option.
|
||||
*/
|
||||
#define IPCOM_ERRNO(x) (M_ipcom | ((x) & 0xffff))
|
||||
|
||||
/*
|
||||
* This section duplicates error number information from ipcom_err.h.
|
||||
* These codes are used for backwards compatibility wrapper functions
|
||||
* which store IPCOM_ERRNO(x) values in errno when an underlying ipcom
|
||||
* function returns an error value x.
|
||||
*
|
||||
* If ipcom_err.h is changed or extended, it may be necessary to reflect
|
||||
* that change here. If this becomes burdensome, it may be desirable to
|
||||
* look into a method for automatically generating the contents of this
|
||||
* section from those files.
|
||||
*
|
||||
* We don't actually use the IPCOM_ERRNO macro in these definitions
|
||||
* since the makeStatTbl script doesn't do macro expansions. M_ipcom
|
||||
* itself is defined in vwModNum.h.
|
||||
* Note, we don't need errno constants for ipcom_perrno.h, as those
|
||||
* are supposed to match those from errno.h.
|
||||
*/
|
||||
|
||||
/* See ipcom_err.h for error descriptions */
|
||||
#define S_ipcom_ERR_FAILED (M_ipcom | (0xffff & -1000))
|
||||
#define S_ipcom_ERR_NO_MEMORY (M_ipcom | (0xffff & -1010))
|
||||
#define S_ipcom_ERR_NOT_FOUND (M_ipcom | (0xffff & -1011))
|
||||
#define S_ipcom_ERR_NOT_SUPPORTED (M_ipcom | (0xffff & -1012))
|
||||
#define S_ipcom_ERR_PERMISSION_DENIED (M_ipcom | (0xffff & -1013))
|
||||
#define S_ipcom_ERR_ALREADY_OPEN (M_ipcom | (0xffff & -1040))
|
||||
#define S_ipcom_ERR_ALREADY_CLOSED (M_ipcom | (0xffff & -1041))
|
||||
#define S_ipcom_ERR_ALREADY_INSTALLED (M_ipcom | (0xffff & -1042))
|
||||
#define S_ipcom_ERR_ALREADY_STARTED (M_ipcom | (0xffff & -1043))
|
||||
#define S_ipcom_ERR_NOT_OPENED (M_ipcom | (0xffff & -1050))
|
||||
#define S_ipcom_ERR_NOT_CLOSED (M_ipcom | (0xffff & -1051))
|
||||
#define S_ipcom_ERR_NOT_INSTALLED (M_ipcom | (0xffff & -1052))
|
||||
#define S_ipcom_ERR_NOT_STARTED (M_ipcom | (0xffff & -1053))
|
||||
#define S_ipcom_ERR_INVALID_ARG (M_ipcom | (0xffff & -1060))
|
||||
#define S_ipcom_ERR_INVALID_CONFIG (M_ipcom | (0xffff & -1061))
|
||||
#define S_ipcom_ERR_INVALID_VERSION (M_ipcom | (0xffff & -1062))
|
||||
#define S_ipcom_ERR_INVALID_ALIGNMENT (M_ipcom | (0xffff & -1063))
|
||||
#define S_ipcom_ERR_INVALID_INTERFACE (M_ipcom | (0xffff & -1064))
|
||||
#define S_ipcom_ERR_NO_ROUTE (M_ipcom | (0xffff & -1070))
|
||||
#define S_ipcom_ERR_DEAD_ROUTE (M_ipcom | (0xffff & -1071))
|
||||
#define S_ipcom_ERR_INVALID_ROUTE (M_ipcom | (0xffff & -1072))
|
||||
#define S_ipcom_ERR_INVALID_MASK (M_ipcom | (0xffff & -1073))
|
||||
#define S_ipcom_ERR_INVALID_RTCLIENT (M_ipcom | (0xffff & -1074))
|
||||
#define S_ipcom_ERR_DUPLICATE (M_ipcom | (0xffff & -1080))
|
||||
#define S_ipcom_ERR_LOCKED (M_ipcom | (0xffff & -1081))
|
||||
#define S_ipcom_ERR_END (M_ipcom | (0xffff & -1082))
|
||||
#define S_ipcom_ERR_READONLY (M_ipcom | (0xffff & -1083))
|
||||
#define S_ipcom_ERR_INVALID_TAG_VALUE (M_ipcom | (0xffff & -1090))
|
||||
#define S_ipcom_ERR_UNSUPPORTED_TAG (M_ipcom | (0xffff & -1091))
|
||||
#define S_ipcom_ERR_INVALID_PACKET (M_ipcom | (0xffff & -1100))
|
||||
#define S_ipcom_ERR_BAD_PACKET (M_ipcom | (0xffff & -1101))
|
||||
#define S_ipcom_ERR_IGNORED_PACKET (M_ipcom | (0xffff & -1102))
|
||||
#define S_ipcom_ERR_SOCKCALLFAILED (M_ipcom | (0xffff & -1110))
|
||||
#define S_ipcom_ERR_REACHED_MIN (M_ipcom | (0xffff & -1111))
|
||||
#define S_ipcom_ERR_REACHED_MAX (M_ipcom | (0xffff & -1112))
|
||||
#define S_ipcom_ERR_TIMEOUT (M_ipcom | (0xffff & -1120))
|
||||
#define S_ipcom_ERR_WOULDBLOCK (M_ipcom | (0xffff & -1121))
|
||||
#define S_ipcom_ERR_INTERRUPT (M_ipcom | (0xffff & -1122))
|
||||
#define S_ipcom_ERR_PENDING (M_ipcom | (0xffff & -1123))
|
||||
#define S_ipcom_ERR_AUTH_FAILED (M_ipcom | (0xffff & -1130))
|
||||
#define S_ipcom_ERR_AUTH_UNKNOWN (M_ipcom | (0xffff & -1131))
|
||||
|
||||
/* From ipcom_errno.h */
|
||||
#define S_ipcom_ENOMEDIUM (M_ipcom | 123)
|
||||
#define S_ipcom_EMEDIUMTYPE (M_ipcom | 124)
|
||||
#define S_ipcom_ENODATA (M_ipcom | 200)
|
||||
#define S_ipcom_ECOMM (M_ipcom | 201)
|
||||
|
||||
#define S_ipcom_EINTERNAL (M_ipcom | 1000)
|
||||
#define S_ipcom_ENOSUPPORT (M_ipcom | 1001)
|
||||
#define S_ipcom_EINITFAILED (M_ipcom | 1002)
|
||||
#define S_ipcom_ECONFIG (M_ipcom | 1003)
|
||||
#define S_ipcom_ENOTOME (M_ipcom | 1004)
|
||||
#define S_ipcom_ENOTFOUND (M_ipcom | 1005)
|
||||
#define S_ipcom_EFIREWALL (M_ipcom | 1006)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_pproc
|
||||
*===========================================================================
|
||||
* Process specific data, member of Ipcom_proc struct.
|
||||
*/
|
||||
typedef struct Ipcom_pproc_struct
|
||||
{
|
||||
int errcode; /* process specific 'errno' */
|
||||
|
||||
/* IPC related data */
|
||||
Ip_bool ipc_installed;
|
||||
Ipcom_list ipc_in_queue;
|
||||
void *in_queue_sem;
|
||||
Ip_bool is_stack_task;
|
||||
#ifdef IPCOM_USE_SPINLOCK_DEADLOCK_DETECTION
|
||||
Ipcom_atomic_t spinlocks_held;
|
||||
#endif
|
||||
}
|
||||
Ipcom_pproc;
|
||||
|
||||
|
||||
#if defined(IPCOM_SOCK) && defined(_WRS_KERNEL)
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_drv_eth_dev_hdr
|
||||
*===========================================================================
|
||||
*/
|
||||
typedef struct Ipcom_drv_eth_dev_hdr_struct
|
||||
{
|
||||
DEV_HDR dev_hdr;
|
||||
}
|
||||
Ipcom_drv_eth_dev_hdr;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef IPCOM_DRV_ETH_STATS
|
||||
struct Ipcom_drv_eth_stats_st
|
||||
{
|
||||
/* Statistics */
|
||||
unsigned int recv_mbufs;
|
||||
unsigned int recv_pkts;
|
||||
unsigned int recv_lost;
|
||||
unsigned int recv_lost_pkt_create;
|
||||
unsigned int recv_strange_buf;
|
||||
unsigned int recv_pkt_malloc_fail;
|
||||
unsigned int send_pkts;
|
||||
unsigned int send_pkt_blocked;
|
||||
unsigned int send_pkt_err;
|
||||
unsigned int send_pkt_err_unexp;
|
||||
unsigned int send_out_of_mbufs;
|
||||
unsigned int send_out_of_clblk;
|
||||
unsigned int restart;
|
||||
unsigned int error_end;
|
||||
unsigned int free_out_pkt;
|
||||
unsigned int free_out_pkt_nop;
|
||||
};
|
||||
typedef struct Ipcom_drv_eth_stats_st Ipcom_drv_eth_stats;
|
||||
#define IPCOM_DRV_ETH_STATS_LINE(xvar) ipcom_port.eth_stats.xvar
|
||||
|
||||
#else
|
||||
|
||||
#define IPCOM_DRV_ETH_STATS_LINE(xvar) IP_NOOP
|
||||
|
||||
#endif /* IPCOM_DRV_ETH_STATS */
|
||||
|
||||
|
||||
#ifdef IPCOM_VXWORKS_STATS
|
||||
|
||||
#define IPCOM_STATS(xvar) ipcom_port.stats.xvar
|
||||
|
||||
typedef struct Ipcom_vxworks_stats_struct
|
||||
{
|
||||
Ip_u32 task_del_hook;
|
||||
Ip_u32 task_del_hook_proc_found;
|
||||
Ip_u32 ipc_open;
|
||||
Ip_u32 ipc_open_before_install;
|
||||
Ip_u32 ipc_close;
|
||||
Ip_u32 ipc_install;
|
||||
Ip_u32 ipc_uninstall;
|
||||
Ip_u32 ipc_send;
|
||||
Ip_u32 ipc_receive;
|
||||
}
|
||||
Ipcom_vxworks_stats;
|
||||
|
||||
#else
|
||||
|
||||
#define IPCOM_STATS(xvar) IP_NOOP
|
||||
|
||||
#endif /* IPCOM_VXWORKS_STATS */
|
||||
|
||||
struct Ipcom_drv_if_map_st
|
||||
{
|
||||
const char* mux_dev_name;
|
||||
const char* ip_if_name;
|
||||
};
|
||||
typedef struct Ipcom_drv_if_map_st Ipcom_drv_if_map;
|
||||
|
||||
#ifdef _WRS_KERNEL
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_port
|
||||
*===========================================================================
|
||||
* Port specific global IPCOM data.
|
||||
*/
|
||||
typedef struct Ipcom_port_struct
|
||||
{
|
||||
Ipcom_list open_q_head; /* IPC queue. */
|
||||
Ipcom_mutex code_mutex; /* Protects IPCOM global data */
|
||||
Ipcom_sem init_sync; /* Syncronizes initialization of ipcom */
|
||||
|
||||
#ifdef IPCOM_SOCK
|
||||
#ifdef IPCOM_VXWORKS_DRV_NULLPOOL
|
||||
NET_POOL *net_pool;
|
||||
#else
|
||||
NET_POOL net_pool;
|
||||
#endif
|
||||
#ifdef IPCOM_USE_SOCK_COMPAT
|
||||
Ipcom_drv_eth_dev_hdr dev_hdr;
|
||||
Ipcom_drv_if_map if_map[IPCOM_DRV_MAX_IFS];
|
||||
#if 0
|
||||
Ipcom_hash *select_wakeup_lists;
|
||||
Ipcom_mutex select_wakeup_lists_mutex;
|
||||
#endif
|
||||
#endif
|
||||
#endif /* IPCOM_SOCK */
|
||||
|
||||
#ifdef IPCOM_VXWORKS_STATS
|
||||
Ipcom_vxworks_stats stats;
|
||||
#endif
|
||||
#ifdef IPCOM_DRV_ETH_STATS
|
||||
Ipcom_drv_eth_stats eth_stats;
|
||||
#endif
|
||||
}
|
||||
Ipcom_port;
|
||||
|
||||
IP_EXTERN IP_FASTDATA Ipcom_port ipcom_port;
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Ipcom_port_pkt
|
||||
*===========================================================================
|
||||
* Port specific Ipcom_pkt extension.
|
||||
*/
|
||||
|
||||
typedef struct Ipcom_port_pkt_struct
|
||||
{
|
||||
Ipcom_pkt pkt;
|
||||
|
||||
/*
|
||||
* This padding is necessary to make sure that the member poolId immediately
|
||||
* precedes the member ml if M_LINK structure becomes 64-bit aligned for
|
||||
* example, when Ip_time_t is redefined to be 64-bit.
|
||||
*/
|
||||
|
||||
#ifndef _WRS_CONFIG_LP64
|
||||
UINT32 pad4 __attribute__((aligned(8)));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These two members must be last. They are not actually present
|
||||
* when MUX M_BLK support is not needed in the image. That's an
|
||||
* image-build-time choice, not an archive-build-time choice, so
|
||||
* there isn't any #ifdef ... #endif here for these members.
|
||||
*/
|
||||
NET_POOL_ID poolId; /* Hidden NET_POOL_ID preceeding M_LINK */
|
||||
M_LINK ml;
|
||||
}
|
||||
Ipcom_port_pkt;
|
||||
|
||||
/*
|
||||
* ml must immediately follow poolId in Ipcom_port_pkt. Verify that the
|
||||
* compiler does not add any unnamed padding in between these two members.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && (__STDC_VERSION__ >= 201112L)
|
||||
_Static_assert (__builtin_offsetof (Ipcom_port_pkt, poolId) +
|
||||
sizeof (NET_POOL_ID) == __builtin_offsetof (Ipcom_port_pkt, ml),
|
||||
"Ipcom_port_pkt: ml must follow immediately after poolId");
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _WRS_KERNEL */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL void ipcom_vxworks_task_del_hook(WIND_TCB* tcb);
|
||||
IP_PUBLIC Ipcom_proc *ipcom_proc_find(Ip_pid_t pid, Ip_bool create);
|
||||
IP_GLOBAL Ip_err ipcom_vxworks_proc_free(Ipcom_proc* proc);
|
||||
IP_GLOBAL void ipcom_register_dev_name_mapping(const char* mux_dev_name,
|
||||
const char* ip_if_name);
|
||||
IP_GLOBAL const char* ipcom_get_mux_dev_name(const char* ip_if_name);
|
||||
IP_GLOBAL const char* ipcom_get_ip_if_name(const char* mux_dev_name);
|
||||
IP_GLOBAL Ip_err ipcom_drv_eth_init(const char *drvname, Ip_u32 drvunit,
|
||||
const char *ifname);
|
||||
#ifdef IPNET_USE_VLAN_STACKING
|
||||
IP_GLOBAL int ipcom_drv_eth_set_stpid(Ipcom_netif *netif, Ip_u16 stpid);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,368 @@
|
||||
/* ipcom_vxworks_nehalem_svlan.h - VLAN stacking MNT on Nehalem head file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01b,07jan11,tlu Record C-VLAN tag in pkt flag on an S port
|
||||
01a,17nov10,tlu Moved inline functions from
|
||||
ipcom_vxworks_cavium_forwarder_svlan.c
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_VXWORKS_CAVIUM_SVLAN_H
|
||||
#define IPCOM_VXWORKS_CAVIUM_SVLAN_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
#ifdef IPCOM_USE_OCTEON_FORWARDER
|
||||
|
||||
#ifdef IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
|
||||
#include "ipcom_forwarder.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "cvmx-config.h" /* Must be before cvmx.h include */
|
||||
#include "executive-config.h"
|
||||
|
||||
#include "cvmx.h"
|
||||
#include "cvmx-atomic.h"
|
||||
#include "cvmx-ciu.h"
|
||||
#include "cvmx-pip.h"
|
||||
#include "cvmx-ipd.h"
|
||||
#include "cvmx-gmx.h"
|
||||
#include "cvmx-sysinfo.h"
|
||||
#include "cvmx-tim.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IS_MCAST(dst_mac) ((dst_mac[0] == 0x01)?IPCOM_FWD_VLAN_PKT_MCAST:0)
|
||||
#define IS_BCAST(dst_mac) \
|
||||
(((dst_mac[0] == 0xFF) && (dst_mac[1] == 0xFF) && \
|
||||
(dst_mac[2] == 0xFF) && (dst_mac[3] == 0xFF) && \
|
||||
(dst_mac[4] == 0xFF) && (dst_mac[5] == 0xFF)) ? \
|
||||
IPCOM_FWD_VLAN_PKT_BCAST:0)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_reverse
|
||||
*===========================================================================
|
||||
* Description: Reverse the number's order
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ Ip_u16
|
||||
ipcom_svlan_reverse(Ip_u16 vid)
|
||||
{
|
||||
Ip_u16 rev = 0;
|
||||
|
||||
while (vid > 0)
|
||||
{
|
||||
rev = (rev << 1) + (vid & 0x1);
|
||||
vid = vid >> 1;
|
||||
}
|
||||
return rev;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_cs_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on a CS port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_cs_rx(void *pkt, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
cvmx_wqe_t *work = (cvmx_wqe_t *)pkt;
|
||||
|
||||
#ifdef FW_SVLAN_DEBUG
|
||||
printf("Enter ipcom_svlan_cs_rx, ipprt %d\n", ipprt);
|
||||
#endif
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
|
||||
/* Init elems, keep orig pkt pointer, and record input port */
|
||||
msg->fw_key = msg->ctci = msg->stci = msg->spri = 0;
|
||||
msg->orig_pkt = work->packet_ptr.s.addr;
|
||||
msg->ipprt = ipprt;
|
||||
|
||||
/* re-format the cache hash key */
|
||||
if (cvmx_unlikely(work->word2.s.not_IP))
|
||||
{
|
||||
msg->packet = (Ip_u8 *)cvmx_phys_to_ptr(work->packet_ptr.s.addr);
|
||||
msg->pkt_flags=(work->word2.snoip.is_bcast?IPCOM_FWD_VLAN_PKT_BCAST:0)
|
||||
| (work->word2.snoip.is_mcast?IPCOM_FWD_VLAN_PKT_MCAST:0);
|
||||
if (work->word2.snoip.vlan_valid)
|
||||
{
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
msg->fw_key = work->word2.snoip.vlan_id & 0x0fff;
|
||||
}
|
||||
else if (*(Ip_u16 *)(msg->packet + LL_ETH_ADDRS_SZ) ==
|
||||
ipcom_fw->vlan_s_tpid_net)
|
||||
{
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_SVTAG;
|
||||
msg->stci = ip_ntohs(*(Ip_u16 *)(msg->packet + LL_ETH_HDR_SZ));
|
||||
if (*(Ip_u16 *)(msg->packet + LL_ETH_ADDRS_VLAN_SZ)
|
||||
== ETH_FRAME_C_VLAN)
|
||||
{
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet +
|
||||
LL_ETH_HDR_VLAN_SZ));
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
msg->fw_key = msg->ctci & 0x0fff;
|
||||
}
|
||||
}
|
||||
#ifdef FW_SVLAN_DEBUG
|
||||
printf("ipcom_forwarder_rx, (snoip) is bcast %d, is mcast %d\n",
|
||||
work->word2.snoip.is_bcast, work->word2.snoip.is_mcast);
|
||||
printf("ipcom_forwarder_rx, (snoip) fw_key %d\n", msg->fw_key);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
msg->pkt_flags = (work->word2.s.is_bcast?IPCOM_FWD_VLAN_PKT_BCAST:0)
|
||||
| (work->word2.s.is_mcast?IPCOM_FWD_VLAN_PKT_MCAST:0);
|
||||
if (work->word2.s.vlan_valid)
|
||||
{
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
msg->fw_key = work->word2.s.vlan_id & 0x0fff;
|
||||
}
|
||||
#ifdef FW_SVLAN_DEBUG
|
||||
printf("ipcom_forwarder_rx, (ip) is bcast %d, is mcast %d\n",
|
||||
work->word2.s.is_bcast, work->word2.s.is_mcast);
|
||||
printf("ipcom_forwarder_rx, (ip) fw_key %d\n", msg->fw_key);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[ipprt] & IPCOM_FWD_VLAN_DROP_VID)) ||
|
||||
(!(msg->fw_key) &&
|
||||
(ipcom_fw->rule_flags[ipprt] & IPCOM_FWD_VLAN_DROP_NO_VID)) ||
|
||||
(msg->stci & 0x0FFF))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, IP_NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(msg->fw_key))
|
||||
{
|
||||
msg->fw_key = ipcom_fw->hw_pvid[ipprt];
|
||||
msg->ctci |= ipcom_fw->hw_pvid[ipprt];
|
||||
if (msg->pkt_flags & IPCOM_FWD_VLAN_PKT_CVTAG)
|
||||
*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ) = ip_htons(msg->ctci);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_sc_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on an SC port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_sc_rx(void *pkt, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
cvmx_wqe_t *work = (cvmx_wqe_t *)pkt;
|
||||
|
||||
#ifdef FW_SVLAN_DEBUG
|
||||
printf("Enter ipcom_svlan_sc_rx, ipprt %d\n", ipprt);
|
||||
#endif
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
msg->packet = (Ip_u8 *)cvmx_phys_to_ptr(work->packet_ptr.s.addr);
|
||||
|
||||
/* record pkt flags */
|
||||
msg->pkt_flags = IPCOM_FWD_VLAN_PKT_SVTAG |
|
||||
(work->word2.snoip.is_bcast?IPCOM_FWD_VLAN_PKT_BCAST:0) |
|
||||
(work->word2.snoip.is_mcast?IPCOM_FWD_VLAN_PKT_MCAST:0);
|
||||
|
||||
/* Init elems, keep orig pkt pointer, and record input port */
|
||||
msg->orig_pkt = work->packet_ptr.s.addr;
|
||||
msg->ipprt = ipprt;
|
||||
|
||||
/* re-format the cache hash key */
|
||||
msg->stci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
msg->fw_key = msg->stci & 0x0fff;
|
||||
#ifdef _WRS_CONFIG_COMPONENT_OCTEON_PRIORITY_QUEUE
|
||||
msg->spri = (msg->stci & 0xe000) >> 13;
|
||||
#endif
|
||||
|
||||
/* record C-VLAN */
|
||||
if (*(Ip_u16 *)(msg->packet + LL_ETH_ADDRS_VLAN_SZ) == ETH_FRAME_C_VLAN)
|
||||
{
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet + LL_ETH_HDR_VLAN_SZ));
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
}
|
||||
else
|
||||
msg->ctci = ipcom_fw->hw_pvid[msg->ipprt];
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[work->ipprt]&IPCOM_FWD_VLAN_DROP_VID))||
|
||||
!(msg->fw_key))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, IP_NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SVLAN_SC_FWD_TABLE
|
||||
msg->fw_key ^= ipcom_svlan_reverse(msg->ctci & 0x0fff);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_s_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on an S port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_s_rx(void *pkt, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
cvmx_wqe_t *work = (cvmx_wqe_t *)pkt;
|
||||
|
||||
#ifdef FW_SVLAN_DEBUG
|
||||
printf("Enter ipcom_svlan_s_rx, ipprt %d\n", ipprt);
|
||||
#endif
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
msg->packet = (Ip_u8 *)cvmx_phys_to_ptr(work->packet_ptr.s.addr);
|
||||
|
||||
/* record pkt flags */
|
||||
msg->pkt_flags = IPCOM_FWD_VLAN_PKT_SVTAG |
|
||||
(work->word2.snoip.is_bcast?IPCOM_FWD_VLAN_PKT_BCAST:0) |
|
||||
(work->word2.snoip.is_mcast?IPCOM_FWD_VLAN_PKT_MCAST:0);
|
||||
|
||||
if (*(Ip_u16 *)(msg->packet + LL_ETH_ADDRS_VLAN_SZ) == ETH_FRAME_C_VLAN)
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
|
||||
/* Keep orig pkt pointer, and record input port */
|
||||
msg->orig_pkt = work->packet_ptr.s.addr;
|
||||
msg->ipprt = ipprt;
|
||||
|
||||
/* re-format the cache hash key */
|
||||
msg->stci = 0;
|
||||
msg->fw_key = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ)) & 0x0fff;
|
||||
#ifdef _WRS_CONFIG_COMPONENT_OCTEON_PRIORITY_QUEUE
|
||||
msg->spri = (ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ)) & 0xe000) >> 13;
|
||||
#endif
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[work->ipprt] & IPCOM_FWD_VLAN_DROP_VID)) ||
|
||||
!(msg->fw_key))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, IP_NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_forwarder_vlan_update_work
|
||||
*===========================================================================
|
||||
* Context:
|
||||
* Description: Update work after VLAN modifies the packet
|
||||
* Parameters: fw_msg : hardware message
|
||||
* work : work queue entry
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ void
|
||||
ipcom_forwarder_vlan_update_work(fw_msg_t *fw_msg, Ip_s8 len_mod)
|
||||
{
|
||||
cvmx_wqe_t *work = (cvmx_wqe_t *)((Ip_u8 *)fw_msg - ip_offsetof(cvmx_wqe_t, packet_data));
|
||||
|
||||
work->len += len_mod;
|
||||
work->packet_ptr.s.addr = cvmx_ptr_to_phys(fw_msg->packet);
|
||||
work->packet_ptr.s.back += (work->packet_ptr.s.addr >> 7) - (fw_msg->orig_pkt >> 7);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_VXWORKS_CAVIUM_SVLAN_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,276 @@
|
||||
/* ipcom_vxworks_nehalem_svlan.h - VLAN stacking MNT on Nehalem head file */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01b,07jan11,tlu Record C-VLAN tag in pkt flag on an S port
|
||||
01a,17nov10,tlu Moved inline functions from
|
||||
ipcom_vxworks_nehalem_forwarder_svlan.c
|
||||
*/
|
||||
|
||||
#ifndef IPCOM_VXWORKS_NEHALEM_SVLAN_H
|
||||
#define IPCOM_VXWORKS_NEHALEM_SVLAN_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
#ifdef IPCOM_USE_NEHALEM_FORWARDER
|
||||
|
||||
#ifdef IPCOM_USE_FORWARDER_VLAN_STACKING
|
||||
|
||||
#include "ipcom_forwarder.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IS_MCAST(dst_mac) ((dst_mac[0] == 0x01)?IPCOM_FWD_VLAN_PKT_MCAST:0)
|
||||
#define IS_BCAST(dst_mac) \
|
||||
(((dst_mac[0] == 0xFF) && (dst_mac[1] == 0xFF) && \
|
||||
(dst_mac[2] == 0xFF) && (dst_mac[3] == 0xFF) && \
|
||||
(dst_mac[4] == 0xFF) && (dst_mac[5] == 0xFF)) ? \
|
||||
IPCOM_FWD_VLAN_PKT_BCAST:0)
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_reverse
|
||||
*===========================================================================
|
||||
* Description: Reverse the number's order
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ Ip_u16
|
||||
ipcom_svlan_reverse(Ip_u16 vid)
|
||||
{
|
||||
Ip_u16 rev = 0;
|
||||
|
||||
while (vid > 0)
|
||||
{
|
||||
rev = (rev << 1) + (vid & 0x1);
|
||||
vid = vid >> 1;
|
||||
}
|
||||
return rev;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_cs_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on a CS port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_cs_rx(void *packet, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
|
||||
/* Init len_mod, keep orig pkt pointer, and record input port */
|
||||
msg->fw_key = msg->ctci = msg->stci = msg->spri = 0;
|
||||
msg->pkt_flags = IS_MCAST(msg->packet) | IS_BCAST(msg->packet);
|
||||
|
||||
/* re-format the cache hash key */
|
||||
if (*(Ip_u16 *)(msg->packet+LL_ETH_ADDRS_SZ) == ipcom_fw->vlan_s_tpid_net)
|
||||
{
|
||||
/* the pkt carries an S-VLAN tag */
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_SVTAG;
|
||||
msg->stci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
if (*(Ip_u16 *)(msg->packet+LL_ETH_ADDRS_VLAN_SZ)
|
||||
== ETH_FRAME_C_VLAN)
|
||||
{
|
||||
/* the pkt also carries a C-VLAN tag */
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet +
|
||||
LL_ETH_HDR_VLAN_SZ));
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
msg->fw_key = msg->ctci & 0x0fff;
|
||||
}
|
||||
}
|
||||
else if (*(Ip_u16 *)(msg->packet+LL_ETH_ADDRS_SZ) == ETH_FRAME_C_VLAN)
|
||||
{
|
||||
/* the pkt carries a C-VLAN tag */
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet + LL_ETH_HDR_SZ));
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
msg->fw_key = msg->ctci & 0x0fff;
|
||||
}
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[ipprt] & IPCOM_FWD_VLAN_DROP_VID)) ||
|
||||
(!(msg->fw_key) &&
|
||||
(ipcom_fw->rule_flags[ipprt] & IPCOM_FWD_VLAN_DROP_NO_VID)) ||
|
||||
(msg->stci & 0x0FFF))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, fw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(msg->fw_key))
|
||||
{
|
||||
msg->fw_key = ipcom_fw->hw_pvid[ipprt];
|
||||
msg->ctci |= ipcom_fw->hw_pvid[ipprt];
|
||||
if (msg->pkt_flags & IPCOM_FWD_VLAN_PKT_CVTAG)
|
||||
*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ) = ip_htons(msg->ctci);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_sc_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on an SC port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_sc_rx(void *packet, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
|
||||
/* record pkt flags */
|
||||
msg->pkt_flags = IPCOM_FWD_VLAN_PKT_SVTAG |
|
||||
IS_MCAST(msg->packet) | IS_BCAST(msg->packet);
|
||||
|
||||
/* re-format the cache hash key */
|
||||
msg->stci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
msg->fw_key = msg->stci & 0x0fff;
|
||||
|
||||
/* record C-VLAN */
|
||||
if (*(Ip_u16 *)(msg->packet+LL_ETH_ADDRS_VLAN_SZ) == ETH_FRAME_C_VLAN)
|
||||
{
|
||||
msg->ctci = ip_ntohs(*(Ip_u16 *)(msg->packet + LL_ETH_HDR_VLAN_SZ));
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
}
|
||||
else
|
||||
msg->ctci = ipcom_fw->hw_pvid[msg->ipprt];
|
||||
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[msg->ipprt]&IPCOM_FWD_VLAN_DROP_VID)) ||
|
||||
!(msg->fw_key))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, fw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SVLAN_SC_FWD_TABLE
|
||||
msg->fw_key ^= ipcom_svlan_reverse(msg->ctci & 0x0fff);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_svlan_s_rx
|
||||
*===========================================================================
|
||||
* Description: Process a pkt received on an S port.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
* 1: pkt processed successfully, contiune
|
||||
* 0: pkt dopped, exit
|
||||
*
|
||||
*/
|
||||
IP_STATIC __inline__ int
|
||||
ipcom_svlan_s_rx(void *packet, fw_msg_t *msg, Ip_u8 ipprt, void *fw)
|
||||
{
|
||||
/* Set the pkt type to be VLAN STACKING */
|
||||
msg->tbl[0] = IPCOM_FORWARDER_PACKET_TYPE_VLAN;
|
||||
|
||||
/* Record pkt flags */
|
||||
msg->pkt_flags = IPCOM_FWD_VLAN_PKT_SVTAG |
|
||||
IS_MCAST(msg->packet) | IS_BCAST(msg->packet);
|
||||
|
||||
if (*(Ip_u16 *)(msg->packet + LL_ETH_ADDRS_VLAN_SZ) == ETH_FRAME_C_VLAN)
|
||||
msg->pkt_flags |= IPCOM_FWD_VLAN_PKT_CVTAG;
|
||||
|
||||
/* re-format the cache hash key */
|
||||
msg->stci = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ));
|
||||
msg->fw_key = ip_ntohs(*(Ip_u16 *)(msg->packet+LL_ETH_HDR_SZ)) & 0x0fff;
|
||||
|
||||
if ((msg->fw_key &&
|
||||
(ipcom_fw->rule_flags[msg->ipprt]&IPCOM_FWD_VLAN_DROP_VID)) ||
|
||||
!(msg->fw_key))
|
||||
{
|
||||
ipcom_forwarder_drop_fw_msg(msg, fw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_VXWORKS_NEHALEM_SVLAN_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_vxworks_p4080_portal.h,v $ $Revision: 1.1.12.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_vxworks_p4080_portal.h,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:15 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_VXWORKS_P4080_PORTAL_H
|
||||
#define IPCOM_VXWORKS_P4080_PORTAL_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_config.h>
|
||||
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_FQ_PER_PORT (8) /* RIME: must be a power of two */
|
||||
#define IPCOM_FQ_PER_PORT_BASE (0x80)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipcom_p4080_cookie_s
|
||||
{
|
||||
fw_msg_t fw_msg;
|
||||
|
||||
QPORTAL *qportal;
|
||||
BPORTAL *bportal;
|
||||
|
||||
struct
|
||||
{
|
||||
QPORTAL_FDESC fd;
|
||||
UINT32 ctxB;
|
||||
UINT32 fqId;
|
||||
UINT16 seqNum;
|
||||
} rx;
|
||||
|
||||
struct
|
||||
{
|
||||
int tx;
|
||||
} tx;
|
||||
|
||||
int sock;
|
||||
int cpuId;
|
||||
int index;
|
||||
Ip_u32 p2g;
|
||||
void *msg_sync;
|
||||
|
||||
} Ipcom_p4080_cookie_t;
|
||||
|
||||
#define SH_PORTALS_VALID (0xaabbccdd)
|
||||
|
||||
typedef struct shared_portals_s
|
||||
{
|
||||
Ip_u32 valid;
|
||||
Ip_u32 n_portals;
|
||||
Ip_u32 packet_p2g;
|
||||
Ip_u32 align[64 / sizeof(Ip_u32) - 3];
|
||||
BPORTAL bportal[10];
|
||||
QPORTAL qportal[10];
|
||||
|
||||
} shared_portals_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 GLOBAL DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
IP_EXTERN Ipcom_p4080_cookie_t ipcom_p4080_cookie[];
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPCOM_VXWORKS_P4080_FORWARDER_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_windview.h,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/include/ipcom_windview.h,v $
|
||||
* $Author: hxie $ $Date: 2010-09-16 03:36:17 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Markus Carlstedt <markus@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPCOM_WINDVIEW_H
|
||||
#define IPCOM_WINDVIEW_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Class definitions
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETD_IP4_DATAPATH_EVENT 0x00000008 /* IPv4 Data Path Events */
|
||||
#define IPCOM_WV_NETD_IP6_DATAPATH_EVENT 0x00000010 /* IPv6 Data Path Events */
|
||||
#define IPCOM_WV_NETD_IP4_CTRLPATH_EVENT 0x00000018 /* IPv4 Control Path Events */
|
||||
#define IPCOM_WV_NETD_IP6_CTRLPATH_EVENT 0x00000020 /* IPv6 Control Path Events */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Event Level
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETD_FATAL 1
|
||||
#define IPCOM_WV_NETD_CRITICAL 2
|
||||
#define IPCOM_WV_NETD_WARNING 3
|
||||
#define IPCOM_WV_NETD_INFO 4
|
||||
#define IPCOM_WV_NETD_VERBOSE 5
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Data transfer status
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETD_SEND 1
|
||||
#define IPCOM_WV_NETD_RECV 2
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Event Id
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETDEVENT_FATAL 20400
|
||||
#define IPCOM_WV_NETDEVENT_CRITICAL 20415
|
||||
#define IPCOM_WV_NETDEVENT_WARNING 20430
|
||||
#define IPCOM_WV_NETDEVENT_INFO 20445
|
||||
#define IPCOM_WV_NETDEVENT_START 20460
|
||||
#define IPCOM_WV_NETDEVENT_FINISH 20475
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Qualifier
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETD_BADLEN 1
|
||||
#define IPCOM_WV_NETD_BADSUM 2
|
||||
#define IPCOM_WV_NETD_BADADDR 3
|
||||
#define IPCOM_WV_NETD_BADSOCK 4
|
||||
#define IPCOM_WV_NETD_BADSIZE 5
|
||||
#define IPCOM_WV_NETD_BADHLEN 6
|
||||
#define IPCOM_WV_NETD_BADWIDTH 7
|
||||
#define IPCOM_WV_NETD_BADOPT 8
|
||||
#define IPCOM_WV_NETD_BADVERS 9
|
||||
#define IPCOM_WV_NETD_BADMBLK 10
|
||||
#define IPCOM_WV_NETD_BADLEVEL 11
|
||||
#define IPCOM_WV_NETD_BADROUTE 12
|
||||
#define IPCOM_WV_NETD_BADREFCNT 13
|
||||
#define IPCOM_WV_NETD_BADSYNC 14
|
||||
#define IPCOM_WV_NETD_NOROUTEKEY 15
|
||||
#define IPCOM_WV_NETD_NOROUTE 16
|
||||
#define IPCOM_WV_NETD_NOPCB 17
|
||||
#define IPCOM_WV_NETD_NOPROTO 18
|
||||
#define IPCOM_WV_NETD_SHORTMSG 19
|
||||
#define IPCOM_WV_NETD_BADFLAGS 20
|
||||
#define IPCOM_WV_NETD_NOMEM 21
|
||||
#define IPCOM_WV_NETD_NOSOCK 22
|
||||
#define IPCOM_WV_NETD_BADBUF 23
|
||||
#define IPCOM_WV_NETD_SEMTKFAILED 24
|
||||
#define IPCOM_WV_NETD_NOFDREF 25
|
||||
#define IPCOM_WV_NETD_BADGATEWAY 26
|
||||
#define IPCOM_WV_NETD_UNREACH 27
|
||||
#define IPCOM_WV_NETD_BADTYPE 28
|
||||
#define IPCOM_WV_NETD_BADRULE 29
|
||||
#define IPCOM_WV_NETD_SHORTBUF 30
|
||||
#define IPCOM_WV_NETD_NOHDR 31
|
||||
#define IPCOM_WV_NETD_INVALIDPARENT 32
|
||||
#define IPCOM_WV_NETD_NOUSRREQS 33
|
||||
#define IPCOM_WV_NETD_BADARG 34
|
||||
#define IPCOM_WV_NETD_OUTOFDATA 35
|
||||
#define IPCOM_WV_NETD_BADCHAIN 36
|
||||
#define IPCOM_WV_NETD_INVAL 37
|
||||
#define IPCOM_WV_NETD_RETRANSMITPENDING 38
|
||||
#define IPCOM_WV_NETD_NOGATEWAY 39
|
||||
#define IPCOM_WV_NETD_NOBUFS 40
|
||||
#define IPCOM_WV_NETD_BADOFFSET 41
|
||||
#define IPCOM_WV_NETD_AFNOSUPPORT 42
|
||||
#define IPCOM_WV_NETD_ADDRNOTAVAIL 43
|
||||
#define IPCOM_WV_NETD_ADDRINUSE 44
|
||||
#define IPCOM_WV_NETD_NXIO 45
|
||||
#define IPCOM_WV_NETD_OPNOTSUPP 46
|
||||
#define IPCOM_WV_NETD_NETDOWN 47
|
||||
#define IPCOM_WV_NETD_HOSTUNREACH 48
|
||||
#define IPCOM_WV_NETD_NETUNREACH 49
|
||||
#define IPCOM_WV_NETD_ACCES 50
|
||||
#define IPCOM_WV_NETD_MSGSIZE 51
|
||||
#define IPCOM_WV_NETD_NOPROTOOPT 52
|
||||
#define IPCOM_WV_NETD_PKTLOST 53
|
||||
#define IPCOM_WV_NETD_NOPORT 54
|
||||
#define IPCOM_WV_NETD_FULLSOCK 55
|
||||
#define IPCOM_WV_NETD_RTCLONE 56
|
||||
#define IPCOM_WV_NETD_RTSEARCHGOOD 57
|
||||
#define IPCOM_WV_NETD_SEARCHFAILED 58
|
||||
#define IPCOM_WV_NETD_BADQUERY 59
|
||||
#define IPCOM_WV_NETD_BADREPORT 60
|
||||
#define IPCOM_WV_NETD_DUPLICATED 61
|
||||
#define IPCOM_WV_NETD_OPSFAILED 62
|
||||
#define IPCOM_WV_NETD_LOCKFAILED 63
|
||||
#define IPCOM_WV_NETD_UNLOCKFAILED 64
|
||||
#define IPCOM_WV_NETD_BADMASK 65
|
||||
#define IPCOM_WV_NETD_ADDFAILED 66
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Info event subtypes
|
||||
*===========================================================================
|
||||
*/
|
||||
#define IPCOM_WV_NETD_INFO_UP 1
|
||||
#define IPCOM_WV_NETD_INFO_DOWN 2
|
||||
#define IPCOM_WV_NETD_INFO_OPEN 3
|
||||
#define IPCOM_WV_NETD_INFO_CLOSE 4
|
||||
#define IPCOM_WV_NETD_INFO_SEND 5
|
||||
#define IPCOM_WV_NETD_INFO_RECEIVE 6
|
||||
#define IPCOM_WV_NETD_INFO_ALLOC 7
|
||||
#define IPCOM_WV_NETD_INFO_FREE 8
|
||||
#define IPCOM_WV_NETD_INFO_CONNECT 9
|
||||
#define IPCOM_WV_NETD_INFO_DISCONNECT 10
|
||||
#define IPCOM_WV_NETD_INFO_CREATE 11
|
||||
#define IPCOM_WV_NETD_INFO_DELETE 12
|
||||
#define IPCOM_WV_NETD_INFO_DROPPED 13
|
||||
#define IPCOM_WV_NETD_INFO_RETRANSMIT 14
|
||||
#define IPCOM_WV_NETD_INFO_TIMEOUT 15
|
||||
#define IPCOM_WV_NETD_INFO_EXPIRED 16
|
||||
#define IPCOM_WV_NETD_INFO_UPDATED 17
|
||||
#define IPCOM_WV_NETD_INFO_QUEUE_FULL 18
|
||||
#define IPCOM_WV_NETD_INFO_PKT_SEND 19
|
||||
#define IPCOM_WV_NETD_INFO_PKT_RECV 20
|
||||
#define IPCOM_WV_NETD_INFO_RESET 21
|
||||
#define IPCOM_WV_NETD_INFO_WAIT 22
|
||||
#define IPCOM_WV_NETD_INFO_NODEADD 23
|
||||
#define IPCOM_WV_NETD_INFO_RTADDED 24
|
||||
#define IPCOM_WV_NETD_INFO_RTCLONE 25
|
||||
#define IPCOM_WV_NETD_INFO_RTALLOC 26
|
||||
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_1 27
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_2 28
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_3 29
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_4 30
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_5 31
|
||||
#define IPCOM_WV_NETD_INFO_CUSTOM_6 32
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Module identifiers
|
||||
*===========================================================================
|
||||
* Represented by an 8-bit field in wvNetDEventInfo. Use codes 0-127 for
|
||||
* dual stack. Use codes 128-255 for Interpeak.
|
||||
*/
|
||||
#define IPCOM_WV_IPNET_MODULE 128 /* ipnet.c source file */
|
||||
#define IPCOM_WV_IPNET_NETIF_MODULE 129 /* ipnet_netif.c source file */
|
||||
#define IPCOM_WV_IPNET_IP4_MODULE 130 /* ipnet_ip4.c source file */
|
||||
#define IPCOM_WV_IPNET_IP6_MODULE 131 /* ipnet_ip6.c source file */
|
||||
#define IPCOM_WV_IPNET_SOCK_TCP_MODULE 132 /* ipnet_sock_tcp.c source file */
|
||||
#define IPCOM_WV_IPNET_UDP_MODULE 133 /* ipnet_udp.c source file */
|
||||
#define IPCOM_WV_IPNET_ETH_MODULE 134 /* ipnet_eth.c source file */
|
||||
#define IPCOM_WV_IPNET_FRAG_MODULE 135 /* ipnet_frag.c source file */
|
||||
#define IPCOM_WV_IPNET_ICMP6_MODULE 136 /* ipnet_icmp6.c source file */
|
||||
#define IPCOM_WV_IPNET_NEIGH_MODULE 137 /* ipnet_neigh.c source file */
|
||||
#define IPCOM_WV_IPNET_PKT_POOL_MODULE 138 /* ipnet_pkt_pool.c source file */
|
||||
#define IPCOM_WV_IPNET_RAW_MODULE 139 /* ipnet_raw.c source file */
|
||||
#define IPCOM_WV_IPNET_SOCK_MODULE 140 /* ipnet_sock.c source file */
|
||||
#define IPCOM_WV_IPNET_TUNNEL_MODULE 141 /* ipnet_tunnel.c source file */
|
||||
#define IPCOM_WV_IPTCP_MODULE 142 /* iptcp.c source file */
|
||||
#define IPCOM_WV_IPSCTP_INPUT_MODULE 143 /* ipsctp_input.c source file */
|
||||
#define IPCOM_WV_IPLITE_TCP_MODULE 144 /* iplite_tcp.c source file */
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* Entity
|
||||
*===========================================================================
|
||||
* Represented by an 8-bit field in wvNetDEventInfo.
|
||||
*/
|
||||
#define IPCOM_WV_NETD_ARP 1
|
||||
#define IPCOM_WV_NETD_ICMP4 2
|
||||
#define IPCOM_WV_NETD_ICMP6 3
|
||||
#define IPCOM_WV_NETD_IP4 4
|
||||
#define IPCOM_WV_NETD_IP6 5
|
||||
#define IPCOM_WV_NETD_RAWIP 6
|
||||
#define IPCOM_WV_NETD_ROUTE 7
|
||||
#define IPCOM_WV_NETD_TCP4 8
|
||||
#define IPCOM_WV_NETD_TCP6 9
|
||||
#define IPCOM_WV_NETD_UDP4 10
|
||||
#define IPCOM_WV_NETD_UDP6 11
|
||||
#define IPCOM_WV_NETD_IF 12
|
||||
#define IPCOM_WV_NETD_SOCKET 13
|
||||
#define IPCOM_WV_NETD_IGMP 14
|
||||
#define IPCOM_WV_NETD_NETBUF 15
|
||||
#define IPCOM_WV_NETD_MEMBUF 16
|
||||
#define IPCOM_WV_NETD_PACKET 17
|
||||
#define IPCOM_WV_NETD_RAW_SOCKET 18
|
||||
#define IPCOM_WV_NETD_IP_REASSEMBLE 19
|
||||
#define IPCOM_WV_NETD_TCP_REASSMBLE 20
|
||||
#define IPCOM_WV_NETD_DLINK 21
|
||||
#define IPCOM_WV_NETD_ND 22
|
||||
#define IPCOM_WV_NETD_SCTP4 23
|
||||
#define IPCOM_WV_NETD_SCTP6 24
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipcom_cmd_wvnet(int argc, char **argv);
|
||||
IP_PUBLIC void ipcom_wv_marker_1(Ip_u32 classId, Ip_u32 eventLevel, Ip_u32 eventOffset, Ip_u32 eventTag,
|
||||
Ip_u32 eventId, void *arg1, Ip_u8 module, Ip_u8 entity);
|
||||
IP_PUBLIC void ipcom_wv_marker_2(Ip_u32 classId, Ip_u32 eventLevel, Ip_u32 eventOffset, Ip_u32 eventTag,
|
||||
Ip_u32 eventId, void *arg1, int arg2, Ip_u8 module, Ip_u8 entity);
|
||||
IP_PUBLIC void ipcom_wv_event_2(Ip_u32 classId, Ip_u32 eventLevel, Ip_u32 eventOffset, Ip_u32 eventTag,
|
||||
Ip_u32 eventId, Ip_u32 status, void *arg1, int arg2, Ip_u8 module, Ip_u8 entity);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef IPCOM_WINDVIEW_H */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,104 @@
|
||||
/* zbufLib.h - zeroCopy buffer interface library header */
|
||||
|
||||
/*
|
||||
* Copyright 1984-2006,2008 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01g,28jan08,aes complete revamp. Using Ipcom_pkt instead of mbuf.
|
||||
01c,20jun06,jpb Removed I960 check
|
||||
01b,17mar04,rp updated to build for 5.5
|
||||
01a,19nov02,nee Ported to Accordion from ""zbufLib.h@@/main/1 from view tor3_x/tor3_x.synth".
|
||||
*/
|
||||
|
||||
#ifndef __INCzbufLibh
|
||||
#define __INCzbufLibh
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <semLib.h>
|
||||
#include <intLib.h>
|
||||
|
||||
#include <ipcom_pkt.h>
|
||||
#include <ipcom_netif.h>
|
||||
|
||||
/* typedefs */
|
||||
|
||||
typedef int ZBUF_ID;
|
||||
typedef Ipcom_pkt* ZBUF_SEG;
|
||||
|
||||
/* status codes */
|
||||
#define S_zbufLib_ID_INVALID (M_mbufLib | 1)
|
||||
#define S_zbufLib_ID_EMPTY (M_mbufLib | 2)
|
||||
#define S_zbufLib_SEGMENT_NOT_FOUND (M_mbufLib | 3)
|
||||
#define S_zbufLib_LENGTH_INVALID (M_mbufLib | 4)
|
||||
#define S_zbufLib_OFFSET_INVALID (M_mbufLib | 5)
|
||||
|
||||
|
||||
/* defines */
|
||||
#define ZBUF_BEGIN -INT_MAX /* shortcut for prepending */
|
||||
#define ZBUF_END INT_MAX /* shortcut for appending */
|
||||
#define ZBUF_NONE ((ZBUF_SEG) NONE) /* cut past zbuf */
|
||||
|
||||
/* function declarations */
|
||||
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
extern STATUS zbufLibInit (FUNCPTR libInitRtn);
|
||||
extern ZBUF_ID zbufCreate (void);
|
||||
extern STATUS zbufDelete (ZBUF_ID zbufId);
|
||||
extern ZBUF_SEG zbufInsert (ZBUF_ID zbufId1, ZBUF_SEG zbufSeg, int offset,
|
||||
ZBUF_ID zbufId2);
|
||||
extern ZBUF_SEG zbufInsertBuf (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int offset,
|
||||
caddr_t buf, int len, VOIDFUNCPTR freeRtn, int freeArg);
|
||||
extern ZBUF_SEG zbufInsertBuf64 (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int offset,
|
||||
caddr_t buf, int len, VOIDFUNCPTR freeRtn, void *freeArg);
|
||||
extern ZBUF_SEG zbufInsertCopy (ZBUF_ID zbufId, ZBUF_SEG zbufSeg,
|
||||
int offset, caddr_t buf, int len);
|
||||
extern int zbufExtractCopy (ZBUF_ID zbufId, ZBUF_SEG zbufSeg,
|
||||
int offset, caddr_t buf, int len);
|
||||
extern ZBUF_SEG zbufCut (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int offset, int len);
|
||||
extern ZBUF_ID zbufSplit (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int offset);
|
||||
extern ZBUF_ID zbufDup (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int offset, int len);
|
||||
extern int zbufLength (ZBUF_ID zbufId);
|
||||
extern ZBUF_SEG zbufSegFind (ZBUF_ID zbufId, ZBUF_SEG zbufSeg, int *pOffset);
|
||||
extern ZBUF_SEG zbufSegNext (ZBUF_ID zbufId, ZBUF_SEG zbufSeg);
|
||||
extern ZBUF_SEG zbufSegPrev (ZBUF_ID zbufId, ZBUF_SEG zbufSeg);
|
||||
extern caddr_t zbufSegData (ZBUF_ID zbufId, ZBUF_SEG zbufSeg);
|
||||
extern int zbufSegLength (ZBUF_ID zbufId, ZBUF_SEG zbufSeg);
|
||||
|
||||
#else /* __STDC__ */
|
||||
|
||||
extern STATUS zbufLibInit ();
|
||||
extern ZBUF_ID zbufCreate ();
|
||||
extern STATUS zbufDelete ();
|
||||
extern ZBUF_SEG zbufInsert ();
|
||||
extern ZBUF_SEG zbufInsertBuf ();
|
||||
extern ZBUF_SEG zbufInsertCopy ();
|
||||
extern int zbufExtractCopy ();
|
||||
extern ZBUF_SEG zbufCut ();
|
||||
extern ZBUF_ID zbufSplit ();
|
||||
extern ZBUF_ID zbufDup ();
|
||||
extern int zbufLength ();
|
||||
extern ZBUF_SEG zbufSegFind ();
|
||||
extern ZBUF_SEG zbufSegNext ();
|
||||
extern ZBUF_SEG zbufSegPrev ();
|
||||
extern caddr_t zbufSegData ();
|
||||
extern int zbufSegLength ();
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCzbufLibh */
|
||||
@@ -0,0 +1,59 @@
|
||||
/* zbufSockLib.h - zeroCopy buffer socket interface library header */
|
||||
|
||||
/*
|
||||
* Copyright 1984-2006, 2008, 2015 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
08nov15,dlk Establish struct sockaddr in scope outside parameter list.
|
||||
28jan08,aes complete revamp. Using Ipcom_pkt instead of mbuf.
|
||||
20jun06,jpb Removed I960 check
|
||||
04nov03,rlm Ran batch header path update for header re-org.
|
||||
03nov03,rlm Removed wrn/coreip/ prefix from #includes for header re-org.
|
||||
19nov02,nee Ported to Accordion from ""zbufSockLib.h@@/main/1 from view tor3_x/tor3_x.synth".
|
||||
*/
|
||||
|
||||
#ifndef __INCzbufSockLibh
|
||||
#define __INCzbufSockLibh
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* includes */
|
||||
#include "zbufLib.h"
|
||||
|
||||
struct sockaddr; /* establish scope outside parameter list */
|
||||
|
||||
/* function declarations */
|
||||
|
||||
extern STATUS zbufSockLibInit (void);
|
||||
extern int zbufSockSend (int s, ZBUF_ID zbufId, int zbufLen, int flags);
|
||||
extern int zbufSockSendto (int s, ZBUF_ID zbufId, int zbufLen, int flags,
|
||||
struct sockaddr *to, int tolen);
|
||||
extern int zbufSockBufSend (int s, char *buf, int bufLen,
|
||||
VOIDFUNCPTR freeRtn, int freeArg, int flags);
|
||||
extern int zbufSockBufSend64 (int s, char *buf, int bufLen,
|
||||
VOIDFUNCPTR freeRtn, void *freeArg, int flags);
|
||||
extern int zbufSockBufSendto (int s, char *buf, int bufLen,
|
||||
VOIDFUNCPTR freeRtn, int freeArg, int flags,
|
||||
struct sockaddr *to, int tolen);
|
||||
extern int zbufSockBufSendto64 (int s, char *buf, int bufLen,
|
||||
VOIDFUNCPTR freeRtn, void *freeArg, int flags,
|
||||
struct sockaddr *to, int tolen);
|
||||
extern ZBUF_ID zbufSockRecv (int s, int flags, int *pLen);
|
||||
extern ZBUF_ID zbufSockRecvfrom (int s, int flags, int *pLen,
|
||||
struct sockaddr *from, int *pFromLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCzbufSockLibh */
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
/* 00comp_envoy_snmp_core.cdf - Component configuration file */
|
||||
|
||||
/*
|
||||
* Copyright 1984-2007, 2020 Wind River Systems, Inc.
|
||||
* All rights reserved. Provided under license only.
|
||||
* Distribution or other use of this software is only
|
||||
* permitted pursuant to the terms of a license agreement
|
||||
* from Wind River Systems (and is otherwise prohibited).
|
||||
* Refer to that license agreement for terms of use.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Log: 00comp_envoy_snmp_core.cdf,v $
|
||||
* Revision 1.3.60.1 2020-03-11 03:27:43 rzhang3
|
||||
* add simultaneous connections limit for AgentX (VXW6-87209)
|
||||
*
|
||||
* Revision 1.3 2009-09-15 07:21:45 ytang
|
||||
* snmp cdf files
|
||||
*
|
||||
* Revision 1.1 2002/06/17 16:16:08 meister
|
||||
* versions of these files for Tornado 2.2, which does not have an
|
||||
* INCLUDE_ANSI_STDLIB_ATOL component
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01f,09mar20,rza add simultaneous connections limit for AgentX (VXW6-87209)
|
||||
01e,08jul08,y_t Removed REQUIRES INCLUDE_IPNET_PACKET_POOL_3
|
||||
01d,06may08,zhr Added SNMP_USE_M2LIB for m2Lib migration to ipnet
|
||||
01c,16aug06,mze reduce MODULES to wrsnmp_config.o from the previous list
|
||||
01b,07jul06,msa Add RFC4293 support and remove obsolete files.
|
||||
01a,02dec03,job update copyright information
|
||||
*/
|
||||
|
||||
/*
|
||||
* Old revision history, from similar file in ../t2_cdf:
|
||||
* Revision 1.5 2002/06/04 17:54:56 josh
|
||||
* none of the vxWorks builds require COMMON_STRICMP or
|
||||
* COMMON_STRNICMP to be installed
|
||||
*
|
||||
* Revision 1.4 2002/01/07 22:35:48 meister
|
||||
* add PROTOTYPE fields for t2 components
|
||||
*
|
||||
* Revision 1.3 2001/12/04 16:27:08 meister
|
||||
* remove epilogue subagent from CDF
|
||||
*
|
||||
* Revision 1.2 2001/11/13 16:47:20 meister
|
||||
* Get rid of obsolete cdf's that came back in the shuffle.
|
||||
*
|
||||
* Revision 1.1.1.1 2001/11/05 17:47:54 tneale
|
||||
* Tornado shuffle
|
||||
*
|
||||
* Revision 1.1.2.2 2001/10/31 18:56:19 meister
|
||||
* Fold common library into snmo core.
|
||||
* Fold des library into V3 core.
|
||||
*
|
||||
* Revision 1.1.2.5 2001/10/23 17:19:37 meister
|
||||
* there is a limitation that modules can only appear in a single CDF file.
|
||||
* this forces the SNMP core to be slpit into two component modules.
|
||||
*
|
||||
* Revision 1.1.2.4 2001/10/18 19:59:52 meister
|
||||
* ENVOY --> WINDMANAGE
|
||||
*
|
||||
* Revision 1.1.2.3 2001/09/27 01:04:00 meister
|
||||
* More rearrangement ; splitting out coexistence/proxy
|
||||
*
|
||||
* Revision 1.1.2.2 2001/09/20 19:43:56 meister
|
||||
* Fix typo
|
||||
*
|
||||
* Revision 1.1.2.1 2001/09/20 17:18:18 meister
|
||||
* component description files for vxworks snmpd components (tae)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
DESCRIPTION
|
||||
This file contains descriptions for the envoy AgentX subagent.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* as a quickie, just export all global symbls as entry points for now.
|
||||
* FIXME Fix this later.
|
||||
*/
|
||||
|
||||
Component INCLUDE_WINDMANAGE_SNMP_CORE {
|
||||
NAME Wind River SNMP Core Library
|
||||
SYNOPSIS Wind River SNMP Core Library
|
||||
CONFIGLETTES net/usrSnmp.c
|
||||
INIT_RTN usrSnmpCfgInit();
|
||||
MODULES wrsnmp_config.o
|
||||
PROTOTYPE void initSnmpd(void);
|
||||
CFG_PARAMS SNMP_USE_M2LIB \
|
||||
SNMP_AGENTX_MAX_SESSIONS
|
||||
}
|
||||
|
||||
Parameter SNMP_USE_M2LIB {
|
||||
NAME SNMP uses m2Lib
|
||||
SYNOPSIS static rfc1213 mib2 supported by m2Lib is used
|
||||
TYPE BOOL
|
||||
DEFAULT FALSE
|
||||
}
|
||||
|
||||
Parameter SNMP_AGENTX_MAX_SESSIONS {
|
||||
NAME Maximum number of simultaneous agentX sessions
|
||||
SYNOPSIS This parameter specifies the maximum number of \
|
||||
simultaneous agentX sessions
|
||||
TYPE int
|
||||
DEFAULT 20
|
||||
}
|
||||
|
||||
|
||||
/* MODULES asy_util.o \
|
||||
buildpkt.o \
|
||||
snmpEBuffer.o \
|
||||
cmn_init.o \
|
||||
snmpBerDecode.o \
|
||||
dyncfgvx.o \
|
||||
snmpBerEncode.o \
|
||||
env_init.o \
|
||||
etimerin.o \
|
||||
etimer.o \
|
||||
localio.o \
|
||||
mibutils.o \
|
||||
mib_next.o \
|
||||
mib_fon.o \
|
||||
null_tas.o \
|
||||
null_sas.o \
|
||||
objectid.o \
|
||||
oidcmp2.o \
|
||||
row_get.o \
|
||||
tree.o \
|
||||
vb_rtns.o \
|
||||
view_chk.o \
|
||||
asy_back.o \
|
||||
bindint.o \
|
||||
bindip.o \
|
||||
bindnull.o \
|
||||
bindoid.o \
|
||||
bindstr.o \
|
||||
bindui64.o \
|
||||
binduint.o \
|
||||
creatint.o \
|
||||
creatrap.o \
|
||||
creatreq.o \
|
||||
etimerin.o \
|
||||
exist_as.o \
|
||||
exists.o \
|
||||
gas_incr.o \
|
||||
gas_int.o \
|
||||
gas_ip.o \
|
||||
gas_oid.o \
|
||||
gas_str.o \
|
||||
gas_ui64.o \
|
||||
gas_uint.o \
|
||||
gas_ulng.o \
|
||||
get_int.o \
|
||||
get_ip.o \
|
||||
get_oid.o \
|
||||
get_str.o \
|
||||
get_ui64.o \
|
||||
get_uint.o \
|
||||
get_ulng.o \
|
||||
getpdu.o \
|
||||
ip2llist.o \
|
||||
ip2rlist.o \
|
||||
llistcmp.o \
|
||||
localio.o \
|
||||
nextpdu.o \
|
||||
null_gas.o \
|
||||
null_get.o \
|
||||
null_nas.o \
|
||||
null_nxt.o \
|
||||
null_set.o \
|
||||
null_tst.o \
|
||||
oid2ip.o \
|
||||
oid2str.o \
|
||||
oidcmp.o \
|
||||
oidorder.o \
|
||||
rcv_pkt.o \
|
||||
row.o \
|
||||
rowloose.o \
|
||||
rpktasy.o \
|
||||
sas_incr.o \
|
||||
sas_int.o \
|
||||
sas_ui64.o \
|
||||
sas_uint.o \
|
||||
scan_loc.o \
|
||||
serial.o \
|
||||
set_int.o \
|
||||
set_ui64.o \
|
||||
set_uint.o \
|
||||
setpdu.o \
|
||||
snmp_d.o \
|
||||
snmp_e.o \
|
||||
view_rts.o \
|
||||
vmth2275.o \
|
||||
weakprng.o \
|
||||
fixed64.o \
|
||||
icmp4293_mib.o \
|
||||
icmp4293_mth.o \
|
||||
if_mib.o \
|
||||
if_mth.o \
|
||||
ip4293_mib.o \
|
||||
ip4293_mth.o \
|
||||
iprt_mth.o \
|
||||
tcp_mib.o \
|
||||
tcp_mth.o \
|
||||
udp_mib.o \
|
||||
udp_mth.o \
|
||||
wrsnmp_config.o
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_atomic.c,v $ $Revision: 1.4.26.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_atomic.c,v $
|
||||
* $Author: hchu0 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
Mapping of the IPCOM atomic operation to VxWorks
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_atomic.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_type.h>
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <vxAtomicLib.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if !defined( __GNUC__) || defined (IPARCH_arm)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_atomic_get(Ipcom_atomic_t *v)
|
||||
{
|
||||
return vxAtomic32Get_inline((atomic32_t *) v);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_set
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_atomic_set(Ipcom_atomic_t *v, int i)
|
||||
{
|
||||
(void) vxAtomic32Set_inline((atomic32_t *) v, i);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_ptr_cas
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_bool
|
||||
ipcom_atomic_ptr_cas(Ip_ptrdiff_t *v, Ip_ptrdiff_t old_v, Ip_ptrdiff_t new_v)
|
||||
{
|
||||
return vxAtomicCas_inline((atomic_t *) v, old_v, new_v);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_add
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_atomic_add(Ipcom_atomic_t *v, int i)
|
||||
{
|
||||
(void) vxAtomic32Add_inline((atomic32_t *) v, i);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_add_and_return
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_atomic_add_and_return(Ipcom_atomic_t *v, int i)
|
||||
{
|
||||
return vxAtomic32Add_inline((atomic32_t *) v, i) + i;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_inc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipcom_atomic_inc(Ipcom_atomic_t *v)
|
||||
{
|
||||
(void) vxAtomic32Inc_inline((atomic32_t *) v);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_dec
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipcom_atomic_dec(Ipcom_atomic_t *v)
|
||||
{
|
||||
(void) vxAtomic32Dec_inline((atomic32_t *) v);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_sub
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_atomic_sub(Ipcom_atomic_t *v, int i)
|
||||
{
|
||||
(void) vxAtomic32Sub_inline((atomic32_t *) v, i);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_atomic_sub_and_return
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_atomic_sub_and_return(Ipcom_atomic_t *v, int i)
|
||||
{
|
||||
return vxAtomic32Sub_inline((atomic32_t *) v, i) - i;
|
||||
}
|
||||
#else /* __GNUC__ */
|
||||
int ipcom_empty_atomic_file;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ccivalidate.c,v $ $Revision: 1.7 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_ccivalidate.c,v $
|
||||
* $Author: braghava $ $Date: 2007-10-04 06:33:42 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_ccivalidate.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_cmd_wvnet
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*/
|
||||
#ifdef IPCOM_CCIVALIDATE_TEST
|
||||
|
||||
#include "cci.h"
|
||||
|
||||
IP_GLOBAL int
|
||||
ipcom_cmd_ccivalidate(int argc, char **argv)
|
||||
{
|
||||
int provider_num = 0, ret = 0;
|
||||
/* Validate arguments */
|
||||
if (argc != 2)
|
||||
{
|
||||
ipcom_printf("Usage: ccivalidate <provider>. 0 is the default provider. \n");
|
||||
return -1;
|
||||
}
|
||||
provider_num=atoi(argv[1]);
|
||||
ret=cciProviderValidate(provider_num);
|
||||
|
||||
/* Check return values of cciProviderValidate*/
|
||||
if(ret == CCI_SUCCESS)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif /* IPCOM_CCIVALIDATE_TEST */
|
||||
|
||||
|
||||
#ifdef IPCOM_CCIPERFORMANCE_TEST
|
||||
|
||||
#include "cci.h"
|
||||
|
||||
IP_GLOBAL int
|
||||
ipcom_cmd_cciperformance(int argc, char **argv)
|
||||
{
|
||||
int provider_num = 0, ret = 0;
|
||||
/* Validate arguments */
|
||||
if (argc != 2)
|
||||
{
|
||||
ipcom_printf("Usage: cciperf <provider>. 0 is the default provider. \n");
|
||||
return -1;
|
||||
}
|
||||
provider_num=atoi(argv[1]);
|
||||
|
||||
ret=cciLibUnInit();
|
||||
|
||||
if(ret != CCI_SUCCESS)
|
||||
return -1;
|
||||
|
||||
cciSharedRegionSet(8192000);
|
||||
|
||||
ret=cciLibInit();
|
||||
|
||||
if(ret != CCI_SUCCESS)
|
||||
return -1;
|
||||
|
||||
ret=cciProviderBenchmark(provider_num);
|
||||
|
||||
/* Check return values of cciProviderValidate*/
|
||||
if(ret == CCI_SUCCESS)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#endif /* IPCOM_CCIPERFORMANCE_TEST */
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* None as of now
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_cmd_vxshell.c,v $ $Revision: 1.6.82.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_cmd_vxshell.c,v $
|
||||
* $Author: hsun $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM && defined(IPCOM_USE_VXSHELL_CMD)
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_vxworks.h>
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <shellLib.h>
|
||||
#include <wrn/coreip/telnetLib.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipcom_vxshell_session_s
|
||||
{
|
||||
Ipcom_sem shell_exit_sem;
|
||||
|
||||
}
|
||||
Ipcom_vxshell_session_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN int ipcom_windnet_socket_use_existing(Ip_fd fd);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_GLOBAL int ipcom_cmd_vxshell(int argc, char **argv);
|
||||
IP_STATIC void ipcom_vxworks_shell_logout_cb(void *arg);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_vxworks_shell_logout_cb
|
||||
*===========================================================================
|
||||
* Description: Called when VxWorks shell exits.
|
||||
* Parameters: Id of VxWorks shell session
|
||||
* Returns: -
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_vxworks_shell_logout_cb(void *arg)
|
||||
{
|
||||
Ipcom_vxshell_session_t *session;
|
||||
|
||||
session = (Ipcom_vxshell_session_t *) arg;
|
||||
|
||||
ipcom_sem_post(session->shell_exit_sem);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_enter_vxworks_shell
|
||||
*===========================================================================
|
||||
* Description: IP shell command to enter the VxWorks shell. The command blocks
|
||||
* until the VxWorks shell exits
|
||||
* Parameters: Command and arguments (not used)
|
||||
* Returns: 0
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL int
|
||||
ipcom_cmd_vxshell(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
Ipcom_proc *proc;
|
||||
Ipcom_vxshell_session_t session;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
proc = ipcom_proc_find(ipcom_getpid(), IP_FALSE);
|
||||
|
||||
#ifdef IPCOM_USE_NATIVE_SOCK_API
|
||||
fd = proc->shell_fd;
|
||||
#else
|
||||
fd = ipcom_windnet_socket_use_existing(proc->shell_fd);
|
||||
#endif
|
||||
|
||||
ipcom_sem_create(&session.shell_exit_sem, 0);
|
||||
|
||||
if (shellParserControl(REMOTE_START, (unsigned long)&session, fd, ipcom_vxworks_shell_logout_cb) == 0)
|
||||
{
|
||||
ipcom_sem_wait(session.shell_exit_sem);
|
||||
shellParserControl(REMOTE_STOP, (unsigned long)&session, 0, IP_NULL);
|
||||
}
|
||||
|
||||
ipcom_sem_delete(&session.shell_exit_sem);
|
||||
|
||||
#ifndef IPCOM_USE_NATIVE_SOCK_API
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#else
|
||||
int ipcom_cmd_vxshell_empty_file;
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM && defined(IPCOM_USE_VXSHELL_CMD) */
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,744 @@
|
||||
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/* Refer to description above*/
|
||||
#ifdef IPCOM_USE_P4080_FORWARDER
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <vxWorks.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <memLib.h>
|
||||
#include <semLib.h>
|
||||
#include <taskLib.h>
|
||||
#include <vxCpuLib.h>
|
||||
#include <vxBusLib.h>
|
||||
#include <cpuset.h>
|
||||
#include <hwif/vxbus/vxBus.h>
|
||||
#include <hwif/util/vxbParamSys.h>
|
||||
#include <hwif/util/vxbDmaBufLib.h>
|
||||
|
||||
#include <etherMultiLib.h>
|
||||
#include <end.h>
|
||||
#include <endLib.h>
|
||||
#include <muxLib.h>
|
||||
#include <muxTkLib.h>
|
||||
|
||||
#include <../src/hwif/h/resource/vxbQorIQQmanPortal.h>
|
||||
#include <../src/hwif/h/resource/vxbQorIQBmanPortal.h>
|
||||
#include <../src/hwif/h/resource/vxbQorIQFman.h>
|
||||
#include <../src/hwif/h/end/vxbDtsecEnd.h>
|
||||
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <arch/ppc/in_cksum.h>
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_netif.h"
|
||||
#include "ipcom_forwarder.h"
|
||||
#include "ipcom_ifproxy_proto.h"
|
||||
|
||||
#include "ipcom_vxworks_p4080_forwarder.h"
|
||||
#include "ipcom_vxworks_p4080_portal.h"
|
||||
|
||||
#ifdef IPCOM_FORWARDER_AMP
|
||||
#include <ipcom_shared_mem.h>
|
||||
#include <wrhv/vbi.h>
|
||||
#include <multios_ipc/mipc.h>
|
||||
#endif
|
||||
|
||||
#include "ipcom_forwarder_h.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* Defines
|
||||
****************************************************************************
|
||||
*/
|
||||
#define MAX_FWD_COUNT (7)
|
||||
#define SLOW_PKT_HDR_SIZE (0)
|
||||
|
||||
#define IPCOM_FW_MASK(x) (x-1)
|
||||
#define FD_DATA_OFFSET(o) ((o) << 20)
|
||||
#define FMAN_PKT_FWKEY(x) ((UINT32 *)((char *)(x) + (FMAN_PKT_OFF - sizeof(UINT32))))
|
||||
|
||||
#define ipcom_cache_line_size() (64)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* Prototypes
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
IP_EXTERN shared_debug_t *shared_debug;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* Local types
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
|
||||
typedef struct ci_s
|
||||
{
|
||||
Ip_u32 eqcr_pi;
|
||||
Ip_u32 eqcr_ci;
|
||||
Ip_u32 pad1[6 + 8];
|
||||
Ip_u32 dqrr_pi;
|
||||
Ip_u32 dqrr_ci;
|
||||
Ip_u32 pad2[6 + 8];
|
||||
Ip_u32 mr_pi;
|
||||
Ip_u32 mr_ci;
|
||||
Ip_u32 pad3[30];
|
||||
Ip_u32 cfg;;
|
||||
} ci_t;
|
||||
|
||||
typedef struct eq_cmd_s
|
||||
{
|
||||
Ip_u8 verb;
|
||||
Ip_u8 dca;
|
||||
Ip_u16 seq;
|
||||
Ip_u32 orp;
|
||||
Ip_u32 fqid;
|
||||
Ip_u32 tag;
|
||||
|
||||
Ip_u8 liodn;
|
||||
Ip_u8 bpid;
|
||||
Ip_u8 rsv;
|
||||
Ip_u8 hi_addr;
|
||||
Ip_u32 lo_addr;
|
||||
Ip_u32 len;
|
||||
Ip_u32 pad;
|
||||
|
||||
Ip_u32 pad8[8];
|
||||
|
||||
} eq_cmd_t;
|
||||
|
||||
typedef struct dq_rsp_s
|
||||
{
|
||||
Ip_u8 verb;
|
||||
Ip_u8 stat;
|
||||
Ip_u16 seq;
|
||||
Ip_u8 tok;
|
||||
Ip_u8 pad[3];
|
||||
Ip_u32 fqid;
|
||||
Ip_u32 ctx;
|
||||
|
||||
Ip_u8 liodn;
|
||||
Ip_u8 bpid;
|
||||
Ip_u8 rsv;
|
||||
Ip_u8 hi_addr;
|
||||
Ip_u32 lo_addr;
|
||||
Ip_u32 len;
|
||||
Ip_u32 pad0;
|
||||
|
||||
Ip_u32 pad8[8];
|
||||
|
||||
} dq_rsp_t;
|
||||
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* Local variables
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
static int hw_port_cnt = 0;
|
||||
static int schemeIndex = 0;
|
||||
static END_OBJ *hw_port[MAX_FW_PORTS];
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* Local functions
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
/*
|
||||
*===========================================================================
|
||||
* dumpdata
|
||||
*===========================================================================
|
||||
* Context: fwd
|
||||
*/
|
||||
static void
|
||||
dumpdata(void *data, int cnt, int sz)
|
||||
{
|
||||
int i;
|
||||
int o = 0;
|
||||
unsigned int *u = data;
|
||||
unsigned short int *h = data;
|
||||
unsigned char *c = data;
|
||||
|
||||
static char text[400];
|
||||
|
||||
switch(sz)
|
||||
{
|
||||
case 1:
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
o += ipcom_sprintf(text + o, "%s%02x ", (i % 20) ? "" : "\n", c[i]);
|
||||
}
|
||||
o += ipcom_sprintf(text + o, "\n");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
o += ipcom_sprintf(text + o, "%s%04x ", (!i || (i % 20)) ? "" : "\n", h[i]);
|
||||
}
|
||||
o += ipcom_sprintf(text + o, "\n");
|
||||
break;
|
||||
|
||||
case 4:
|
||||
default:
|
||||
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
o += ipcom_sprintf(text + o, "%s%08x ", (i % 10) ? "" : "\n", u[i]);
|
||||
}
|
||||
o += ipcom_sprintf(text + o, "\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (o)
|
||||
ipcom_printf(text);
|
||||
else
|
||||
ipcom_printf("--zero length packet--\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* Published functions
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
/*
|
||||
*===========================================================================
|
||||
* print_qp
|
||||
*===========================================================================
|
||||
* Context: shell
|
||||
* Description: Print Qportal Enqueue and Dequeue FIFOs
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
print_qp(int p)
|
||||
{
|
||||
int i;
|
||||
ci_t *ci;
|
||||
QPORTAL *qp;
|
||||
eq_cmd_t *eq;
|
||||
dq_rsp_t *dq;
|
||||
|
||||
qp = ipcom_p4080_cookie[p].qportal;
|
||||
ci = qp->qportalCiBase;
|
||||
eq = qp->qportalCeBase;
|
||||
dq = (dq_rsp_t *)((Ip_u8 *)qp->qportalCeBase + 0x1000);
|
||||
|
||||
|
||||
ipcom_printf("EQCR: pi=%2d(vp=%d), ci=%2d(vc=%d), valid polarity=%d\n",
|
||||
ci->eqcr_pi & 0x7, (ci->eqcr_pi & 0x8)>>3,
|
||||
ci->eqcr_ci & 0x7, (ci->eqcr_ci & 0x8)>>3);
|
||||
|
||||
for (i = 0; i < 8; i++, eq++)
|
||||
{
|
||||
ipcom_printf("%2d: vb=%2x, seq=%5d, orp=%2d(%2x), bpid=%2x, vaddr=%08x, paddr=%08x, len=%d(%x)%s%s\n", i,
|
||||
eq->verb, eq->seq, eq->orp, eq->orp, eq->bpid,
|
||||
(eq->hi_addr << 24) + eq->lo_addr + ipcom_p4080_cookie[0].p2g,
|
||||
(eq->hi_addr << 24) + eq->lo_addr,
|
||||
eq->len & 0xffff, eq->len & 0xffff,
|
||||
(i == (ci->eqcr_pi & 0x7)) ? " <-- PI " : "",
|
||||
(i == (ci->eqcr_ci & 0x7)) ? " <-- CI " : "");
|
||||
}
|
||||
|
||||
ipcom_printf("DQRR: pi=%2d(vp=%d), ci=%2d(qportalDqVbit=%d)\n",
|
||||
ci->dqrr_pi & 0xf, (ci->dqrr_pi & 0x10) >> 4,
|
||||
ci->dqrr_ci & 0xf, qp->qportalDqVbit);
|
||||
|
||||
for (i = 0; i < 16; i++, dq++)
|
||||
{
|
||||
ipcom_printf("%2d: vb=%2x, seq=%5d, fqid=%2d(%2x), bpid=%2x, vaddr=%08x, paddr=%08x, len=%d(%x)%s%s\n", i,
|
||||
dq->verb, dq->seq, dq->fqid, dq->fqid, dq->bpid,
|
||||
(dq->hi_addr << 24) + dq->lo_addr + ipcom_p4080_cookie[0].p2g,
|
||||
(dq->hi_addr << 24) + dq->lo_addr,
|
||||
dq->len & 0xffff, dq->len & 0xffff,
|
||||
(i == (ci->dqrr_pi & 0xf)) ? " <-- PI " : "",
|
||||
(i == (ci->dqrr_ci & 0xf)) ? " <-- CI " : "");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* print_mr
|
||||
*===========================================================================
|
||||
* Context: shell
|
||||
* Description: Dequeue from Message Ring
|
||||
* Parameter: portal: Dequeue from specified portal, or all portals if NULL
|
||||
* cnt: Number of dequeue operations
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
print_mr(int portal, int cnt)
|
||||
{
|
||||
int i, j;
|
||||
int s = 0;
|
||||
int e = 8;
|
||||
int ret;
|
||||
Ip_u32 fq;
|
||||
Ip_u8 verb;
|
||||
Ip_u32 tag;
|
||||
Ip_u32 orrej;
|
||||
Ip_u16 sec;
|
||||
QPORTAL_FDESC fd;
|
||||
|
||||
if (portal)
|
||||
{
|
||||
s = portal;
|
||||
e = portal + 1;
|
||||
}
|
||||
if (!cnt)
|
||||
{
|
||||
cnt = 1;
|
||||
}
|
||||
|
||||
while(cnt--)
|
||||
{
|
||||
for (i = s; i < e; i++)
|
||||
{
|
||||
extern STATUS qportalMrDequeueFull(QPORTAL * portal,UINT32 * fq,UINT8 * verb,UINT32 * tag,UINT32 * OrRej,UINT16 * secNum,QPORTAL_FDESC * fd);
|
||||
|
||||
QPORTAL *qportal = ipcom_p4080_cookie[i].qportal;
|
||||
if (qportalMrDequeueFull(qportal, &fq, &verb, &tag, &orrej, &sec, &fd) != OK)
|
||||
{
|
||||
ipcom_printf("portal %2d: -- MR empty --\n", i);
|
||||
}
|
||||
else
|
||||
{
|
||||
ipcom_printf("portal %2d: fq=%d, verb=%02x, tag=%08x, rej=%02x, orp=%06x, sec=%4d, pkt=%08x:%08x, Bpid=%d, cmd=%8x\n",
|
||||
i, fq, verb, tag, orrej >> 24, orrej & 0xffffff, sec,
|
||||
fd.qportalAddrHi, fd.qportalAddrLo, fd.qportalBpid, fd.qportalCmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_forwarder_setup_portals
|
||||
*===========================================================================
|
||||
* Context: cNAE
|
||||
* Description: Setup BMAN and QMAN portals and copy them to shared memory
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_forwarder_setup_portals(int bman, int qman)
|
||||
{
|
||||
int i;
|
||||
char *name;
|
||||
uint32_t len;
|
||||
uint32_t attr;
|
||||
BPORTAL *bportal;
|
||||
QPORTAL *qportal;
|
||||
VXB_DEVICE_ID Bman;
|
||||
VXB_DEVICE_ID Qman;
|
||||
shared_portals_t *portals;
|
||||
|
||||
|
||||
name = "portals";
|
||||
vbiShmemRegionFind((int8_t *)name, (void **)&portals, &len, &attr);
|
||||
if (!portals)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: shared memory region \'%s\' not found. (size=%d)"), "ipcom_forwarder_setup_portals",
|
||||
name, sizeof(shared_portals_t) IPCOM_ENDX;
|
||||
return;
|
||||
}
|
||||
|
||||
Bman = vxbInstByNameFind ("QorIQBman", bman);
|
||||
if (!Bman)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: could not find Bman, \'QorIQBman%d\'"), "ipcom_forwarder_setup_portals", bman IPCOM_ENDX;
|
||||
return;
|
||||
}
|
||||
|
||||
Qman = vxbInstByNameFind ("QorIQQman", qman);
|
||||
if (!Qman)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: could not find Qman, \'QorIQQman%d\'"), "ipcom_forwarder_setup_portals", qman IPCOM_ENDX;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create Bman portals */
|
||||
for (i = 0; i < sizeof(portals->bportal) / sizeof(portals->bportal[0]); i++)
|
||||
{
|
||||
bportalCreate (Bman, i);
|
||||
bportalAcquire(i, &bportal);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: i=%d, bportal=%p"), "ipcom_forwarder_setup_portals", i, bportal IPCOM_ENDX;
|
||||
|
||||
ipcom_memcpy(portals->bportal + i, bportal, sizeof(*bportal));
|
||||
ipcom_p4080_cookie[i].bportal = portals->bportal + i;
|
||||
}
|
||||
|
||||
/* Create Qman portals */
|
||||
for (i = 0; i < sizeof(portals->qportal) / sizeof(portals->qportal[0]); i++)
|
||||
{
|
||||
if (i)
|
||||
{
|
||||
/* qportal 0 has already been created */
|
||||
qportalCreate(Qman, i);
|
||||
}
|
||||
qportalAcquire(i, &qportal);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: i=%d, qportal=%p"), "ipcom_forwarder_setup_portals", i, qportal IPCOM_ENDX;
|
||||
|
||||
qportalIntHandlingDisable(qportal);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
qportalDequeueSourceSelect(qportal, 0, QPORTAL_CHAN_FM0_SP0, 0); /* no HW packets on management portal */
|
||||
}
|
||||
ipcom_memcpy(portals->qportal + i, qportal, sizeof(*qportal));
|
||||
ipcom_p4080_cookie[i].qportal = portals->qportal + i;
|
||||
}
|
||||
|
||||
portals->n_portals = sizeof(portals->qportal) / sizeof(portals->qportal[0]);
|
||||
|
||||
/* */
|
||||
{
|
||||
void *vbPhys;
|
||||
Ip_u32 attr;
|
||||
Ip_u32 length;
|
||||
vbiStatus_t ret;
|
||||
char *name = "packets";
|
||||
vbiPhysAddr_t paddr;
|
||||
|
||||
vbiShmemRegionFind((int8_t *)name, &vbPhys, &length, &attr);
|
||||
|
||||
if (vbPhys == IP_NULL)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: Shared memory region \'%s\' not found."), "ipcom_forwarder_setup_portals", name IPCOM_ENDX;
|
||||
return;
|
||||
}
|
||||
ret = vbiGuestDmaAddrGet((vbiGuestPhysAddr_t)vbPhys, &paddr);
|
||||
|
||||
portals->packet_p2g = (Ip_u32)((Ip_u64)vbPhys - (Ip_u64)paddr);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: Shared memory region \'%s\' gp=%p, p2g=%x, ret=%x, p=%llx"), "ipcom_forwarder_setup_portals",
|
||||
name, vbPhys, portals->packet_p2g, ret, paddr IPCOM_ENDX;
|
||||
}
|
||||
|
||||
/* Initialise 'cookie' used by MIPC when sending slow path packets (on core 1) */
|
||||
ipcom_p4080_cookie[0].cpuId = 1;
|
||||
ipcom_p4080_cookie[0].p2g = portals->packet_p2g;
|
||||
|
||||
/* */
|
||||
VX_MEM_BARRIER_RW();
|
||||
|
||||
/* Indicate portals valid */
|
||||
portals->valid = SH_PORTALS_VALID;
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_forwarder_retrieve_ports
|
||||
*===========================================================================
|
||||
* Context: init
|
||||
* Description: Retrieve network ports
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_forwarder_retrieve_ports(void)
|
||||
{
|
||||
int i,j;
|
||||
int ret;
|
||||
Ip_u32 mtu;
|
||||
END_OBJ * pEnd;
|
||||
VB_CONFIG * pVbiConfig;
|
||||
Ip_u8 mac_addr[8];
|
||||
Ipcom_fw_port_t *fwd;
|
||||
Ipcom_port_cookie_data_t port_data;
|
||||
|
||||
#ifdef IPCOM_USE_MANY_INPUT_FQ
|
||||
{
|
||||
int qman = 0;
|
||||
VXB_DEVICE_ID Qman;
|
||||
|
||||
Qman = vxbInstByNameFind ("QorIQQman", qman);
|
||||
if (!Qman)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: could not find Qman, \'QorIQQman%d\'"), "ipcom_forwarder_setup_portals", qman IPCOM_ENDX;
|
||||
return;
|
||||
}
|
||||
qportalCreate(Qman, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve a list of all End objects registered in the Mux */
|
||||
pVbiConfig = VBI_CONFIG_ADDR_GET();
|
||||
hw_port_cnt = muxEndListGet(hw_port, MAX_FW_PORTS);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: found %d END devices."), "ipcom_forwarder_create_slow_path_fq", hw_port_cnt IPCOM_ENDX;
|
||||
|
||||
for (i = 0; i < hw_port_cnt; i++)
|
||||
{
|
||||
char devname[IP_IFNAMSIZ];
|
||||
|
||||
pEnd = hw_port[i];
|
||||
|
||||
ipcom_snprintf(devname,sizeof(devname),"%s%d", pEnd->devObject.name, pEnd->devObject.unit);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: probing device %."), "ipcom_forwarder_create_slow_path_fq", devname IPCOM_ENDX;
|
||||
|
||||
for (j = 0; j < pVbiConfig->numMem; j++)
|
||||
{
|
||||
VB_MEM_INFO *pMem = &pVbiConfig->memoryRegionsConfigAddress[j];
|
||||
|
||||
if (strncmp((char *)pMem->name, devname, strlen(devname)) == 0)
|
||||
{
|
||||
/* RIME: The result of the EIOCGFWPORT ioctl determines if the device has FW capabilities */
|
||||
ret = muxIoctl (pEnd, EIOCGFWPORT, (caddr_t)&port_data);
|
||||
if (ret != EINVAL)
|
||||
{
|
||||
(void)muxIoctl (pEnd, EIOCGIFMTU, (caddr_t)&mtu);
|
||||
(void)muxIoctl (pEnd, EIOCGADDR, (caddr_t)mac_addr);
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: pEnd:%s(%d), TxFq=%x(%d), bpid=%x(%d), mtu=%d, mac=%02x:%02x:%02x:%02x:%02x:%02x"),
|
||||
"ipcom_forwarder_retrieve_ports",
|
||||
pEnd->devObject.name, pEnd->devObject.unit,
|
||||
port_data.TxFq, port_data.TxFq,
|
||||
port_data.bpid, port_data.bpid,
|
||||
mtu,
|
||||
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5] IPCOM_ENDX;
|
||||
|
||||
fwd = ipcom_fw_cpu_mem_alloc(ipcom_forwarder_current_core(),
|
||||
sizeof(Ipcom_fw_port_t),
|
||||
ipcom_cache_line_size(),
|
||||
IPCOM_FW_CPU_MEM_ALLOC_SHARED);
|
||||
|
||||
fwd->pEnd = pEnd;
|
||||
fwd->port_index = port_data.bpid;
|
||||
fwd->TxFq = port_data.TxFq;
|
||||
fwd->bpid = port_data.bpid;
|
||||
|
||||
/* Re-direct traffic to a POOL channel, which can be polled from multiple portals */
|
||||
if (muxIoctl (pEnd, EIOCSFWPORT, (caddr_t)IP_NULL) != OK)
|
||||
{
|
||||
IPCOM_LOGX(DEBUG, "%s: muxIoctl(EIOCSFWPORT) on pEnd(%s %d) failed"), "ipcom_forwarder_retrieve_ports",
|
||||
pEnd->devObject.name, pEnd->devObject.unit IPCOM_ENDX;
|
||||
}
|
||||
|
||||
ipcom_forwarder_setup_keygen(port_data.rx_port, port_data.rx_q, port_data.fman);
|
||||
ipcom_forwarder_register_port(fwd->port_index, fwd, mtu, mac_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPCOM_LOGX(DEBUG, "%s: pEnd %p does not support EIOCGFWPORT"), "ipcom_forwarder_retrieve_ports",
|
||||
pEnd IPCOM_ENDX;
|
||||
}
|
||||
|
||||
/* Break inner loop and probe next device */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fw_packet_send
|
||||
*===========================================================================
|
||||
* Context: Control NAE mipc callback context
|
||||
* Description: Called by MIPC Rx callback routine when data packets are
|
||||
* received from the management system.
|
||||
* Parameters: hdr: MIPC packet descriptor
|
||||
* free_arg: (not used)
|
||||
* Returns: always 1
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fw_packet_send(ifproxy_cmd_hdr_t *hdr, void *free_arg)
|
||||
{
|
||||
Ip_u8 *vaddr;
|
||||
Ip_u64 paddr;
|
||||
Ipcom_pkt *pkt;
|
||||
BPORTAL *bportal;
|
||||
Ipcom_p4080_cookie_t *c = &ipcom_p4080_cookie[0];
|
||||
Ipcom_fw_port_t *fw_port = ipcom_forwarder_get_port_cookie(hdr->PortIndex);
|
||||
|
||||
(void)free_arg;
|
||||
|
||||
IPCOM_LOGX(DEBUG2, "%s: fw_port=%p, port_index=%d(%x)"), "ipcom_fw_packet_send",
|
||||
fw_port, hdr->PortIndex, hdr->PortIndex IPCOM_ENDX;
|
||||
|
||||
if (fw_port != IP_NULL)
|
||||
{
|
||||
if (bportalAlloc(c->bportal, fw_port->bpid, &paddr) != OK)
|
||||
{
|
||||
return 1; /* let MIPC release its zbuffer */
|
||||
}
|
||||
|
||||
{
|
||||
vaddr = (void *)(paddr + c->p2g);
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
if (shared_debug->flag)
|
||||
{
|
||||
static int cnt = 1;
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s:(%3d) vaddr=%p, paddr=%llx, p2g=%x, port_index=%d(%x), len=%d, bpid=%d, bportal=%p, flags=%x"), "ipcom_fw_packet_send",
|
||||
cnt++, vaddr, paddr, c->p2g, hdr->PortIndex, hdr->PortIndex, hdr->EndOffset - hdr->StartOffset,
|
||||
fw_port->bpid, c->bportal, hdr->Flags IPCOM_ENDX;
|
||||
}
|
||||
#endif
|
||||
memcpy(FMAN_PKT_DATA(vaddr), (Ip_u8 *)(hdr + 1) + hdr->StartOffset, hdr->EndOffset - hdr->StartOffset);
|
||||
|
||||
if (IP_BIT_ISSET(IFPROXY_CMD_HDR_HAS_FWD_TAG, hdr->Flags))
|
||||
{
|
||||
hdr->EndOffset -= sizeof(Ip_u32);
|
||||
|
||||
/* Packet is forwarded by mgmt, update fwcache */
|
||||
pkt = ipcom_pkt_malloc(0, 0);
|
||||
pkt->data = FMAN_PKT_DATA(vaddr);
|
||||
pkt->start = 0;
|
||||
pkt->end = hdr->EndOffset - hdr->StartOffset;
|
||||
ipcom_memcpy(&pkt->nae_key, (Ip_u8 *)(hdr + 1) + hdr->EndOffset, sizeof(Ip_u32));
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
if (shared_debug->flag)
|
||||
{
|
||||
IPCOM_LOGX(DEBUG, "%s: Forwarded packet (%p) port_index=%d(%x), pkt->nae_key=%x(%d)"), "ipcom_fw_packet_send",
|
||||
pkt->data, hdr->PortIndex, hdr->PortIndex, pkt->nae_key, pkt->nae_key IPCOM_ENDX;
|
||||
}
|
||||
#endif
|
||||
|
||||
ipcom_forwarder_transmit_pkt_ext(pkt, hdr->PortIndex);
|
||||
pkt->data = IP_NULL;
|
||||
ipcom_pkt_free(pkt);
|
||||
}
|
||||
|
||||
#ifdef IPCOM_SHARED_DEBUG
|
||||
if (shared_debug->flag > 1)
|
||||
{
|
||||
dumpdata(FMAN_PKT_DATA(vaddr), 100, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
c->rx.fd.qportalDdLioLo = 0;
|
||||
c->rx.fd.qportalBpid = fw_port->bpid;
|
||||
c->rx.fd.qportalAddrHi = DTSEC_ADDR_HI(paddr);
|
||||
c->rx.fd.qportalAddrLo = DTSEC_ADDR_LO(paddr);
|
||||
c->rx.fd.qportalCmd = FMAN_TXFS_FCO;
|
||||
c->rx.fd.qportalOffLen = QPORTAL_FDESC_FMT_CONTIG | FD_DATA_OFFSET(FMAN_PKT_OFF + FMAN_PKT_ALIGN) | hdr->EndOffset - hdr->StartOffset;
|
||||
|
||||
ipcom_forwarder_tx(fw_port->TxFq, IP_NULL, c);
|
||||
}
|
||||
}
|
||||
return 1; /* let MIPC release the buffer */
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* fmanKgSchemeCreate - set up a sample key generator scheme
|
||||
*
|
||||
* This function initializes a key generator scheme index <schemeIdx>. The
|
||||
* scheme uses the 'extract known fields' mask to have the key generator
|
||||
* extract the first IP source address from received packets, and then
|
||||
* direct the frame to the frame queue specified by <fqid>. The next
|
||||
* action field of the 'mode' word in the scheme is set to direct the
|
||||
* frame to the 'BMI enqueue' path so that the frame can be enqueued
|
||||
* to the queue manager.
|
||||
*
|
||||
* The scheme can be modified to extract the IP destination address instead
|
||||
* of the source, or to extract both fields together.
|
||||
*
|
||||
* Once the scheme is loaded, the fmanKgPortConfig() routine is used to
|
||||
* tie it to a given port. Note that it's possible to associate a given
|
||||
* scheme with more than one port.
|
||||
*
|
||||
* Note that the scheme is only activated by having the FMKG_SE_MODE_SI
|
||||
* bit set in the 'mode' word of the scheme. Without this bit, the scheme
|
||||
* will still be loaded into the specified <schemeIdx> slot, but it will
|
||||
* be ignored by the frame manager.
|
||||
*
|
||||
* RETURNS: N/A
|
||||
*
|
||||
* ERRNO: N/A
|
||||
*/
|
||||
|
||||
IP_PUBLIC void
|
||||
ipcom_forwarder_setup_keygen(int port, int fqid, int fman)
|
||||
{
|
||||
int i, q;
|
||||
void *pDev;
|
||||
QPORTAL *qportal;
|
||||
FMAN_KG_SCHEME sc;
|
||||
|
||||
schemeIndex++;
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: adding keygen for port, %d, index=%d, fqid=%x(%d), fman=%d"),"ipcom_forwarder_setup_keygen",
|
||||
port, schemeIndex, fqid, fqid, fman IPCOM_ENDX;
|
||||
|
||||
#ifdef IPCOM_USE_MANY_INPUT_FQ
|
||||
qportalAcquire(0, &qportal);
|
||||
|
||||
for (i = 0; i < IPCOM_FQ_PER_PORT; i++)
|
||||
{
|
||||
q = IPCOM_FQ_PER_PORT_BASE + IPCOM_FQ_PER_PORT * (schemeIndex - 1) + i;
|
||||
|
||||
IPCOM_LOGX(DEBUG, "%s: port=%d, fq=%d(%x)"),"ipcom_forwarder_setup_keygen", port, q, q IPCOM_ENDX;
|
||||
|
||||
if (qportalFqInit (qportal, q, QPORTAL_CHAN_POOL1, 0, 0xa5a5, 0, 0, 0) != OK)
|
||||
{
|
||||
IPCOM_LOGX(ERR, "%s: qportalFqInit failed for fqid %d(%x)"), "ipcom_forwarder_setup_keygen", q, q IPCOM_ENDX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pDev = vxbInstByNameFind ("QorIQFman", fman);
|
||||
|
||||
bzero ((char *)&sc, sizeof(sc));
|
||||
|
||||
sc.fmks_mode = FMKG_SE_MODE_SI | FMAN_NIA_BMIEQ;
|
||||
sc.fmks_ekfc = FMKG_SE_EKFC_IPDST1;
|
||||
sc.fmks_fqb = fqid;
|
||||
sc.fmks_dv0 = 0x0;
|
||||
sc.fmks_ekdv = FMKG_EKDV_SCHEME0;
|
||||
|
||||
#ifdef IPCOM_USE_MANY_INPUT_FQ
|
||||
/* Spread over 8 frame queues, [fqid, fqid + 7] */
|
||||
sc.fmks_hc = 0 | IPCOM_FW_MASK(IPCOM_FQ_PER_PORT);
|
||||
sc.fmks_fqb = IPCOM_FQ_PER_PORT_BASE + IPCOM_FQ_PER_PORT * (schemeIndex - 1);
|
||||
#endif
|
||||
|
||||
/* Load the scheme to the desired scheme index */
|
||||
fmanKgSchemeWrite (pDev, schemeIndex, &sc);
|
||||
|
||||
/* Tie the scheme index to a port */
|
||||
fmanKgPortConfig (pDev, port, schemeIndex);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* IPCOM_USE_P4080_FORWARDER */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* End of file
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_debug.c,v $ $Revision: 1.18.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_debug.c,v $
|
||||
* $Author: svc-cmnet $ $Date: 2013-03-13 07:45:16 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_clib2.h>
|
||||
#include <ipcom_os.h>
|
||||
#ifdef IPCOM_FORWARDER_NAE
|
||||
#include <ipcom_forwarder.h>
|
||||
#endif
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <taskLib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(IPCOM_USE_FORWARDER) && defined(_WRS_CONFIG_WRHV_GUEST)
|
||||
#include <wrhv/vbi.h>
|
||||
|
||||
IP_EXTERN Ip_bool ipcom_forwarder_is_master(void);
|
||||
IP_EXTERN Ip_bool ipcom_forwarder_has_serial_console(void);
|
||||
IP_EXTERN unsigned int ipcom_forwarder_current_core(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(IPCOM_FORWARDER_NAE) || defined(IPCOM_FORWARDER_AMP)
|
||||
IP_EXTERN int ipcom_mipc_printf(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Global and public variable to store assert info in. */
|
||||
#ifdef IP_ASSERT
|
||||
IP_PUBLIC Ip_assert assert_data;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
#if defined(IPCOM_USE_FORWARDER) && defined(_WRS_CONFIG_WRHV_GUEST)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_hv_printf
|
||||
*===========================================================================
|
||||
* Description: Special version of printf to be used when VxWorks
|
||||
* is used as a guestOS in the Wind River Hypervisor.
|
||||
* This function outputs the string on the Hypervisor
|
||||
* console - prefixed with a the coreID.
|
||||
*
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_hv_vprintf(const char *format, va_list vargs)
|
||||
{
|
||||
char *buf;
|
||||
int retval;
|
||||
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE + 1);
|
||||
if (buf == IP_NULL)
|
||||
return -1;
|
||||
|
||||
if (ipcom_forwarder_is_master())
|
||||
retval = ipcom_sprintf(buf, "nae-ctrl:: ");
|
||||
else
|
||||
retval = ipcom_sprintf(buf, "nae-%d:: ", ipcom_forwarder_current_core());
|
||||
|
||||
if (retval < 0)
|
||||
goto out;
|
||||
|
||||
retval = ipcom_vsnprintf(&buf[retval], IPCOM_STDIO_BUFSIZE - retval, format, vargs);
|
||||
retval = IP_MIN(retval, (int) IPCOM_STDIO_BUFSIZE);
|
||||
|
||||
if (retval < 0)
|
||||
goto out;
|
||||
|
||||
if (ipcom_forwarder_has_serial_console())
|
||||
retval = printf(buf);
|
||||
else
|
||||
retval = vbiKputs(buf);
|
||||
|
||||
out:
|
||||
ipcom_free(buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
IP_PUBLIC int
|
||||
ipcom_hv_printf(const char *format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
retval = ipcom_hv_vprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC int
|
||||
ipcom_hv_syslog(Ip_u32 priority, const char *format, ...)
|
||||
{
|
||||
int retval;
|
||||
va_list ap;
|
||||
char *buf;
|
||||
|
||||
(void)priority;
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE + 1);
|
||||
if (buf == IP_NULL)
|
||||
return -1;
|
||||
|
||||
/* Append line feed */
|
||||
ipcom_snprintf(buf, IPCOM_STDIO_BUFSIZE, "%s\n", format);
|
||||
|
||||
va_start(ap, buf); /* FIXME -- this won't work, &buf != &format */
|
||||
retval = ipcom_hv_vprintf(buf, ap);
|
||||
va_end(ap);
|
||||
|
||||
ipcom_free(buf);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_debug_printf
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_debug_printf(const char *format, /* args*/ ...)
|
||||
{
|
||||
char *buf;
|
||||
va_list ap;
|
||||
Ip_s32 retval;
|
||||
|
||||
buf = ipcom_malloc(IPCOM_STDIO_BUFSIZE);
|
||||
if (buf == IP_NULL)
|
||||
{
|
||||
printf("ipcom_debug_printf: out of memory printing: %s", format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Here we would like to use vsnprintf, but vxWorks doesn't support that.
|
||||
* we cannot use ipcom_vsnprintf either, since that function uses the
|
||||
* ip_assert macro (may cause endless recursion). */
|
||||
va_start(ap, format);
|
||||
retval = vsprintf(buf, format, ap);
|
||||
va_end(ap);
|
||||
if (retval >= IPCOM_STDIO_BUFSIZE)
|
||||
{
|
||||
printf(buf);
|
||||
printf("ipcom_debug_printf: buffer overwrite!!! Task name: %s id: %x"IP_LF,
|
||||
taskName(taskIdSelf()), taskIdSelf());
|
||||
(void)taskSuspend(0);
|
||||
}
|
||||
|
||||
#if defined(IPCOM_USE_FORWARDER) && defined(_WRS_CONFIG_WRHV_GUEST) && defined(IPCOM_USE_P4080_FORWARDER)
|
||||
/* Use Hypervisor printfs for debug output on SAMP */
|
||||
retval = ipcom_hv_printf("%s", buf);
|
||||
#elif defined(IPCOM_USE_FORWARDER) && (defined(IPCOM_FORWARDER_NAE) || defined(IPCOM_FORWARDER_AMP))
|
||||
/* Use MIPC printfs on UAMP */
|
||||
retval = ipcom_mipc_printf("%s", buf);
|
||||
#else
|
||||
retval = printf("%s", buf);
|
||||
#endif
|
||||
ipcom_free(buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_assert
|
||||
*===========================================================================
|
||||
* Description: Called if the assert macro failed due to a false assertion.
|
||||
* The function stores the expression, line and file number in
|
||||
* the a global Ip_assert structure 'ip_assert' then optionally
|
||||
* prints the message and halts the program.
|
||||
* Parameters: expr - The assert expression that is false.
|
||||
* file - Pointer to the file where the assert triggered.
|
||||
* line - File line number to identify the assert.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_assert(const char *expr, const char *file, Ip_u32 line)
|
||||
{
|
||||
#ifdef IP_ASSERT
|
||||
ipcom_debug_printf("*** Failed assertion '%s' at %s:%ld, task name: %s, Id: %x ***"IP_LF,
|
||||
expr, file, line, taskName(taskIdSelf()), taskIdSelf());
|
||||
|
||||
/* Fill in the last assert into the global 'assert_data' structure. */
|
||||
assert_data.expr = expr;
|
||||
assert_data.file = file;
|
||||
assert_data.line = line;
|
||||
|
||||
ipcom_sleep(1);
|
||||
|
||||
(void)taskSuspend(0);
|
||||
#else
|
||||
(void)expr;
|
||||
(void)file;
|
||||
(void)line;
|
||||
#endif /* IP_ASSERT */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_errno.c,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_errno.c,v $
|
||||
* $Author: lob $ $Date: 2004-05-04 12:02:18 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_errno_set
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_errno_set(int errcode)
|
||||
{
|
||||
errno = errcode;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_errno_get
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int *
|
||||
ipcom_errno_get(void)
|
||||
{
|
||||
return &errno;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ipc_spinlock.c,v $ $Revision: 1.3.12.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_ipc_spinlock.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/* For now, include contents only if Nehalem or P4080 forwarder is enabled. */
|
||||
#if defined(IPCOM_USE_NEHALEM_FORWARDER) || defined(IPCOM_USE_P4080_FORWARDER)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_ipc_spinlock.h>
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <multios_ipc/mipc.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 12 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_PUBLIC void
|
||||
ipcom_ipc_spinlock_init(Ipcom_ipc_spinlock_t * lock)
|
||||
{
|
||||
ipcom_atomic_set (&lock->flag, 0);
|
||||
MULTIOS_MEM_BARRIER();
|
||||
}
|
||||
|
||||
/*
|
||||
* ipcom_ipc_spinlock_take() and ipcom_ipc_spinlock_give()
|
||||
* are defined in the VxWorks architecture-specific code.
|
||||
* Need portable VxWorks version here.
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_PORTABLE_IPC_SPINLOCK
|
||||
/*
|
||||
* TODO -- portable versions of ipcom_ipc_spinlock_take() and
|
||||
* ipcom_ipc_spinlock_give().
|
||||
*/
|
||||
IP_PUBLIC Ipcom_int_key_t
|
||||
ipcom_ipc_spinlock_take(Ipcom_ipc_spinlock_t * lock)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
IP_PUBLIC void
|
||||
ipcom_ipc_spinlock_give (Ipcom_ipc_spinlock_t * lock, Ipcom_int_key_t key)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
int ipcom_ipc_spinlock_empty_file;
|
||||
#endif /* IPCOM_USE_NEHALEM_FORWARDER || IPCOM_USE_P4080_FORWARDER */
|
||||
/*
|
||||
******************************************************************************
|
||||
* End of file
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,378 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_job_queue.c,v $ $Revision: 1.7.26.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_job_queue.c,v $
|
||||
* $Author: anonymous $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth.jonsson@windriver.com>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* VxWorks specific version of the IPCOM net-job API.
|
||||
* NOTE: this implementation does only implement enough features to
|
||||
* support the IPNET stack. The most important restriction is that
|
||||
* only one delayed job can be in flight at any point in time.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#if (defined(IPNET) || defined(IPLITE)) && defined(IPCOM_USE_JOB_QUEUE)
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <jobQueueLib.h>
|
||||
#include <netLib.h>
|
||||
#include <wdLib.h>
|
||||
#include <vxAtomicLib.h>
|
||||
|
||||
#include "ipcom_job_queue.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_errno.h"
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Maximum number of ticks that a job can be delayed. The 2:nd
|
||||
argument of wdStart() takes number of ticks as an "int", so the
|
||||
biggest possible value is 0x7fffffff. Ticks is calculated as
|
||||
ticks = (delay * tick_per_sec + 999) / 1000
|
||||
*/
|
||||
#define IPCOM_JOB_MAX_TICKS_FOR_DELAYED_JOB (0x7fffffff - 999)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipcom_job_struct {
|
||||
QJOB vxjob; /* VxWorks job structure */
|
||||
Ipcom_job_action action; /* Handler for this job */
|
||||
WDOG_ID watchdog_id; /* Watchdog for this job or
|
||||
IP_NULL if this job has never
|
||||
been delayed */
|
||||
int watchdog_ticks; /* Number of ticks the current
|
||||
watchdog is scheduled */
|
||||
}
|
||||
Ipcom_job_t;
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN int sysClkRateGet(void);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/* Memory cache for IPNET job entries */
|
||||
static Ipcom_memory_cache *ipcom_job_slab;
|
||||
/* ID of the job queue used by all IPNET jobs */
|
||||
static JOB_QUEUE_ID ipcom_job_queue_id;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 LOCAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_action_auto_clean
|
||||
*===========================================================================
|
||||
* Description: VxWorks job handler that will run the specified action
|
||||
* and then free the job structure.
|
||||
* Parameters: job - contains the action to perform
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_job_action_auto_clean(Ipcom_job_t *job)
|
||||
{
|
||||
job->action();
|
||||
ipcom_slab_free(ipcom_job_slab, job);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_sigleton_job_action
|
||||
*===========================================================================
|
||||
* Description: VxWorks job handler for jobs that may only be present no
|
||||
* more than one time on the job queue.
|
||||
* Parameters: job - contains the action to perform
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_singleton_job_action(Ipcom_job_t *job)
|
||||
{
|
||||
job->watchdog_ticks = 0;
|
||||
job->action();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_prio_to_vxjob_prio
|
||||
*===========================================================================
|
||||
* Description: Converts an IPCOM job priority to the equvivalent VxWorks
|
||||
* job priority.
|
||||
* Parameters: prio - an IPCOM job priority.
|
||||
* Returns: A VxWorks job priority.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_job_queue_prio_to_vxjob_prio(enum Ipcom_job_prio prio)
|
||||
{
|
||||
switch (prio)
|
||||
{
|
||||
case IPCOM_JOB_PRIO_LOW:
|
||||
return NET_TASK_QJOB_PRI - 1;
|
||||
case IPCOM_JOB_PRIO_NORMAL:
|
||||
return NET_TASK_QJOB_PRI;
|
||||
case IPCOM_JOB_PRIO_HIGH:
|
||||
return NET_TASK_QJOB_PRI + 1;
|
||||
default:
|
||||
IP_PANIC();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_init
|
||||
*===========================================================================
|
||||
* Description: Initializes the job queue.
|
||||
* Parameters: memory_pool - the memory pool the job queue has to allocate
|
||||
* memory from.
|
||||
* Returns: 0 = sucess, <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_job_queue_init(Ipcom_memory_pool *memory_pool)
|
||||
{
|
||||
ipcom_job_queue_id = netDaemonQ(0);
|
||||
ipcom_job_slab = ipcom_slab_new("IPCOM network job",
|
||||
0,
|
||||
sizeof(Ipcom_job_t),
|
||||
(Ip_size_t)ipcom_cache_line_size(),
|
||||
IP_NULL,
|
||||
IP_NULL,
|
||||
memory_pool);
|
||||
return (ipcom_job_slab ? 0 : -IP_ERRNO_ENOMEM);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_singleton_new
|
||||
*===========================================================================
|
||||
* Description: Creates a job that is guaranteed to be present at the most
|
||||
* one time in the queue of pending jobs.
|
||||
* Parameters: action - function to call in order to run the job
|
||||
* prio - priority of the job
|
||||
* Returns: A new singleton job.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ipcom_singleton_job_t ipcom_job_queue_singleton_new(Ipcom_job_action action,
|
||||
enum Ipcom_job_prio prio)
|
||||
{
|
||||
Ipcom_job_t *job;
|
||||
|
||||
job = ipcom_slab_alloc(ipcom_job_slab);
|
||||
if (IP_LIKELY(job != IP_NULL))
|
||||
{
|
||||
job->vxjob.priInfo = ipcom_job_queue_prio_to_vxjob_prio(prio);
|
||||
job->vxjob.func = (QJOB_FUNC) ipcom_singleton_job_action;
|
||||
job->action = action;
|
||||
job->watchdog_id = IP_NULL;
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_singleton_delete
|
||||
*===========================================================================
|
||||
* Description: Frees all resources allocated by
|
||||
* ipcom_job_queue_singleton_new()
|
||||
* Parameters: sjob - singleton job created with
|
||||
* ipcom_job_queue_singleton_new()
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipcom_job_queue_singleton_delete(Ipcom_singleton_job_t sjob)
|
||||
{
|
||||
Ipcom_job_t *job = (Ipcom_job_t *) sjob;
|
||||
|
||||
if (job->watchdog_id)
|
||||
wdDelete(job->watchdog_id);
|
||||
ipcom_slab_free(ipcom_job_slab, sjob);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_schedule_singleton
|
||||
*===========================================================================
|
||||
* Description: Schedule a singleton job to be run as soon as possible.
|
||||
* Parameters: sjob - singleton job created with
|
||||
* ipcom_job_queue_singleton_new()
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void ipcom_job_queue_schedule_singleton(Ipcom_singleton_job_t sjob)
|
||||
{
|
||||
Ipcom_job_t *job = (Ipcom_job_t *) sjob;
|
||||
|
||||
jobQueuePost(ipcom_job_queue_id, &job->vxjob);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_schedule_singleton_delayed
|
||||
*===========================================================================
|
||||
* Description: Schedule a job to be run in the future.
|
||||
* Parameters: sjob - job to run in the future
|
||||
* delay - number of milliseconds to delay the job
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_job_queue_schedule_singleton_delayed(Ipcom_singleton_job_t sjob,
|
||||
Ip_s64 delay)
|
||||
{
|
||||
Ipcom_job_t *job = (Ipcom_job_t *) sjob;
|
||||
int ticks_per_sec;
|
||||
|
||||
if (delay == 0)
|
||||
ipcom_job_queue_schedule_singleton(sjob);
|
||||
else
|
||||
{
|
||||
int ticks;
|
||||
|
||||
if (job->watchdog_id == IP_NULL)
|
||||
{
|
||||
/* Lazy init of the watchdog timer */
|
||||
job->watchdog_id = wdCreate();
|
||||
if (job->watchdog_id == NULL)
|
||||
{
|
||||
/* The stack timeout handling will not work without a
|
||||
watchdog timer. */
|
||||
IP_PANIC();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ticks_per_sec = sysClkRateGet();
|
||||
if (delay >= (Ip_s64)(IPCOM_JOB_MAX_TICKS_FOR_DELAYED_JOB / ticks_per_sec))
|
||||
/* The "ticks" variable would overflow if "delay" is
|
||||
translated to ticks in this case. The stack has no
|
||||
problem with receiving a call to the timeout machinery
|
||||
too early though, it will just schedule a new timeout
|
||||
with "delay" set to the timeout to the next timeout. */
|
||||
ticks = IPCOM_JOB_MAX_TICKS_FOR_DELAYED_JOB;
|
||||
else
|
||||
ticks = (int)((delay * ticks_per_sec + 999) / 1000);
|
||||
|
||||
if (job->watchdog_ticks == 0 || job->watchdog_ticks > ticks)
|
||||
{
|
||||
job->watchdog_ticks = ticks;
|
||||
(void)wdStart(job->watchdog_id,
|
||||
ticks,
|
||||
(WD_RTN) ipcom_job_queue_schedule_singleton,
|
||||
(_Vx_usr_arg_t) job);
|
||||
}
|
||||
/* else: the watchdog is already schedule with the same or
|
||||
shorter time, let the running timer expire before the
|
||||
current one. IPNET has no problem handling too early
|
||||
exparation of this timer. */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_job_queue_schedule
|
||||
*===========================================================================
|
||||
* Description: Schedule a job to be run as soon as possible.
|
||||
* Parameters: action - function to call in order to run the job
|
||||
* prio - priority of the job
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_job_queue_schedule(Ipcom_job_action action,
|
||||
enum Ipcom_job_prio prio)
|
||||
{
|
||||
Ipcom_job_t *job;
|
||||
|
||||
job = ipcom_slab_alloc(ipcom_job_slab);
|
||||
if (IP_UNLIKELY(job == IP_NULL))
|
||||
return;
|
||||
|
||||
job->vxjob.priInfo = ipcom_job_queue_prio_to_vxjob_prio(prio);
|
||||
job->vxjob.func = (QJOB_FUNC) ipcom_job_action_auto_clean;
|
||||
job->action = action;
|
||||
|
||||
jobQueuePost(ipcom_job_queue_id, &job->vxjob);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_RCPL8_2024030303 $ $RCSfile: ipcom_malloc.c,v $ $Revision: 1.17.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_malloc.c,v $
|
||||
* $Author: jren $ $Date: 2020-03-12 07:45:41 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ipcom_vxworks.h"
|
||||
#include "ipcom_clib.h"
|
||||
|
||||
#ifdef WRS_IPLITE
|
||||
#include "simpleMemLib.h"
|
||||
#ifndef IPCOM_SIMPLE_MEM_SIZE
|
||||
#define IPCOM_SIMPLE_MEM_SIZE (1024*1024*sizeof(ulong_t))
|
||||
#endif
|
||||
static ulong_t g_ipcom_simple_mem_buf[IPCOM_SIMPLE_MEM_SIZE/sizeof(ulong_t)];
|
||||
static memInfo_t *g_ipcom_simple_mem = NULL;
|
||||
static int g_ipcom_simple_mem_initd = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef ipcom_malloc
|
||||
#undef ipcom_malloc
|
||||
#endif
|
||||
#ifdef ipcom_calloc
|
||||
#undef ipcom_calloc
|
||||
#endif
|
||||
#ifdef ipcom_realloc
|
||||
#undef ipcom_realloc
|
||||
#endif
|
||||
#ifdef ipcom_free
|
||||
#undef ipcom_free
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
IP_STATIC Ip_s32 no_of_bufs = 0;
|
||||
IP_STATIC Ip_s32 tot_no_of_bufs = 0;
|
||||
#endif
|
||||
|
||||
#ifdef WRS_IPLITE
|
||||
|
||||
static int ipcom_simple_mem_init()
|
||||
{
|
||||
if (1 == g_ipcom_simple_mem_initd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/* printf("!!!!!!!!!!! ipcom_simple_mem_init ::: init\n"); */
|
||||
/* g_ipcom_simple_mem_buf = (char *)malloc(IPCOM_SIMPLE_MEM_SIZE);
|
||||
if (NULL == g_ipcom_simple_mem_buf)
|
||||
{
|
||||
printf(" ipcom_simple_mem_init ::::::::::::: malloc failed\n");
|
||||
return -1;
|
||||
}*/
|
||||
g_ipcom_simple_mem = simpleMemCreate((void *)g_ipcom_simple_mem_buf, sizeof(g_ipcom_simple_mem_buf));
|
||||
if (g_ipcom_simple_mem != NULL)
|
||||
{
|
||||
g_ipcom_simple_mem_initd = 1;
|
||||
return 0;
|
||||
}
|
||||
/* printf("!!!!!!!!!!! ipcom_simple_mem_init ::: failed\n"); */
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
static int ipcom_simple_mem_free()
|
||||
{
|
||||
if ((0 == g_ipcom_simple_mem_initd)
|
||||
|| (NULL == g_ipcom_simple_mem))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
simpleMemDestory(g_ipcom_simple_mem);
|
||||
g_ipcom_simple_mem_initd = 0;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_malloc_stat
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef IP_DEBUG
|
||||
IP_PUBLIC void
|
||||
ipcom_malloc_stat(void)
|
||||
{
|
||||
#ifdef _WRS_KERNEL
|
||||
ipcom_printf("Current no of bufs: %d\n", no_of_bufs);
|
||||
ipcom_printf("Total no of bufs: %d\n", tot_no_of_bufs);
|
||||
#else
|
||||
printf("Current no of bufs: %d\n", no_of_bufs);
|
||||
printf("Total no of bufs: %d\n", tot_no_of_bufs);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_free
|
||||
*===========================================================================
|
||||
* Description: Free the dynamic memory pointer to by 'ptr'. If 'ptr'
|
||||
* is IP_NULL, no operation is performed.
|
||||
* Parameters: ptr - Pointer to the dynamic memory to free.
|
||||
* Returns: .
|
||||
*
|
||||
*/
|
||||
#ifdef WRS_IPLITE
|
||||
IP_PUBLIC void
|
||||
ipcom_free(void *ptr)
|
||||
{
|
||||
if(ptr != IP_NULL)
|
||||
{
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs--;
|
||||
#endif
|
||||
if (ipcom_simple_mem_init() == 0)
|
||||
{
|
||||
simpleMemMFree(g_ipcom_simple_mem, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
IP_PUBLIC void
|
||||
ipcom_free(void *ptr)
|
||||
{
|
||||
if(ptr != IP_NULL)
|
||||
{
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs--;
|
||||
#endif
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_calloc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef WRS_IPLITE
|
||||
IP_PUBLIC void *
|
||||
ipcom_calloc(Ip_size_t nelem, Ip_size_t elsize)
|
||||
{
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs++;
|
||||
tot_no_of_bufs++;
|
||||
#endif
|
||||
if (ipcom_simple_mem_init() == 0)
|
||||
{
|
||||
char *ptr = simpleMemMalloc(g_ipcom_simple_mem, nelem * elsize);
|
||||
if (ptr != NULL)
|
||||
{
|
||||
memset(ptr, 0x00, nelem * elsize);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
IP_PUBLIC void *
|
||||
ipcom_calloc(Ip_size_t nelem, Ip_size_t elsize)
|
||||
{
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs++;
|
||||
tot_no_of_bufs++;
|
||||
#endif
|
||||
|
||||
return calloc(nelem, elsize);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_realloc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
#ifdef WRS_IPLITE
|
||||
IP_PUBLIC void *
|
||||
ipcom_realloc(void *ptr, Ip_size_t size)
|
||||
{
|
||||
if (ipcom_simple_mem_init() == 0)
|
||||
{
|
||||
char *ptr_new = NULL;
|
||||
|
||||
ptr_new = simpleMemMalloc(g_ipcom_simple_mem, size);
|
||||
if (ptr_new != NULL)
|
||||
{
|
||||
memset(ptr_new, 0x00, size);
|
||||
}
|
||||
if (ptr != NULL)
|
||||
{
|
||||
ulong_t ptrlen = *(ulong_t *)(((ulong_t *)ptr)-1);
|
||||
if ((ptrlen > 0) && (ptr_new != NULL))
|
||||
{
|
||||
memcpy(ptr_new, ptr, (ptrlen > size) ? size : ptrlen);
|
||||
}
|
||||
simpleMemMFree(g_ipcom_simple_mem, ptr);
|
||||
}
|
||||
|
||||
return ptr_new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
IP_PUBLIC void *
|
||||
ipcom_realloc(void *ptr, Ip_size_t size)
|
||||
{
|
||||
return realloc(ptr, (size_t)size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_malloc
|
||||
*===========================================================================
|
||||
* Description: Allocate 'size' bytes of consecutive dynamic memory which
|
||||
* is uninitialized. The allocated memory must later be freed
|
||||
* by ipcom_free() or ipcom_freep().
|
||||
* Parameters: size - The number of bytes to allocate.
|
||||
* Returns: Pointer to the allocated dynamic memory.
|
||||
*
|
||||
*/
|
||||
#ifdef WRS_IPLITE
|
||||
IP_PUBLIC void *
|
||||
ipcom_malloc(Ip_size_t size)
|
||||
{
|
||||
Ip_u8 *buf = NULL;
|
||||
|
||||
if (ipcom_simple_mem_init() == 0)
|
||||
{
|
||||
buf = (void *)simpleMemMalloc(g_ipcom_simple_mem, (ulong_t)size);
|
||||
}
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs++;
|
||||
tot_no_of_bufs++;
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
#else
|
||||
IP_PUBLIC void *
|
||||
ipcom_malloc(Ip_size_t size)
|
||||
{
|
||||
Ip_u8 *buf;
|
||||
|
||||
buf = malloc(size);
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
no_of_bufs++;
|
||||
tot_no_of_bufs++;
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_cache_line_size
|
||||
*===========================================================================
|
||||
* Description: Get the system cache line size in bytes.
|
||||
* Parameters: N/A
|
||||
* Returns: Number of bytes in a cache line.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_cache_line_size( void )
|
||||
{
|
||||
#ifdef WRS_IPLITE
|
||||
return sizeof(ulong_t);
|
||||
#else
|
||||
return _CACHE_ALIGN_SIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_mcmd_ifconfig.c,v $ $Revision: 1.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_mcmd_ifconfig.c,v $
|
||||
* $Author: kenneth $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* This is a reduced version of ipnet_cmd_ifconfig.c. The file is used to
|
||||
* make ifconfig command utility binary scalable.
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IPCOM_KERNEL
|
||||
#undef IPCOM_KERNEL
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_USE_CLIB_PROTO
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_cmd.h>
|
||||
#include <ipcom_getopt.h>
|
||||
#include <ipcom_sysctl.h>
|
||||
|
||||
#ifdef IPNET
|
||||
#include "ipnet_config.h"
|
||||
|
||||
#include "ipnet.h"
|
||||
#include "ipnet_cmd.h"
|
||||
#include "ipnet_ctrl.h"
|
||||
#include "ipnet_h.h"
|
||||
#include "ipnet_routesock.h"
|
||||
#ifdef IPCOM_USE_INET6
|
||||
#include "ipnet_ip6.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPNET_IFCONFIG_CMD_UP 1 /* Bring the interface up */
|
||||
#define IPNET_IFCONFIG_CMD_ADD_ADDR 2 /* Add an address */
|
||||
|
||||
#define IPNET_IFCONFIG_OPT_NETMASK 1
|
||||
#define IPNET_IFCONFIG_OPT_PREFIXLEN 2
|
||||
#define IPNET_IFCONFIG_OPT_TENTATIVE 3
|
||||
#define IPNET_IFCONFIG_OPT_VALID 4
|
||||
#define IPNET_IFCONFIG_OPT_PREFERRED 5
|
||||
#define IPNET_IFCONFIG_OPT_TEMPORARY 6
|
||||
#define IPNET_IFCONFIG_OPT_ANYCAST 7
|
||||
#define IPNET_IFCONFIG_OPT_HOMEADDRESS 8
|
||||
|
||||
#define IPNET_IFCONFIG_CHECK_SILENT(statement) do { if (!silent) statement; } while((0))
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
struct Ipnet_ifconfig_in_addr
|
||||
{
|
||||
struct Ip_in_addr addr;
|
||||
struct Ip_in_addr mask;
|
||||
Ip_bool addr_is_set;
|
||||
Ip_bool mask_is_set;
|
||||
};
|
||||
|
||||
struct Ipnet_ifconfig_in6_addr
|
||||
{
|
||||
struct Ip_in6_addr addr;
|
||||
int flags;
|
||||
int prefixlen;
|
||||
Ip_time_t preferred_lifetime;
|
||||
Ip_time_t valid_lifetime;
|
||||
};
|
||||
|
||||
typedef struct Ipnet_cmd_ifconfig_struct
|
||||
{
|
||||
int cmd; /* The command to perform */
|
||||
Ip_u32 ifindex; /* The interface to operate on (0 == all, valid for show command) */
|
||||
int domain; /* The domain to operate in (0 == all, valid for show command) */
|
||||
union
|
||||
{
|
||||
struct Ipnet_ifconfig_in_addr inet;
|
||||
struct Ipnet_ifconfig_in6_addr inet6;
|
||||
Ip_u16 vr;
|
||||
Ip_u32 mtu;
|
||||
char *lladdr;
|
||||
struct Ip_ifreq create;
|
||||
Ip_bool promisc_mode;
|
||||
#ifdef IPNET_USE_VLAN
|
||||
struct Ip_vlanreq vlan;
|
||||
#endif /* IPNET_USE_VLAN */
|
||||
#ifdef IPNET_USE_TUNNEL
|
||||
struct Ip_ip_tunnel_param tunnel;
|
||||
#endif /* IPNET_USE_TUNNEL */
|
||||
} param;
|
||||
}
|
||||
Ipnet_cmd_ifconfig;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipnet_cmd_map[] =
|
||||
{
|
||||
{ IPNET_IFCONFIG_CMD_UP, "up" },
|
||||
{ IPNET_IFCONFIG_CMD_ADD_ADDR, "add" },
|
||||
#ifdef IPNET_USE_VLAN
|
||||
#endif /* IPNET_USE_VLAN */
|
||||
#ifdef IPNET_USE_TUNNEL
|
||||
#endif
|
||||
{ -1, IP_NULL }
|
||||
};
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipnet_switch_map[] =
|
||||
{
|
||||
{ -1, IP_NULL }
|
||||
};
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipnet_af_map[] =
|
||||
{
|
||||
#ifdef IPCOM_USE_INET
|
||||
{ IP_AF_INET, "inet" },
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
{ IP_AF_INET6, "inet6" },
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
{ -1, IP_NULL }
|
||||
};
|
||||
|
||||
IP_STATIC Ipcom_cmd_int_str_map ipnet_option_map[] =
|
||||
{
|
||||
{ IPNET_IFCONFIG_OPT_NETMASK, "netmask" },
|
||||
{ IPNET_IFCONFIG_OPT_PREFIXLEN, "prefixlen" },
|
||||
{ IPNET_IFCONFIG_OPT_TENTATIVE, "tentative" },
|
||||
{ IPNET_IFCONFIG_OPT_VALID, "valid" },
|
||||
{ IPNET_IFCONFIG_OPT_PREFERRED, "preferred" },
|
||||
{ IPNET_IFCONFIG_OPT_TEMPORARY, "temporary" },
|
||||
{ IPNET_IFCONFIG_OPT_ANYCAST, "anycast" },
|
||||
{ IPNET_IFCONFIG_OPT_HOMEADDRESS, "homeaddress" },
|
||||
{ -1, IP_NULL }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mcmd_ifconfig_create_mask
|
||||
*===========================================================================
|
||||
* Description: Creates a network mask with the 'netbits' leftmost bits set.
|
||||
* Parameters: [in] mask - Pointer to a buffer where the mask should be stored.
|
||||
* [in] netbits - The number of set bits.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_mcmd_ifconfig_create_mask(void *mask, int netbits)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < netbits; i++)
|
||||
{
|
||||
IP_BIT_SET(((Ip_u16*) mask)[i / 16], ip_htons(0x8000 >> (i % 16)));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_if_change_state
|
||||
*===========================================================================
|
||||
* Description: Change the state of a network interface.
|
||||
* Parameters: fd - A socket descriptor.
|
||||
* ifindex - The interface index for the interface to change.
|
||||
* if_up - Set to IP_TRUE if the interface should be brought up.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipnet_ifconfig_if_change_state(Ip_fd fd, Ip_u32 ifindex, Ip_bool if_up, Ip_bool silent)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
|
||||
ipcom_memset(&ifreq, 0, sizeof(struct Ip_ifreq));
|
||||
(void)ipcom_if_indextoname(ifindex, ifreq.ifr_name);
|
||||
if (ipcom_socketioctl(fd, IP_SIOCGIFFLAGS, &ifreq) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: failed to get interface flags: %s" IP_LF, ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
|
||||
if (if_up)
|
||||
IP_BIT_SET(ifreq.ip_ifr_flags, IP_IFF_UP);
|
||||
else
|
||||
IP_BIT_CLR(ifreq.ip_ifr_flags, IP_IFF_UP);
|
||||
if (ipcom_socketioctl(fd, IP_SIOCSIFFLAGS, &ifreq) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: failed to set interface flags: %s"IP_LF, ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_if_change_dhcp
|
||||
*===========================================================================
|
||||
* Description: Change the dhcp state of a network interface.
|
||||
* Parameters: fd - A socket descriptor.
|
||||
* ifindex - The interface index for the interface to change.
|
||||
* dhcp_en - Set to IP_TRUE if the interface should be configured
|
||||
* by dhcp.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
|
||||
IP_STATIC int
|
||||
ipnet_ifconfig_if_change_dhcp(Ip_fd fd, Ip_u32 ifindex, Ip_bool dhcp_en)
|
||||
{
|
||||
struct Ip_ifreq ifreq;
|
||||
|
||||
ipcom_memset(&ifreq, 0, sizeof(struct Ip_ifreq));
|
||||
(void)ipcom_if_indextoname(ifindex, ifreq.ifr_name);
|
||||
|
||||
if (dhcp_en)
|
||||
ifreq.ifr_ifru.ifru_opt = 1;
|
||||
else
|
||||
ifreq.ifr_ifru.ifru_opt = 0;
|
||||
if (ipcom_socketioctl(fd, IP_SIOCXSDHCPRUNNING, &ifreq) < 0)
|
||||
{
|
||||
ipcom_printf("ifconfig: failed to enable/disabled DHCP: %s"IP_LF, ipcom_strerror(ipcom_errno));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_ipv4_replace
|
||||
*===========================================================================
|
||||
* Description: Replaces the primary IPv4 address.
|
||||
* Parameters: ifindex - The interface index for which the primary address
|
||||
* should be changed.
|
||||
* addr - The new address.
|
||||
* mask - The new mask or IP_NULL if the mask should not be changed.
|
||||
* silent - IP_TRUE if no nothing should be printed in the case
|
||||
* on an error.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipnet_ifconfig_ipv4_replace(Ip_fd fd,
|
||||
Ip_u32 ifindex,
|
||||
struct Ip_in_addr *addr,
|
||||
struct Ip_in_addr *netmask,
|
||||
Ip_bool silent)
|
||||
{
|
||||
struct Ip_ifreq ifr;
|
||||
struct Ip_sockaddr_in *in;
|
||||
|
||||
if (addr == IP_NULL)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: address is missing" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
ipcom_memset(&ifr, 0, sizeof(struct Ip_ifreq));
|
||||
(void)ipcom_if_indextoname(ifindex, ifr.ifr_name);
|
||||
|
||||
in = (struct Ip_sockaddr_in *) &ifr.ip_ifr_addr;
|
||||
in->sin_family = IP_AF_INET;
|
||||
in->sin_len = sizeof(struct Ip_sockaddr_in);
|
||||
in->sin_addr = *addr;
|
||||
if (ipcom_socketioctl(fd, IP_SIOCSIFADDR, &ifr) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: ipcom_socketioctl() failed to set primary IPv4 address: %s" IP_LF,
|
||||
ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
|
||||
if (netmask == IP_NULL)
|
||||
return 0;
|
||||
|
||||
in->sin_addr = *netmask;
|
||||
if (ipcom_socketioctl(fd, IP_SIOCSIFNETMASK, &ifr) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: ipcom_socketioctl() failed to set mask for primary IPv4 address: %s" IP_LF,
|
||||
ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_ipv4_add_delete
|
||||
*===========================================================================
|
||||
* Description: Adds or deletes a IPv4 address.
|
||||
* Parameters: add - Set to IP_TRUE to add the address.
|
||||
* ifindex - The interface the address should be added to.
|
||||
* addr - The address to add/delete
|
||||
* netmask - The netmask to add.
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipnet_ifconfig_ipv4_add_delete(Ip_fd fd,
|
||||
Ip_bool add,
|
||||
Ip_u32 ifindex,
|
||||
struct Ip_in_addr *addr,
|
||||
struct Ip_in_addr *netmask,
|
||||
Ip_bool silent)
|
||||
{
|
||||
struct Ip_ifaliasreq ifal;
|
||||
struct Ip_sockaddr_in *in_addr;
|
||||
struct Ip_sockaddr_in *in_mask;
|
||||
|
||||
if (addr == IP_NULL)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: address is missing" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
ipcom_memset(&ifal, 0, sizeof(struct Ip_ifaliasreq));
|
||||
(void)ipcom_if_indextoname(ifindex, ifal.ifra_name);
|
||||
|
||||
/* Adding address and mask. */
|
||||
in_addr = (struct Ip_sockaddr_in *) &ifal.ifra_addr;
|
||||
in_addr->sin_family = IP_AF_INET;
|
||||
in_addr->sin_len = sizeof(struct Ip_sockaddr_in);
|
||||
in_addr->sin_addr = *addr;
|
||||
|
||||
if (netmask != IP_NULL)
|
||||
{
|
||||
if (!add)
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("warning: mask is ignored in delete operations" IP_LF));
|
||||
else
|
||||
{
|
||||
in_mask = (struct Ip_sockaddr_in *) &ifal.ifra_mask;
|
||||
in_mask->sin_family = IP_AF_INET;
|
||||
in_mask->sin_len = sizeof(struct Ip_sockaddr_in);
|
||||
in_mask->sin_addr = *netmask;
|
||||
}
|
||||
}
|
||||
|
||||
if (ipcom_socketioctl(fd, add ? IP_SIOCAIFADDR : IP_SIOCDIFADDR, &ifal) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: ipcom_socketioctl() failed to %s IPv4 address: %s" IP_LF,
|
||||
add ? "add" : "delete",
|
||||
ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
|
||||
#ifndef IP_PORT_LAS
|
||||
if (IP_IN_CLASSD(addr->s_addr) == IP_FALSE)
|
||||
/* Unicast address was changed manually. Disable dhcp on the interface */
|
||||
return ipnet_ifconfig_if_change_dhcp(fd, ifindex, IP_FALSE);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
|
||||
|
||||
#ifdef IPCOM_USE_INET6
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipnet_ifconfig_ipv6_add
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipnet_ifconfig_ipv6_add(Ip_fd fd,
|
||||
Ip_u32 ifindex,
|
||||
struct Ipnet_ifconfig_in6_addr *param,
|
||||
Ip_bool silent)
|
||||
{
|
||||
struct Ip_in6_aliasreq ifareq;
|
||||
|
||||
ipcom_memset(&ifareq, 0, sizeof(ifareq));
|
||||
(void)ipcom_if_indextoname(ifindex, ifareq.ifra_name);
|
||||
|
||||
ifareq.ifra_addr.sin6_family = IP_AF_INET6;
|
||||
ifareq.ifra_addr.sin6_len = sizeof(struct Ip_sockaddr_in6);
|
||||
ifareq.ifra_addr.sin6_addr = param->addr;
|
||||
if (IP_IN6_IS_ADDR_LINK_LOCAL(¶m->addr))
|
||||
ifareq.ifra_addr.sin6_scope_id = ifindex;
|
||||
|
||||
ifareq.ifra_prefixmask.sin6_family = IP_AF_INET6;
|
||||
ifareq.ifra_prefixmask.sin6_len = sizeof(struct Ip_sockaddr_in6);
|
||||
ipcom_mcmd_ifconfig_create_mask(&ifareq.ifra_prefixmask.sin6_addr, param->prefixlen);
|
||||
|
||||
ifareq.ifra_flags = param->flags;
|
||||
|
||||
if (param->preferred_lifetime != (Ip_time_t)IPCOM_ADDR_INFINITE)
|
||||
ifareq.ifra_lifetime.ia6t_preferred = param->preferred_lifetime + ipcom_time(IP_NULL);
|
||||
else
|
||||
ifareq.ifra_lifetime.ia6t_preferred = (Ip_time_t)IPCOM_ADDR_INFINITE;
|
||||
|
||||
if (ifareq.ifra_lifetime.ia6t_expire != (Ip_time_t)IPCOM_ADDR_INFINITE)
|
||||
ifareq.ifra_lifetime.ia6t_expire = param->valid_lifetime + ipcom_time(IP_NULL);
|
||||
else
|
||||
ifareq.ifra_lifetime.ia6t_expire = (Ip_time_t)IPCOM_ADDR_INFINITE;
|
||||
|
||||
if (ipcom_socketioctl(fd, IP_SIOCAIFADDR_IN6, &ifareq) < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: ipcom_socketioctl() failed to add IPv6 address: %s" IP_LF,
|
||||
ipcom_strerror(ipcom_errno)));
|
||||
return -ipcom_errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mcmd_ifconfig_parse_arg
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_mcmd_ifconfig_parse_arg(int argc,
|
||||
int *next_arg,
|
||||
char **argv,
|
||||
Ipnet_cmd_ifconfig *cmd,
|
||||
Ip_bool silent)
|
||||
{
|
||||
int domain;
|
||||
char *str_prefixlen;
|
||||
|
||||
domain = ipcom_cmd_str_to_key(ipnet_af_map, argv[*next_arg]);
|
||||
if (domain > 0)
|
||||
{
|
||||
/* Domain specifed */
|
||||
cmd->domain = domain;
|
||||
++*next_arg;
|
||||
}
|
||||
|
||||
cmd->cmd = ipcom_cmd_str_to_key(ipnet_cmd_map, argv[*next_arg]);
|
||||
if (cmd->cmd < 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: '%s' unknown command" IP_LF, argv[*next_arg]));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
++*next_arg;
|
||||
|
||||
switch (cmd->cmd)
|
||||
{
|
||||
case IPNET_IFCONFIG_CMD_ADD_ADDR :
|
||||
if (cmd->domain <= 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: missing <family>" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
if (*next_arg >= argc)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: missing <address>" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (cmd->domain == IP_AF_INET)
|
||||
{
|
||||
int prefixlen = -1;
|
||||
|
||||
if (ipcom_inet_pton(IP_AF_INET, argv[*next_arg], &cmd->param.inet.addr) != 1)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: %s is not a valid inet <address>" IP_LF,
|
||||
argv[*next_arg]));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
|
||||
cmd->param.inet.addr_is_set = IP_TRUE;
|
||||
cmd->param.inet.mask_is_set = IP_FALSE;
|
||||
|
||||
str_prefixlen = ipcom_strstr(argv[*next_arg], "/");
|
||||
if (str_prefixlen != IP_NULL && ipcom_strlen(str_prefixlen) > 1)
|
||||
prefixlen = ipcom_atoi(str_prefixlen + 1);
|
||||
|
||||
++*next_arg;
|
||||
while (*next_arg < argc)
|
||||
{
|
||||
switch (ipcom_cmd_str_to_key(ipnet_option_map, argv[*next_arg]))
|
||||
{
|
||||
case IPNET_IFCONFIG_OPT_NETMASK:
|
||||
++*next_arg;
|
||||
if (ipcom_inet_pton(IP_AF_INET, argv[*next_arg], &cmd->param.inet.mask) != 1)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: %s is not a valid inet <netmask>" IP_LF,
|
||||
argv[*next_arg]));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
++*next_arg;
|
||||
cmd->param.inet.mask_is_set = IP_TRUE;
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_PREFIXLEN:
|
||||
++*next_arg;
|
||||
prefixlen = ipcom_atoi(argv[*next_arg]);
|
||||
++*next_arg;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefixlen != -1 && cmd->param.inet.mask_is_set == IP_FALSE)
|
||||
{
|
||||
if (prefixlen <= 0 || prefixlen > 32)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: inet <prefixlen> must be a value 1 - 32" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
cmd->param.inet.mask.s_addr = 0;
|
||||
ipcom_mcmd_ifconfig_create_mask(&cmd->param.inet.mask, prefixlen);
|
||||
cmd->param.inet.mask_is_set = IP_TRUE;
|
||||
}
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (cmd->domain == IP_AF_INET6)
|
||||
{
|
||||
if (ipcom_inet_pton(IP_AF_INET6, argv[*next_arg], &cmd->param.inet6.addr) != 1)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: %s is not a valid inet6 <address>" IP_LF,
|
||||
argv[*next_arg]));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
cmd->param.inet6.flags = 0;
|
||||
cmd->param.inet6.prefixlen = 64;
|
||||
cmd->param.inet6.preferred_lifetime = (Ip_time_t)IPCOM_ADDR_INFINITE;
|
||||
cmd->param.inet6.valid_lifetime = (Ip_time_t)IPCOM_ADDR_INFINITE;
|
||||
|
||||
str_prefixlen = ipcom_strstr(argv[*next_arg], "/");
|
||||
if (str_prefixlen != IP_NULL && ipcom_strlen(str_prefixlen) > 1)
|
||||
cmd->param.inet6.prefixlen = ipcom_atoi(str_prefixlen + 1);
|
||||
|
||||
++*next_arg;
|
||||
while (*next_arg < argc)
|
||||
{
|
||||
switch (ipcom_cmd_str_to_key(ipnet_option_map, argv[(*next_arg)++]))
|
||||
{
|
||||
case IPNET_IFCONFIG_OPT_TENTATIVE:
|
||||
IP_BIT_SET(cmd->param.inet6.flags, IP_IN6_IFF_TENTATIVE);
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_TEMPORARY:
|
||||
IP_BIT_SET(cmd->param.inet6.flags, IP_IN6_IFF_TEMPORARY);
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_ANYCAST:
|
||||
IP_BIT_SET(cmd->param.inet6.flags, IP_IN6_IFF_ANYCAST);
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_HOMEADDRESS:
|
||||
IP_BIT_SET(cmd->param.inet6.flags, IP_IN6_IFF_HOMEADDRESS);
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_PREFIXLEN:
|
||||
cmd->param.inet6.prefixlen = ipcom_atoi(argv[*next_arg]);
|
||||
++*next_arg;
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_VALID:
|
||||
cmd->param.inet6.valid_lifetime = ipcom_atoi(argv[*next_arg]);
|
||||
break;
|
||||
case IPNET_IFCONFIG_OPT_PREFERRED:
|
||||
cmd->param.inet6.preferred_lifetime = ipcom_atoi(argv[*next_arg]);
|
||||
break;
|
||||
default:
|
||||
--*next_arg;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (cmd->param.inet6.prefixlen <= 0 || cmd->param.inet6.prefixlen > 128)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(
|
||||
ipcom_printf("ifconfig: inet6 <prefixlen> must be a value 1 - 128" IP_LF));
|
||||
return -IP_ERRNO_EINVAL;
|
||||
}
|
||||
}
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mcmd_ifconfig
|
||||
*===========================================================================
|
||||
* Description: ifconfig shell command entry point.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_mcmd_ifconfig(int argc, char **argv)
|
||||
{
|
||||
int next_arg;
|
||||
Ip_fd fd;
|
||||
Ipnet_cmd_ifconfig cmd;
|
||||
int err = 0;
|
||||
IP_CONST char *ifname = IP_NULL;
|
||||
int silent = IP_FALSE;
|
||||
next_arg = 1;
|
||||
|
||||
/* Silent must only be used by the configuration daemon */
|
||||
if (argc > next_arg && ipcom_strcmp(argv[next_arg], "-silent") == 0)
|
||||
{
|
||||
silent = IP_TRUE;
|
||||
next_arg++;
|
||||
}
|
||||
|
||||
#ifdef IPCOM_USE_INET
|
||||
fd = ipcom_socket(IP_AF_INET, IP_SOCK_DGRAM, 0);
|
||||
#else
|
||||
fd = ipcom_socket(IP_AF_INET6, IP_SOCK_DGRAM, 0);
|
||||
#endif
|
||||
if (fd == IP_SOCKERR)
|
||||
{
|
||||
ipcom_printf("ifconfig: ipcom_socket() failed: %s"IP_LF, ipcom_strerror(ipcom_errno));
|
||||
goto errout;
|
||||
}
|
||||
|
||||
ipcom_memset(&cmd, 0, sizeof(cmd));
|
||||
|
||||
/* Process all switches */
|
||||
while (argc > next_arg && cmd.cmd != -1)
|
||||
{
|
||||
cmd.cmd = ipcom_cmd_str_to_key(ipnet_switch_map, argv[next_arg]);
|
||||
switch (cmd.cmd)
|
||||
{
|
||||
default:
|
||||
if (argv[next_arg][0] == '-' && cmd.cmd == -1)
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("'%s' is a unknown switch"IP_LF, argv[next_arg]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == next_arg)
|
||||
goto errout;
|
||||
|
||||
/* Process all commands */
|
||||
while (next_arg < argc && err == 0)
|
||||
{
|
||||
ipcom_memset(&cmd.param, 0, sizeof(cmd.param));
|
||||
if (ifname == IP_NULL)
|
||||
ifname = argv[next_arg++];
|
||||
|
||||
if (ipcom_mcmd_ifconfig_parse_arg(argc, &next_arg, argv, &cmd, silent) < 0)
|
||||
goto errout;
|
||||
|
||||
{
|
||||
cmd.ifindex = ipcom_if_nametoindex(ifname);
|
||||
if (cmd.ifindex == 0)
|
||||
{
|
||||
IPNET_IFCONFIG_CHECK_SILENT(ipcom_printf("ifconfig: interface %s not found"IP_LF, ifname));
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
switch (cmd.cmd)
|
||||
{
|
||||
case IPNET_IFCONFIG_CMD_UP :
|
||||
err = ipnet_ifconfig_if_change_state(fd, cmd.ifindex, IP_TRUE, silent);
|
||||
break;
|
||||
case IPNET_IFCONFIG_CMD_ADD_ADDR :
|
||||
#ifdef IPCOM_USE_INET
|
||||
if (cmd.domain == IP_AF_INET)
|
||||
{
|
||||
err = ipnet_ifconfig_ipv4_add_delete(fd,
|
||||
IP_TRUE,
|
||||
cmd.ifindex,
|
||||
cmd.param.inet.addr_is_set ? &cmd.param.inet.addr : IP_NULL,
|
||||
cmd.param.inet.mask_is_set ? &cmd.param.inet.mask : IP_NULL,
|
||||
silent);
|
||||
}
|
||||
#endif /* IPCOM_USE_INET */
|
||||
#ifdef IPCOM_USE_INET6
|
||||
if (cmd.domain == IP_AF_INET6)
|
||||
err = ipnet_ifconfig_ipv6_add(fd, cmd.ifindex, &cmd.param.inet6, silent);
|
||||
#endif /* IPCOM_USE_INET6 */
|
||||
break;
|
||||
#ifdef IPNET_USE_VLAN
|
||||
#endif /* IPNET_USE_VLAN */
|
||||
default:
|
||||
IP_PANIC();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (fd != IP_INVALID_SOCKET)
|
||||
(void)ipcom_socketclose(fd);
|
||||
|
||||
return err;
|
||||
|
||||
errout:
|
||||
err = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
#else /* IPLITE */
|
||||
IP_PUBLIC int
|
||||
ipcom_mcmd_ifconfig(int argc, char **argv)
|
||||
{
|
||||
printf("IMPLEMENT mcmd_ifconfig!!!\n");
|
||||
IP_PANIC();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_mutex.c,v $ $Revision: 1.3.10.4 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_mutex.c,v $
|
||||
* $Author: hxie $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <semLib.h>
|
||||
#include <taskLib.h>
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include "ipcom_sem.h"
|
||||
#include "ipcom_syslog.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#undef IPCOM_SYSLOG_PRIORITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
|
||||
#ifdef IP_ASSERT
|
||||
#define CHK(x) chk(x, #x, __FILE__, __LINE__)
|
||||
#define PCHK(x) pchk(x, #x, __FILE__, __LINE__)
|
||||
#else
|
||||
#define CHK(x) (x)
|
||||
#define PCHK(x) (x)
|
||||
#endif
|
||||
|
||||
#undef ipcom_mutex_lock
|
||||
#undef ipcom_mutex_unlock
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if (!defined(IPCOM_SYSLOG) || IPCOM_SYSLOG == 1) && !defined(IPCOM_USE_CLIB_PROTO)
|
||||
IP_EXTERN IP_PUBLIC void
|
||||
ipcom_syslog(Ip_u32 priority, const char *format, ...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* chk
|
||||
*===========================================================================
|
||||
* Description: Check system call.
|
||||
* Parameters: Status.
|
||||
* Returns: Status.
|
||||
*
|
||||
*/
|
||||
#ifdef IP_ASSERT
|
||||
IP_STATIC STATUS
|
||||
chk(int status, char *msg, char *file, int line)
|
||||
{
|
||||
if (status == ERROR)
|
||||
{
|
||||
IPCOM_LOG4(ERR, "VxWorks returned ERROR at %s(%d): %s, errno:%d\n",
|
||||
file, line, msg, errno);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* pchk
|
||||
*===========================================================================
|
||||
* Description: Check system call.
|
||||
* Parameters: Status.
|
||||
* Returns: Status.
|
||||
*
|
||||
*/
|
||||
#ifdef IP_ASSERT
|
||||
IP_STATIC void *
|
||||
pchk(void *status, char *msg, char *file, int line)
|
||||
{
|
||||
if (status == NULL)
|
||||
{
|
||||
IPCOM_LOG4(ERR, "VxWorks returned NULL at %s(%d): %s, errno:%d\n",
|
||||
file, line, msg, errno);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mutex_create
|
||||
*===========================================================================
|
||||
* Description: Create mutex with undefined queue order.
|
||||
* Parameters: Pointer to mutex descriptor.
|
||||
* Returns: IPCOM_SUCCESS if success.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_mutex_create(Ipcom_mutex *mutex)
|
||||
{
|
||||
*mutex = (Ipcom_mutex)PCHK(semMCreate(MUTEX_CREATE_OPTS));
|
||||
if (*mutex != NULL)
|
||||
{
|
||||
#if defined(_WRS_CONFIG_RTP) && defined(_WRS_CONFIG_OBJECT_OWNERSHIP)
|
||||
/* Set kernel as owner to disable possible RTP cleanup */
|
||||
if (objOwnerSet(*mutex, kernelId) == OK)
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
semDelete((SEM_ID)*mutex);
|
||||
#else
|
||||
return IPCOM_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mutex_delete
|
||||
*===========================================================================
|
||||
* Description: Delete mutex. The mutex must be empty,
|
||||
* i.e. have no pending processes.
|
||||
* Parameters: Mutex descriptor.
|
||||
* Returns: 0 if success.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_err
|
||||
ipcom_mutex_delete(Ipcom_mutex *mutex)
|
||||
{
|
||||
STATUS ret;
|
||||
|
||||
ip_assert(*mutex != IPCOM_MUTEX_INVALID);
|
||||
|
||||
ret = CHK(semDelete((SEM_ID)*mutex));
|
||||
*mutex = IPCOM_MUTEX_INVALID;
|
||||
|
||||
return (ret == OK) ? IPCOM_SUCCESS : IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mutex_lock
|
||||
*===========================================================================
|
||||
* Description: Lock mutex. Recursive calls by the same process
|
||||
* are not allowed.
|
||||
* Parameters: Mutex descriptor.
|
||||
* Returns: Nothing.
|
||||
*
|
||||
*/
|
||||
IP_FASTTEXT IP_PUBLIC void
|
||||
ipcom_mutex_lock(Ipcom_mutex mutex)
|
||||
{
|
||||
CHK(SEM_M_TAKE(mutex, WAIT_FOREVER));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mutex_unlock
|
||||
*===========================================================================
|
||||
* Description: Unlock mutex. Only the process that owns
|
||||
* the mutex may unlock it.
|
||||
* Parameters: Mutex descriptor.
|
||||
* Returns: Nothing.
|
||||
*
|
||||
*/
|
||||
IP_FASTTEXT IP_PUBLIC void
|
||||
ipcom_mutex_unlock(Ipcom_mutex mutex)
|
||||
{
|
||||
CHK(SEM_M_GIVE(mutex));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_nae_vxworks.c,v $ $Revision: 1.11.2.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_nae_vxworks.c,v $
|
||||
* $Author: svc-cmnet $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* This is the port specific part of the 'ipcom_forwarder'. It is only valid
|
||||
* if IPCOM_USE_FORWARDER is defined (typically in ipcom/config/ipcom_config.h)
|
||||
* When IPCOM_USE_FORWARDER is not defined the contents of this file is
|
||||
* "ifdefed out"
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_NAE_VXWORKS_C
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/* Refer to description above */
|
||||
#if defined(IPCOM_FORWARDER_NAE)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <endLib.h>
|
||||
#include <memLib.h>
|
||||
#include <multios_ipc/mipc.h>
|
||||
#include <string.h>
|
||||
#include <symLib.h>
|
||||
#include <sysSymTbl.h>
|
||||
#include <vxCpuLib.h>
|
||||
#include <vxWorks.h>
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_clib2.h"
|
||||
#include "ipcom_cstyle.h"
|
||||
#include "ipcom_nae.h"
|
||||
#include "ipcom_netif.h"
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_vxworks.h"
|
||||
|
||||
#include "ipcom_mipc.h"
|
||||
#include "ipcom_forwarder.h"
|
||||
#include "ipcom_syslog.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 EXTERNAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_EXTERN void ipcom_mipc_send_slow_path(void *work, Ipcom_pkt *update_pkt);
|
||||
|
||||
/* TODO: should ipcom_mipc_vaprintf() return the number of characters
|
||||
written? */
|
||||
IP_EXTERN void ipcom_mipc_vaprintf(const char *fmt, va_list vargs);
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5.1 LOCAL DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef IPCOM_USE_P4080_FORWARDER
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mipc_printf
|
||||
*===========================================================================
|
||||
* Context: any nae
|
||||
* Description: print on control NAE console
|
||||
* Parameters: fmt : printf format string
|
||||
* ... : arguments to format string
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_mipc_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ipcom_mipc_vaprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mipc_syslog
|
||||
*===========================================================================
|
||||
* Context: any nae
|
||||
* Description: print on control NAE console
|
||||
* Parameters: fmt : printf format string
|
||||
* ... : arguments to format string
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_mipc_syslog(Ip_u32 priority, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[2000];
|
||||
int len;
|
||||
|
||||
len = ipcom_sprintf(buf, "nae[%d]: %s: %s: ",
|
||||
(int)ipcom_forwarder_nae_id(),
|
||||
ipcom_syslog_facility_names[IPCOM_LOG_FAC(priority)],
|
||||
ipcom_syslog_priority_names[priority & IPCOM_LOG_PRIMASK]);
|
||||
|
||||
va_start(ap, format);
|
||||
|
||||
ipcom_vsnprintf(buf + len, sizeof(buf) - len - 1, format, ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
ipcom_strcat(buf, "\n");
|
||||
ipcom_mipc_printf(buf);
|
||||
}
|
||||
#endif /* IPCOM_USE_P4080_FORWARDER */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_sym_from_name
|
||||
*===========================================================================
|
||||
* Description: Returns the address of the symbol with name 'sym_name'
|
||||
* Parameters: sym_name - name of a symbol.
|
||||
* Returns: Address to the symbol or IP_NULL if no symbol with the
|
||||
* passed name was found.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ipcom_func_ptr
|
||||
ipcom_sym_from_name(const char *sym_name)
|
||||
{
|
||||
STATUS status;
|
||||
union
|
||||
{
|
||||
void *var;
|
||||
Ipcom_func_ptr func;
|
||||
} ptr;
|
||||
SYM_TYPE type;
|
||||
|
||||
/*
|
||||
* union needed to suppress warning about "ISO C forbids
|
||||
* conversion of object pointer to function pointer type".
|
||||
*/
|
||||
|
||||
status = symFindByName (sysSymTbl,
|
||||
(char *)sym_name,
|
||||
(char **)&ptr.var,
|
||||
&type);
|
||||
if (status != OK)
|
||||
{
|
||||
char *_sym_name;
|
||||
|
||||
/*
|
||||
* Search the symbol table for prepend and not prepend symbol
|
||||
* name: compiler for some architectures append the '_' to the
|
||||
* symbol name.
|
||||
*/
|
||||
_sym_name = malloc(1 + strlen(sym_name) + 1);
|
||||
if (_sym_name)
|
||||
{
|
||||
sprintf("_%s", sym_name);
|
||||
status = symFindByName (sysSymTbl,
|
||||
_sym_name,
|
||||
(char **)&ptr.var,
|
||||
&type);
|
||||
free(_sym_name);
|
||||
}
|
||||
}
|
||||
|
||||
return status == OK ? ptr.func : NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_nae_is_primary
|
||||
*===========================================================================
|
||||
* Description: Returns whether this is the primary NAE or not.
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_bool
|
||||
ipcom_nae_is_primary(void)
|
||||
{
|
||||
return ipcom_forwarder_is_master();
|
||||
}
|
||||
|
||||
|
||||
#ifdef IP_LW_DEBUG
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_nae_owner_set
|
||||
*===========================================================================
|
||||
* Description: Set calling nae as owner of a pkt
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_nae_owner_set(Ipcom_pkt *pkt)
|
||||
{
|
||||
pkt->nae_owner = ipcom_nae_ix() + 1;
|
||||
ipcom_nae_wmb();
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_nae_owner_clear
|
||||
*===========================================================================
|
||||
* Description: Clear owner of a pkt
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_nae_owner_clear(Ipcom_pkt *pkt)
|
||||
{
|
||||
pkt->nae_owner = 0;
|
||||
ipcom_nae_wmb();
|
||||
}
|
||||
#endif /* IP_LW_DEBUG */
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pkt_to_master_os
|
||||
*===========================================================================
|
||||
* Context: forwarder (NAE or cNAE)
|
||||
* Description: send packet to management os
|
||||
* Parameters: pkt : ipcom packet reference
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_pkt_to_master_os(Ipcom_pkt *pkt)
|
||||
{
|
||||
Ipcom_pkt *frag;
|
||||
if (pkt->nae_ctx == IP_NULL)
|
||||
{
|
||||
/* No NAE context in this frame; do we have an original? */
|
||||
if (IP_LIKELY(IP_NULL != pkt->next_original))
|
||||
{
|
||||
ipcom_pkt_to_master_os(pkt->next_original);
|
||||
pkt->next_original = IP_NULL;
|
||||
}
|
||||
|
||||
ipcom_pkt_free(pkt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IP_UNLIKELY(IP_NULL != (frag = pkt->next_fragment)))
|
||||
{
|
||||
/* Unlink the fragment chain */
|
||||
pkt->next_fragment = IP_NULL;
|
||||
|
||||
/* Forward the first frame */
|
||||
/* To Do!!: temporarily disable on P4080, whether use similar code in Nehalem
|
||||
or code from P4080 ipcom_forwarder_slow_path */
|
||||
#ifndef IPCOM_USE_P4080_FORWARDER
|
||||
ipcom_mipc_send_slow_path(pkt->nae_ctx, pkt);
|
||||
#endif
|
||||
|
||||
/* Do send the next fragment chain to the slow path */
|
||||
ipcom_pkt_to_master_os(frag);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No special processing; just send */
|
||||
/* To Do!!: temporarily disable on P4080 */
|
||||
#ifndef IPCOM_USE_P4080_FORWARDER
|
||||
ipcom_mipc_send_slow_path(pkt->nae_ctx, pkt);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* IPCOM_FORWARDER_NAE */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,765 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pfile.c,v $ $Revision: 1.25.10.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_pfile.c,v $
|
||||
* $Author: fguo $ $Date: 2012-07-04 06:56:42 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* ipcom_file.c contains source code for mapping to vxworks filesystem.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
#define IPCOM_SKIP_NATIVE_SOCK_API
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_file.h"
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_err.h"
|
||||
#include "ipcom_shell.h"
|
||||
#include "ipcom_os.h"
|
||||
#include "ipcom_vxworks.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <taskLib.h>
|
||||
#include <iosLib.h>
|
||||
#include <errnoLib.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fileclose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fileclose(Ip_fd fildes)
|
||||
{
|
||||
return close((int)fildes);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fileread
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_fileread(Ip_fd fildes, void *buf, Ip_size_t nbyte)
|
||||
{
|
||||
return (Ip_ssize_t)read((int)fildes, buf, (size_t)nbyte);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fileopen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
* More stuff from unistd.h missing ...
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fileopen(const char *pathname, int omode, Ip_mode_t attrs)
|
||||
{
|
||||
return open(pathname, (int)omode, (mode_t)attrs);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fstat
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* VxWork's struct stat is of a different size, compared to struct Ip_stat.
|
||||
* Furthermore the struct members come in a different order.
|
||||
*
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fstat(int fildes, struct Ip_stat *buf)
|
||||
{
|
||||
struct stat vxworks_stat;
|
||||
int rc;
|
||||
rc = fstat((int)fildes, &vxworks_stat);
|
||||
if (rc == OK)
|
||||
{
|
||||
buf->st_mode = vxworks_stat.st_mode;
|
||||
buf->st_ino = (Ip_ino_t)vxworks_stat.st_ino;
|
||||
buf->st_dev = vxworks_stat.st_dev;
|
||||
buf->st_nlink = (Ip_nlink_t)vxworks_stat.st_nlink;
|
||||
buf->st_uid = vxworks_stat.st_uid;
|
||||
buf->st_gid = vxworks_stat.st_gid;
|
||||
buf->st_size = vxworks_stat.st_size;
|
||||
buf->st_atime = vxworks_stat.st_atime;
|
||||
buf->st_mtime = vxworks_stat.st_mtime;
|
||||
buf->st_ctime = vxworks_stat.st_ctime;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_stat
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* VxWork's struct stat is of a different size, compared to struct Ip_stat.
|
||||
* Furthermore the struct members come in a different order.
|
||||
*
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_stat(const char *pathname, struct Ip_stat *buf)
|
||||
{
|
||||
struct stat vxworks_stat;
|
||||
int rc;
|
||||
|
||||
rc = stat((char*) pathname, &vxworks_stat);
|
||||
if (rc == OK)
|
||||
{
|
||||
buf->st_mode = vxworks_stat.st_mode;
|
||||
buf->st_ino = (Ip_ino_t)vxworks_stat.st_ino;
|
||||
buf->st_dev = vxworks_stat.st_dev;
|
||||
buf->st_nlink = (Ip_nlink_t)vxworks_stat.st_nlink;
|
||||
buf->st_uid = vxworks_stat.st_uid;
|
||||
buf->st_gid = vxworks_stat.st_gid;
|
||||
buf->st_size = vxworks_stat.st_size;
|
||||
buf->st_atime = vxworks_stat.st_atime;
|
||||
buf->st_mtime = vxworks_stat.st_mtime;
|
||||
buf->st_ctime = vxworks_stat.st_ctime;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fopen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_FILE *
|
||||
ipcom_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
return (IP_FILE *)fopen(filename, mode);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fclose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fclose(IP_FILE *stream)
|
||||
{
|
||||
return fclose((FILE *)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fwrite
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns: function returns the number of items written.
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_fwrite(const void *ptr, Ip_size_t size, Ip_size_t nitems, IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
Ipcom_proc *proc;
|
||||
|
||||
/* If we are executing in ipcom shell and the stream is stdin or stdout, use ipcom shell io */
|
||||
proc = ipcom_proc_find(taskIdSelf(), IP_FALSE);
|
||||
if (proc && (proc->shell_fd != IP_INVALID_SOCKET) && (stream == ip_stdout || stream == ip_stderr))
|
||||
return ipcom_shell_fwrite(ptr, size, nitems, stream);
|
||||
#endif
|
||||
|
||||
/* VXWORKS FILESYSTEM */
|
||||
return (Ip_size_t)fwrite(ptr, (size_t)size, (size_t)nitems, (FILE *)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fread
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_fread(void *ptr, Ip_size_t size, Ip_size_t nitems, IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if (stream == ip_stdin)
|
||||
return ipcom_shell_fread(ptr, size, nitems, stream);
|
||||
#endif
|
||||
|
||||
/* VXWORKS FILESYSTEM */
|
||||
return (Ip_size_t)fread(ptr, (size_t)size, (size_t)nitems, (FILE *)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_opendir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_DIR *
|
||||
ipcom_opendir(const char *dirname)
|
||||
{
|
||||
return (IP_DIR *)opendir( (char*) dirname);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_readdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC struct Ip_dirent *
|
||||
ipcom_readdir(IP_DIR *dirp)
|
||||
{
|
||||
static struct Ip_dirent dir_entry;
|
||||
struct dirent *tmp;
|
||||
|
||||
tmp = readdir((DIR *)dirp);
|
||||
if (tmp != IP_NULL)
|
||||
{
|
||||
dir_entry.d_namlen = (Ip_u32)ipcom_strlen(tmp->d_name);
|
||||
ipcom_strcpy(dir_entry.d_name, tmp->d_name);
|
||||
return &dir_entry;
|
||||
}
|
||||
else
|
||||
return IP_NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_closedir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_closedir(IP_DIR *dirp)
|
||||
{
|
||||
return closedir((DIR *)dirp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fileno
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_fd
|
||||
ipcom_fileno(IP_FILE *stream)
|
||||
{
|
||||
return (Ip_fd)fileno((FILE*)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_unlink
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_unlink(const char *pathname)
|
||||
{
|
||||
return unlink( (char*)pathname );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ferror
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_ferror(IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if (stream == ip_stdin)
|
||||
return 0;
|
||||
#endif
|
||||
return ferror((FILE*)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_feof
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_feof(IP_FILE *stream)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if (stream == ip_stdin)
|
||||
return 0;
|
||||
#endif
|
||||
return feof((FILE*)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fseek
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fseek(IP_FILE *stream, int offset, int whence)
|
||||
{
|
||||
return fseek((FILE*)stream, (long int)offset, (int)whence);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_ftell
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_ftell(IP_FILE *stream)
|
||||
{
|
||||
return (int)ftell((FILE*)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_lseek
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_off_t
|
||||
ipcom_lseek(Ip_fd fildes, Ip_off_t offset, int whence)
|
||||
{
|
||||
return lseek((int)fildes, (off_t)offset, (int)whence);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_rename
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_rename(const char *old, const char *new)
|
||||
{
|
||||
return rename(old, new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fdopen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC IP_FILE *
|
||||
ipcom_fdopen(Ip_fd fd, const char *mode)
|
||||
{
|
||||
return (IP_FILE*)fdopen((int)fd, mode);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getcwd
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC char *
|
||||
ipcom_getcwd(char *buf, Ip_size_t size)
|
||||
{
|
||||
return getcwd(buf, (size_t)size);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_mkdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_mkdir(const char *path, Ip_mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
/* umask? */
|
||||
fd = open (path, O_RDWR | O_CREAT, FSTAT_DIR | (mode & 0777));
|
||||
|
||||
if (fd == ERROR)
|
||||
return (ERROR);
|
||||
|
||||
return (close (fd));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_rmdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_rmdir(const char *dirName)
|
||||
{
|
||||
/*
|
||||
* Hmm. This duplicates code in usrFsLib.c to avoid bringing the
|
||||
* whole of usrFsLib.c into the image.
|
||||
*/
|
||||
int fd;
|
||||
int error;
|
||||
STATUS status;
|
||||
struct stat stat;
|
||||
|
||||
if ((fd = open (dirName, O_RDONLY, 0)) == ERROR)
|
||||
return (ERROR);
|
||||
|
||||
if (fstat (fd, &stat) != OK) /* Obtain file stats on <dirName>. */
|
||||
{
|
||||
error = errnoGet ();
|
||||
close (fd);
|
||||
errnoSet (error);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (!S_ISDIR (stat.st_mode)) /* If it is not a directory, then */
|
||||
{ /* set <errno> and return ERROR. */
|
||||
close (fd);
|
||||
errnoSet (ENOTDIR);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
status = ioctl (fd, FIORMDIR, dirName);
|
||||
error = errnoGet ();
|
||||
close (fd);
|
||||
|
||||
if ((status != OK) && ((error == ENOTSUP) || (error == ENOSYS)))
|
||||
return (remove (dirName));
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_chdir
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_chdir(const char *path)
|
||||
{
|
||||
#if 1
|
||||
DIR *dir;
|
||||
|
||||
/*
|
||||
* VxWorks filesystem does not check that the destination dir is valid--
|
||||
* this must be done by the clients.
|
||||
*/
|
||||
if ((dir = opendir(path)) == NULL)
|
||||
return -1;
|
||||
|
||||
(void)closedir(dir);
|
||||
|
||||
return chdir((char*)path);
|
||||
#else
|
||||
/*!! Old code due to problems with relative paths in older vxWorks kernel.
|
||||
* Unsure if we still need it?? /Lennart Bang 2006-09-27
|
||||
*/
|
||||
char buf[128];
|
||||
char *tmp;
|
||||
|
||||
/* Check if the path is an absolute path */
|
||||
if (iosDevFind((char*)path, (const char **)&tmp) != NULL && path != tmp)
|
||||
return chdir((char*)path);
|
||||
|
||||
/* Convert relative path to absolute path */
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_chdir :: getcwd failed, errno: %x", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ipcom_strlen(buf) + 1 + ipcom_strlen(path) + 1 > sizeof(buf))
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ipcom_chdir :: constructed absolute path would exceed max length");
|
||||
return -1;
|
||||
}
|
||||
if (buf[ipcom_strlen(buf)-1] != '/')
|
||||
ipcom_strcat(buf, "/");
|
||||
ipcom_strcat(buf, path);
|
||||
|
||||
return chdir(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_fflush
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_fflush(IP_FILE *file)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if (file == ip_stdout || file == ip_stderr)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return fflush((FILE*)file);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_filewrite
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_filewrite(Ip_fd fd, const void *buffer, Ip_size_t nbyte)
|
||||
{
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
||||
if (fd == IP_FD_STDOUT || fd == IP_FD_STDERR)
|
||||
return ipcom_shell_write(fd, buffer, nbyte);
|
||||
#endif
|
||||
|
||||
return write((int)fd, (void*)buffer, (size_t)nbyte);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_rewind
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_rewind(IP_FILE *stream)
|
||||
{
|
||||
(void)fseek((FILE*)stream, 0L, SEEK_SET);
|
||||
}
|
||||
|
||||
#endif /* IPCOM_USE_FILE == IPCOM_FILE_NATIVE */
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_shell_fread
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_shell_fread(void *ptr, Ip_size_t size, Ip_size_t nitems, IP_FILE *stream)
|
||||
{
|
||||
return (Ip_size_t)fread(ptr, (size_t)size, (size_t)nitems, (FILE *)stream);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_shell_fwrite
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_size_t
|
||||
ipcom_shell_fwrite(IP_CONST void *ptr, Ip_size_t size, Ip_size_t nitems, IP_FILE *stream)
|
||||
{
|
||||
return (Ip_size_t)fwrite(ptr, (size_t)size, (size_t)nitems, (FILE *)stream);
|
||||
}
|
||||
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE */
|
||||
|
||||
|
||||
#if IPCOM_USE_FILE != IPCOM_FILE_NATIVE && IPCOM_USE_SHELL != IPCOM_SHELL_NATIVE
|
||||
int ipcom_pfile_empty_file;
|
||||
#endif
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pkt.c,v $ $Revision: 1.5 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_pkt.c,v $
|
||||
* $Author: kenneth $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by FirstName LastName <email@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_pkt.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pkt_buffer_malloc
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void *
|
||||
ipcom_pkt_buffer_malloc(Ip_size_t size)
|
||||
{
|
||||
return ipcom_malloc(size);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pkt_buffer_free
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
ipcom_pkt_buffer_free(void *buffer)
|
||||
{
|
||||
ipcom_free(buffer);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,830 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_pshell.c,v $ $Revision: 1.37.10.14 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_pshell.c,v $
|
||||
* $Author: jren $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Roger Boden <roger@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SKIP_NATIVE_SOCK_API
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE
|
||||
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_cstyle.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_sock2.h>
|
||||
#include <ipcom_err.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_shell.h>
|
||||
#include <ipcom_list.h>
|
||||
#include <ipcom_os.h>
|
||||
#ifdef IPCOM_USE_INET6
|
||||
#include <ipcom_sock6.h>
|
||||
#endif
|
||||
|
||||
#undef s6_addr /* Remove the ipcom definition, vxWorks 6.0 has a conflicting macro definition */
|
||||
#undef ifa_dstaddr /* The ifa_dstaddr #define in ipcom_sock2.h breaks code in target/h/.../ifvar.h */
|
||||
#undef ifa_broadaddr /* The ifa_broadaddr #define in ipcom_sock2.h breaks code in target/h/.../ifvar.h */
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <shellLib.h>
|
||||
#include <sockLib.h>
|
||||
#include <taskLib.h>
|
||||
#include <wrn/coreip/telnetLib.h>
|
||||
#include <tyLib.h>
|
||||
#include <ptyDrv.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <private/shellLibP.h>
|
||||
#include <ioLib.h>
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
|
||||
#ifndef IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN
|
||||
#define IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN 64
|
||||
#endif
|
||||
|
||||
#ifndef IPCOM_PSHELL_PTY_BUFFER_SIZE
|
||||
#define IPCOM_PSHELL_PTY_BUFFER_SIZE 512
|
||||
#endif
|
||||
|
||||
#define IPCOM_PSHELL_TASK_NAME_LEN 32
|
||||
#define IPCOM_PSHELL_LOGIN_TASK_BASENAME "tLogin"
|
||||
#define IPCOM_PSHELL_STDIO_PROXY_TASK_BASENAME "tStdioProxy"
|
||||
#define IPCOM_PSHELL_SOCKBUF_SZ 10000
|
||||
|
||||
/*
|
||||
* Ideally, we would not define IPCOM_SKIP_NATIVE_SOCK_API above, then we
|
||||
* would handle the both the case of IPCOM_USE_NATIVE_SOCK_API being defined
|
||||
* and not defined. Unfortunately, when IPCOM_USE_NATIVE_SOCK_API is defined,
|
||||
* we get compile errors (inconsistent function declarations for the socket
|
||||
* API. As a work-around, we therefore define IPCOM_SKIP_NATIVE_SOCK_API,
|
||||
* include all headers and thereafter define macros that include type casts
|
||||
* where necessary (below).
|
||||
*/
|
||||
#ifdef IPCOM_USE_NATIVE_SOCK_API
|
||||
#define ipcom_socket socket
|
||||
#define ipcom_socketclose(fd) close((int)fd)
|
||||
#define ipcom_shutdown(fd,how) shutdown((int)fd, how)
|
||||
#define ipcom_bind(s,a,l) bind((int)s,(struct sockaddr*)a,(int)l)
|
||||
#define ipcom_connect connect
|
||||
#define ipcom_accept accept
|
||||
#define ipcom_listen listen
|
||||
#define ipcom_socketwrite write
|
||||
#define ipcom_socketwritev writev
|
||||
#define ipcom_send send
|
||||
#define ipcom_sendto sendto
|
||||
#define ipcom_sendmsg sendmsg
|
||||
#define ipcom_socketread read
|
||||
#define ipcom_recv recv
|
||||
#define ipcom_recvfrom recvfrom
|
||||
#define ipcom_recvmsg recvmsg
|
||||
#define ipcom_getsockopt getsockopt
|
||||
#define ipcom_setsockopt(s,l,n,v,d) setsockopt(s,l,n,(char *)v,d)
|
||||
#define ipcom_getsockname(s,a,l) getsockname((int)s,(struct sockaddr*)a,(int*)l)
|
||||
#define ipcom_getpeername getpeername
|
||||
#define ipcom_socketioctl ioctl
|
||||
#define ipcom_if_nametoindex if_nametoindex
|
||||
#define ipcom_if_indextoname if_indextoname
|
||||
#define ipcom_if_nameindex if_nameindex
|
||||
#define ipcom_if_freenameindex if_freenameindex
|
||||
#define ipcom_socketselect select
|
||||
#endif
|
||||
|
||||
#define ZERO ((_Vx_usr_arg_t)0)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipcom_vxshell_session_s
|
||||
{
|
||||
Ipcom_sem shell_exit_sem;
|
||||
}
|
||||
Ipcom_vxshell_session_t;
|
||||
|
||||
typedef struct Ipcom_proxy_session_s
|
||||
{
|
||||
Ipcom_sem login_task_exit_sem;
|
||||
}
|
||||
Ipcom_proxy_session_t;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
extern char tyBackspaceChar;
|
||||
IMPORT int sysClkRateGet (void);
|
||||
|
||||
#if (!defined(IPCOM_SYSLOG) || IPCOM_SYSLOG == 1) && !defined(IPCOM_USE_CLIB_PROTO)
|
||||
IP_EXTERN IP_PUBLIC void
|
||||
ipcom_syslog(Ip_u32 priority, const char *format, ...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TODO: In private/shellLibP.h, the sessionId argument to shellParserControl()
|
||||
* is still declared as a UINT32, which won't work for LP64.
|
||||
extern STATUS shellParserControl (UINT32 remoteEvent, unsigned long sessionId,
|
||||
UINT32 slaveFd, VOIDFUNCPTR logoutFunc);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
IP_STATIC void ipcom_vxshell_login_task(int pty_fd, int vx_sock, Ipcom_proxy_session_t *proxy_session);
|
||||
|
||||
IP_STATIC void ipcom_vxworks_shell_logout_cb(void *arg);
|
||||
|
||||
IP_STATIC Ip_err ipcom_pshell_create_pty(char* pty_dev_name, size_t name_len, int *master_fd, int *slave_fd);
|
||||
|
||||
IP_STATIC Ip_err ipcom_pshell_spawn_proxy(int vx_sock);
|
||||
|
||||
IP_STATIC void ipcom_pshell_stdio_proxy(int vx_sock, int parent_task_id);
|
||||
|
||||
IP_STATIC int ipcom_pshell_proxy_data(int read_fd, int write_fd, Ip_bool can_change_direction, Ip_bool writefd_is_shell);
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 STATIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pshell_spawn_proxy
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipcom_pshell_spawn_proxy(int vx_sock)
|
||||
{
|
||||
char task_name[IPCOM_PSHELL_TASK_NAME_LEN];
|
||||
int task_prio = 50;
|
||||
|
||||
snprintf(task_name,
|
||||
sizeof(task_name),
|
||||
IPCOM_PSHELL_STDIO_PROXY_TASK_BASENAME "%x",
|
||||
taskIdSelf());
|
||||
|
||||
(void)taskPriorityGet(taskIdSelf(), &task_prio);
|
||||
if (taskSpawn(task_name,
|
||||
task_prio,
|
||||
0,
|
||||
6000UL,
|
||||
(FUNCPTR)ipcom_pshell_stdio_proxy,
|
||||
(_Vx_usr_arg_t)vx_sock,
|
||||
(_Vx_usr_arg_t)taskIdSelf(),
|
||||
ZERO, ZERO, ZERO, ZERO,
|
||||
ZERO, ZERO, ZERO, ZERO) == (IP_TASK_ID)TASK_ID_ERROR)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "Failed to create stdio proxy task: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pshell_stdio_proxy
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_pshell_stdio_proxy(int vx_sock, int parent_task_id)
|
||||
{
|
||||
int master_fd;
|
||||
int slave_fd;
|
||||
char task_name[IPCOM_PSHELL_TASK_NAME_LEN];
|
||||
char pty_dev_name[IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN];
|
||||
int master_fd_eof = 0;
|
||||
int vx_sock_eof = 0;
|
||||
Ip_pid_t pid;
|
||||
int task_prio = 50;
|
||||
Ipcom_proxy_session_t *session = IP_NULL;
|
||||
|
||||
session = ipcom_malloc(sizeof(Ipcom_proxy_session_t));
|
||||
if (session == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "Failed to malloc proxy session");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make this process the owner of the "vx_sock" socket */
|
||||
pid = ipcom_getpid();
|
||||
(void) ipcom_socketioctl(vx_sock, IP_SIOCSPGRP, &pid);
|
||||
|
||||
if (ipcom_pshell_create_pty(pty_dev_name, sizeof(pty_dev_name), &master_fd, &slave_fd) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "Failed to create ptys");
|
||||
close(vx_sock);
|
||||
ipcom_free(session);
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(task_name,
|
||||
sizeof(task_name),
|
||||
IPCOM_PSHELL_LOGIN_TASK_BASENAME "%x",
|
||||
parent_task_id);
|
||||
(void)taskPriorityGet(taskIdSelf(), &task_prio);
|
||||
(void)ipcom_sem_create(&session->login_task_exit_sem, 0);
|
||||
if (taskSpawn(task_name,
|
||||
task_prio,
|
||||
0,
|
||||
6000UL,
|
||||
(FUNCPTR)ipcom_vxshell_login_task,
|
||||
(_Vx_usr_arg_t)slave_fd,
|
||||
(_Vx_usr_arg_t)vx_sock,
|
||||
(_Vx_usr_arg_t)session, ZERO, ZERO, ZERO,
|
||||
ZERO, ZERO, ZERO, ZERO) == (IP_TASK_ID)TASK_ID_ERROR)
|
||||
{
|
||||
IPCOM_LOG1(ERR,
|
||||
"ipcom_shell_login_task: Failed to create login task: %s",
|
||||
strerror(errno));
|
||||
close(slave_fd);
|
||||
close(master_fd);
|
||||
ptyDevRemove(pty_dev_name);
|
||||
close(vx_sock);
|
||||
ipcom_sem_delete(&session->login_task_exit_sem);
|
||||
ipcom_free(session);
|
||||
return;
|
||||
}
|
||||
/* else: the ownership of "slave_fd" has been transferred to the
|
||||
ipcom_vxshell_login_task at this point */
|
||||
|
||||
/* Main loop, proxy data between pty fd and socket to telnet daemon */
|
||||
for (;;)
|
||||
{
|
||||
fd_set read_set;
|
||||
int read_fd = -1;
|
||||
int write_fd = -1;
|
||||
Ip_bool can_change_direction = IP_FALSE;
|
||||
Ip_bool writefd_is_shell = IP_FALSE;
|
||||
int ret;
|
||||
|
||||
FD_ZERO(&read_set);
|
||||
if (!master_fd_eof)
|
||||
FD_SET(master_fd, &read_set);
|
||||
if (!vx_sock_eof)
|
||||
FD_SET(vx_sock, &read_set);
|
||||
|
||||
if ((ret = select(IP_MAX(master_fd, vx_sock)+1, &read_set, NULL, NULL, NULL)) < 0)
|
||||
{
|
||||
IPCOM_LOG3(ERR,
|
||||
"ipcom_shell_login_task: select([%d, %d]) failed: %s",
|
||||
master_fd,
|
||||
vx_sock,
|
||||
strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (FD_ISSET(master_fd, &read_set))
|
||||
{
|
||||
/* Move data from the shell client to the telnet client */
|
||||
read_fd = master_fd;
|
||||
write_fd = vx_sock;
|
||||
}
|
||||
else if (FD_ISSET(vx_sock, &read_set))
|
||||
{
|
||||
/* Move data from the telnet client to the shell */
|
||||
read_fd = vx_sock;
|
||||
write_fd = master_fd;
|
||||
/* Allow ipcom_pshell_proxy_data() to start move data from
|
||||
the shell to the telnet client if the shell cannot
|
||||
accept more data. This is done to avoid a dead lock
|
||||
where this task waits for the shell file descriptor to
|
||||
become writable, but the only thing that can make it
|
||||
writable is if someone dequeus data written by the
|
||||
shell. */
|
||||
can_change_direction = IP_TRUE;
|
||||
writefd_is_shell = IP_TRUE;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
ret = ipcom_pshell_proxy_data(read_fd, write_fd, can_change_direction, writefd_is_shell);
|
||||
if (ret == 0 || (ret < 0 && (ipcom_errno == ESHUTDOWN || ipcom_errno == ECONNRESET)))
|
||||
{
|
||||
if (read_fd == vx_sock && !vx_sock_eof)
|
||||
{
|
||||
char eof;
|
||||
vx_sock_eof = 1;
|
||||
|
||||
/* Write EOF char to signal to shell that the client has
|
||||
* initiated close */
|
||||
taskDelay(sysClkRateGet()/10);
|
||||
if (write(master_fd, "\n", 1) != 1)
|
||||
goto cleanup;
|
||||
taskDelay(sysClkRateGet()/10);
|
||||
sprintf(&eof, "%c", tyEOFGet());
|
||||
if (write(master_fd, &eof, 1) != 1)
|
||||
goto cleanup;
|
||||
}
|
||||
if (read_fd == master_fd && !master_fd_eof)
|
||||
{
|
||||
master_fd_eof = 1;
|
||||
(void)shutdown(vx_sock, SHUT_WR);
|
||||
}
|
||||
if (master_fd_eof && vx_sock_eof)
|
||||
goto cleanup; /* Either shell or client initiated close */
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
if (ret < 0 && ipcom_errno != ESHUTDOWN && ipcom_errno != ECONNRESET)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "Failed to proxy data: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
close(master_fd);
|
||||
ipcom_sem_wait(session->login_task_exit_sem);
|
||||
ptyDevRemove(pty_dev_name);
|
||||
close(vx_sock);
|
||||
ipcom_sem_delete(&session->login_task_exit_sem);
|
||||
ipcom_free(session);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pshell_proxy_data
|
||||
*===========================================================================
|
||||
* Description: Moves data from the read_fd to the write_fd.
|
||||
* Parameters: read_fd - file descriptor data is moved from.
|
||||
* write_fd - file descriptor data is move to.
|
||||
* can_change_direction - IP_TRUE if data can be moved in the
|
||||
* opposite direction if the write_fd is full.
|
||||
* writefd_is_shell - IP_TRUE if write_fd is shell pty device.
|
||||
* Returns: >0 = number of bytes moved.
|
||||
* 0 = end of file reached.
|
||||
* <0 = error code.
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_pshell_proxy_data(int read_fd, int write_fd, Ip_bool can_change_direction, Ip_bool writefd_is_shell)
|
||||
{
|
||||
char buf[200];
|
||||
char *ptr;
|
||||
int rlen;
|
||||
int wlen;
|
||||
|
||||
rlen = (int)read(read_fd, buf, sizeof(buf));
|
||||
if (rlen <= 0)
|
||||
return rlen;
|
||||
|
||||
ptr = buf;
|
||||
wlen = rlen;
|
||||
while (wlen > 0)
|
||||
{
|
||||
int bytes_written;
|
||||
|
||||
bytes_written = (int)write(write_fd, ptr,
|
||||
(size_t)(wlen == rlen ? wlen : 1));
|
||||
if (bytes_written < 0)
|
||||
return bytes_written;
|
||||
|
||||
if (bytes_written == 0)
|
||||
{
|
||||
fd_set wr_set;
|
||||
|
||||
/* When the pty device is in line mode (typically when running a command
|
||||
* with a sub prompt), typing backspace when there are no characters to
|
||||
* erase will make write return 0 */
|
||||
if (ptr[0] == tyBackspaceChar)
|
||||
return rlen;
|
||||
|
||||
if (can_change_direction)
|
||||
{
|
||||
/* If shell pty device is in line-mode and write buf is full(E.g: up to max bytes
|
||||
in line in tty line mode), checking whether the read buf has data. If read buf
|
||||
is empty, drop data and return, otherwise trying read() in oposite direction
|
||||
will be pended in ptyMasterRead(). */
|
||||
if (writefd_is_shell)
|
||||
{
|
||||
int options;
|
||||
int bytesToRead = 0;
|
||||
|
||||
options = ioctl(write_fd, FIOGETOPTIONS, 0);
|
||||
if (options == ERROR)
|
||||
return -1;
|
||||
if (options & OPT_LINE)
|
||||
{
|
||||
if (ioctl(write_fd, FIONREAD, (_Vx_ioctl_arg_t) &bytesToRead) == ERROR)
|
||||
return -1;
|
||||
if (bytesToRead == 0)
|
||||
return rlen;
|
||||
}
|
||||
}
|
||||
/* Try to move data in the oposite direction to free
|
||||
up space in the input buffer of the shell file
|
||||
descriptor. */
|
||||
(void)ipcom_pshell_proxy_data(write_fd, read_fd, IP_FALSE, !writefd_is_shell);
|
||||
}
|
||||
|
||||
/* Send buffer full, wait until more space becomes
|
||||
available */
|
||||
FD_ZERO(&wr_set);
|
||||
FD_SET(write_fd, &wr_set);
|
||||
if (select(write_fd + 1, NULL, &wr_set, NULL, NULL) < 0)
|
||||
return -1;
|
||||
}
|
||||
wlen -= bytes_written;
|
||||
ptr += bytes_written;
|
||||
}
|
||||
|
||||
return rlen;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_pshell_create_pty
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC Ip_err
|
||||
ipcom_pshell_create_pty(char* pty_dev_name, size_t name_len, int *master_fd, int *slave_fd)
|
||||
{
|
||||
char pty_dev_name_m[IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN];
|
||||
char pty_dev_name_s[IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN];
|
||||
|
||||
*master_fd = ERROR;
|
||||
*slave_fd = ERROR;
|
||||
|
||||
/* Create unique names for the pty device */
|
||||
snprintf (pty_dev_name, name_len, "%s_%p.", "stdio_pty", (void *)taskIdSelf());
|
||||
snprintf (pty_dev_name_m, (size_t)IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN,
|
||||
"%sM", pty_dev_name);
|
||||
snprintf (pty_dev_name_s, (size_t)IPCOM_PSHELL_PTY_DEV_NAME_MAX_LEN,
|
||||
"%sS", pty_dev_name);
|
||||
|
||||
/* pseudo tty device creation */
|
||||
if (ptyDevCreate (pty_dev_name,
|
||||
(size_t)IPCOM_PSHELL_PTY_BUFFER_SIZE,
|
||||
(size_t)IPCOM_PSHELL_PTY_BUFFER_SIZE) == ERROR)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ptyDevCreate failed: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
/* Master-side open of pseudo tty */
|
||||
*master_fd = open (pty_dev_name_m, O_RDWR, 0);
|
||||
if (*master_fd == ERROR)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "open failed on pty device: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Slave-side open of pseudo tty */
|
||||
*slave_fd = open (pty_dev_name_s, O_RDWR, 0);
|
||||
if (*slave_fd == ERROR)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "open failed on pty device: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* Set up the slave device to act like a terminal, but no ^C/^X.
|
||||
* OPT_ABORT and OPT_MON_TRAP will be enabled by the shell parser
|
||||
* routine after successful login but before restarting the shell.
|
||||
*/
|
||||
|
||||
if (ioctl(*slave_fd, FIOOPTIONS, OPT_TERMINAL & ~(OPT_ABORT|OPT_MON_TRAP)) != OK)
|
||||
{
|
||||
IPCOM_LOG2(ERR, "ioctl(FIOOPTIONS) failed: %s(%d)",
|
||||
ipcom_strerror(ipcom_errno), ipcom_errno);
|
||||
goto err;
|
||||
}
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
err:
|
||||
ptyDevRemove(pty_dev_name);
|
||||
if (*master_fd != ERROR)
|
||||
close(*master_fd);
|
||||
if (*slave_fd != ERROR)
|
||||
close(*slave_fd);
|
||||
|
||||
return IPCOM_ERR_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_vxworks_shell_logout_cb
|
||||
*===========================================================================
|
||||
* Description: The vxshell calls this upon exit. This is used to trigger the
|
||||
* 'ipcom_login_task_task' to tear down the remote connection
|
||||
*
|
||||
* Parameters: arg: the session descriptor created by the 'ipcom_vxshell_login_task'
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_vxworks_shell_logout_cb(void *arg)
|
||||
{
|
||||
Ipcom_vxshell_session_t *session = (Ipcom_vxshell_session_t *) arg;
|
||||
|
||||
ipcom_sem_post(session->shell_exit_sem);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_vxshell_login_task
|
||||
*===========================================================================
|
||||
* Description: Task to provide a context login procedure in 'shellParserControl'
|
||||
*
|
||||
* Parameters: pty_fd: the vxworks socket the vxshell should communicate on
|
||||
* Parameters: vx_sock: the vxworks socket the stdio_proxy is using for
|
||||
* communication with the telnet server.
|
||||
* login_task_exit_sem: the login task exit sem
|
||||
*
|
||||
*/
|
||||
IP_STATIC void
|
||||
ipcom_vxshell_login_task(int pty_fd, int vx_sock, Ipcom_proxy_session_t *proxy_session)
|
||||
{
|
||||
Ipcom_vxshell_session_t session;
|
||||
|
||||
(void)ipcom_sem_create(&session.shell_exit_sem, 0);
|
||||
|
||||
if (shellParserControl(REMOTE_START, (unsigned long)&session, (UINT32)pty_fd, ipcom_vxworks_shell_logout_cb) == 0)
|
||||
{
|
||||
ipcom_sem_wait(session.shell_exit_sem);
|
||||
shellParserControl(REMOTE_STOP, (unsigned long)&session, 0U, IP_NULL);
|
||||
}
|
||||
|
||||
ipcom_sem_delete(&session.shell_exit_sem);
|
||||
|
||||
close(pty_fd);
|
||||
shutdown(vx_sock, SHUT_RD);
|
||||
ipcom_sem_post(proxy_session->login_task_exit_sem);
|
||||
}
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 10 GLOBAL FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_start_shell_native
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL Ip_err
|
||||
ipcom_start_shell_native(Ip_fd *stdio_sock, const Ipcom_shell_ctx* sh_ctx)
|
||||
{
|
||||
Ip_fd ip_sock = IP_INVALID_SOCKET;
|
||||
Ip_fd ip_listen_sock = IP_INVALID_SOCKET;
|
||||
int vx_sock = IP_INVALID_SOCKET;
|
||||
Ip_err rc = IPCOM_ERR_FAILED;
|
||||
Ip_socklen_t len;
|
||||
int enable = IP_TRUE;
|
||||
struct linger linger;
|
||||
struct Ip_addrinfo hints;
|
||||
struct Ip_addrinfo *res;
|
||||
struct Ip_sockaddr_storage ss;
|
||||
int sockbuf = IPCOM_PSHELL_SOCKBUF_SZ;
|
||||
|
||||
|
||||
ipcom_memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_socktype = IP_SOCK_STREAM;
|
||||
if (ipcom_getaddrinfo(IP_NULL, "0", &hints, &res) != 0)
|
||||
return rc;
|
||||
|
||||
ip_listen_sock = ipcom_socket(res->ai_family, res->ai_socktype, (int)res->ai_protocol);
|
||||
if (ip_listen_sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_socket(AF_INET) failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (ipcom_bind(ip_listen_sock, res->ai_addr, (Ip_socklen_t)res->ai_addrlen) != OK)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_bind() failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
if (ipcom_listen(ip_listen_sock, 1) != OK)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_listen() failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
/* Fetch the empheral port assigned to our socket */
|
||||
len = sizeof(ss);
|
||||
if (ipcom_getsockname(ip_listen_sock, (struct Ip_sockaddr*) &ss, &len) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_getsockname(AF_INET) failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
vx_sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||
if (vx_sock == -1)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_socket() failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (connect(vx_sock, (struct sockaddr *) &ss, (socklen_t)sizeof(ss)) != OK)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: connect() failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ip_sock = ipcom_accept(ip_listen_sock, NULL, NULL);
|
||||
if (ip_sock == IP_INVALID_SOCKET)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_start_shell_native :: ipcom_accept() failed: %s", ipcom_strerror(ipcom_errno));
|
||||
goto err_out;
|
||||
}
|
||||
ipcom_socketclose(ip_listen_sock);
|
||||
|
||||
/*
|
||||
* Limit the socket buffer size as this connection disables the
|
||||
* Nagle algorithm which might result in a huge amount of small
|
||||
* packets.
|
||||
*/
|
||||
(void)ipcom_setsockopt(ip_sock, IP_SOL_SOCKET, IP_SO_SNDBUF, &sockbuf, sizeof(sockbuf));
|
||||
(void)ipcom_setsockopt(ip_sock, IP_SOL_SOCKET, IP_SO_RCVBUF, &sockbuf, sizeof(sockbuf));
|
||||
(void)setsockopt(vx_sock, SOL_SOCKET, SO_SNDBUF, &sockbuf, sizeof(sockbuf));
|
||||
(void)setsockopt(vx_sock, SOL_SOCKET, SO_RCVBUF, &sockbuf, sizeof(sockbuf));
|
||||
|
||||
/*
|
||||
* Disable Nagle (enable no delay) on the sockets since it is an
|
||||
* interactive connection
|
||||
*/
|
||||
(void)setsockopt(vx_sock, IPPROTO_TCP, TCP_NODELAY, (char *) &enable, (socklen_t)sizeof(enable));
|
||||
(void)ipcom_setsockopt(ip_sock, IP_IPPROTO_TCP, IP_TCP_NODELAY, &enable, (Ip_socklen_t)sizeof(enable));
|
||||
|
||||
linger.l_onoff = 1;
|
||||
linger.l_linger = 0;
|
||||
(void)setsockopt(vx_sock, SOL_SOCKET, SO_LINGER, (char*)&linger, (socklen_t)sizeof(linger));
|
||||
(void)ipcom_setsockopt(ip_sock, IP_SOL_SOCKET, IP_SO_LINGER, &linger, (Ip_socklen_t)sizeof(linger));
|
||||
|
||||
if(tyAbortFuncGet() == IP_NULL)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ipcom_start_extshell :: shell initialization have not be finished yet");
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (ipcom_pshell_spawn_proxy(vx_sock) != IPCOM_SUCCESS)
|
||||
{
|
||||
IPCOM_LOG0(ERR, "ipcom_start_shell_native :: Failed to spawn proxy task");
|
||||
goto err_out;
|
||||
}
|
||||
*stdio_sock = ip_sock;
|
||||
ipcom_freeaddrinfo(res);
|
||||
|
||||
return IPCOM_SUCCESS;
|
||||
|
||||
err_out:
|
||||
ipcom_freeaddrinfo(res);
|
||||
if (ip_listen_sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(ip_listen_sock);
|
||||
if (vx_sock != IP_INVALID_SOCKET)
|
||||
close(vx_sock);
|
||||
if (ip_sock != IP_INVALID_SOCKET)
|
||||
ipcom_socketclose(ip_sock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_stdio_set_echo
|
||||
*===========================================================================
|
||||
* Description: Enables/disabled local echo on a telnet session.
|
||||
* Parameters: fd - shell
|
||||
* echo - IP_TRUE to enabled echo, IP_FALSE to disable
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_GLOBAL void
|
||||
ipcom_stdio_set_echo (int fd, Ip_bool echo)
|
||||
{
|
||||
int opts;
|
||||
int int_fd;
|
||||
|
||||
|
||||
if (fd == -1)
|
||||
int_fd = STD_IN;
|
||||
else
|
||||
int_fd = fd;
|
||||
|
||||
opts = ioctl(int_fd, FIOGETOPTIONS, 0);
|
||||
if (opts == ERROR)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_stdio_set_echo :: ioctl(FIOGETOPTIONS) failed, errno=0x%x", errno);
|
||||
return;
|
||||
}
|
||||
if (echo)
|
||||
opts |= OPT_ECHO;
|
||||
else
|
||||
opts &= ~OPT_ECHO;
|
||||
|
||||
if (ioctl(int_fd, FIOOPTIONS, opts) == ERROR)
|
||||
IPCOM_LOG1(ERR, "ipcom_stdio_set_echo :: ioctl(FIOOPTIONS) failed, errno=0x%x", errno);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 11 PUBLIC FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#else
|
||||
int ipcom_pshell_empty_file;
|
||||
#endif /* IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,740 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_psock.c,v $ $Revision: 1.37.10.2 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_psock.c,v $
|
||||
* $Author: fguo $ $Date: 2012-11-06 02:39:54 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* ipcom_sock.c contains source code for BSD sockets functions calls.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE || defined(IPCOM_VXWORKS_TEST_SOCKET_BACKEND) || defined(IPCOM_USE_NATIVE_SOCK_API)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define SOCKLEN_T_UNSIGNED
|
||||
|
||||
#include <ipcom_sock.h>
|
||||
#include <ipcom_clib.h>
|
||||
#include <ipcom_syslog.h>
|
||||
#include <ipcom_os.h>
|
||||
#include <ipcom_ipcom2coreip.h>
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <sockLib.h>
|
||||
#include <selectLib.h>
|
||||
#include <inetLib.h>
|
||||
#include <ioLib.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef IPSCTP
|
||||
#include <netinet/sctp.h>
|
||||
#endif
|
||||
#include <netinet/in_var.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <version.h>
|
||||
#if defined(_WRS_VXWORKS_MAJOR) && _WRS_VXWORKS_MAJOR == 6
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
#ifdef IP_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if (!defined(IPCOM_SYSLOG) || IPCOM_SYSLOG == 1) && !defined(IPCOM_USE_CLIB_PROTO)
|
||||
IP_EXTERN IP_PUBLIC void
|
||||
ipcom_syslog(Ip_u32 priority, const char *format, ...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_psock_ipsockopt_to_sockopt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_STATIC int
|
||||
ipcom_psock_ipoptname_to_optname(int optname)
|
||||
{
|
||||
switch(optname)
|
||||
{
|
||||
case IP_SO_REUSEADDR:
|
||||
optname = SO_REUSEADDR;
|
||||
break;
|
||||
case IP_SO_BROADCAST:
|
||||
optname = SO_BROADCAST;
|
||||
break;
|
||||
case IP_SO_REUSEPORT:
|
||||
optname = SO_REUSEPORT;
|
||||
break;
|
||||
case IP_SO_DONTROUTE:
|
||||
optname = SO_DONTROUTE;
|
||||
break;
|
||||
case IP_SO_SNDBUF:
|
||||
optname = SO_SNDBUF;
|
||||
break;
|
||||
case IP_SO_RCVBUF:
|
||||
optname = SO_RCVBUF;
|
||||
break;
|
||||
case IP_SO_RCVTIMEO:
|
||||
optname = SO_RCVTIMEO;
|
||||
break;
|
||||
case IP_SO_ERROR:
|
||||
optname = SO_ERROR;
|
||||
break;
|
||||
case IP_SO_TYPE:
|
||||
optname = SO_TYPE;
|
||||
break;
|
||||
case IP_SO_KEEPALIVE:
|
||||
optname = SO_KEEPALIVE;
|
||||
break;
|
||||
default:
|
||||
IP_PANIC2();
|
||||
break;
|
||||
}
|
||||
return optname;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
IP_STATIC int ipcom_psock_tot_no_socks = 0;
|
||||
IP_STATIC int ipcom_curr_no_socks = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
IP_PUBLIC void
|
||||
ipcom_show_sock_stat(void)
|
||||
{
|
||||
ipcom_printf("total no of sockets created: %d\n", ipcom_psock_tot_no_socks);
|
||||
ipcom_printf("current no of sockets in use: %d\n", ipcom_curr_no_socks);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socket
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_fd
|
||||
ipcom_socket(int domain, int type, int protocol)
|
||||
{
|
||||
#ifdef IP_DEBUG
|
||||
Ip_fd sock;
|
||||
|
||||
ipcom_psock_tot_no_socks++;
|
||||
ipcom_curr_no_socks++;
|
||||
sock = (Ip_fd)socket((int)domain, (int)type, (int)protocol);
|
||||
|
||||
return sock;
|
||||
#else
|
||||
return (Ip_fd)socket((int)domain, (int)type, (int)protocol);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketclose
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_socketclose(Ip_fd fd)
|
||||
{
|
||||
int ret = -1;
|
||||
#ifdef IP_DEBUG
|
||||
ipcom_curr_no_socks--;
|
||||
#endif
|
||||
|
||||
IPCOM_LOG1(DEBUG2, "ipcom_socketclose(%d)", fd);
|
||||
|
||||
if (fd >= 0)
|
||||
ret = (int)close((int)fd);
|
||||
if (ret < 0)
|
||||
{
|
||||
IPCOM_LOG2(DEBUG2, "ipcom_socketclose(%d) :: failed, errno=%d", fd, errno);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_shutdown
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_shutdown(Ip_fd fd, int how)
|
||||
{
|
||||
int ret;
|
||||
|
||||
IPCOM_LOG1(DEBUG2, "ipcom_shutdown(%d)", fd);
|
||||
|
||||
ret = shutdown((int)fd, how);
|
||||
if (ret < 0)
|
||||
{
|
||||
IPCOM_LOG2(DEBUG2, "ipcom_shutdown(%d) :: failed, errno=%d", fd, errno);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_bind
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_bind(Ip_fd fd, IP_CONST struct Ip_sockaddr *addr, Ip_socklen_t addrlen)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (int)bind((int)fd, (struct sockaddr *)addr, (int)addrlen);
|
||||
if (ret < 0)
|
||||
{
|
||||
IPCOM_LOG2(DEBUG2, "ipcom_bind(%d) :: failed, errno=%d", fd, errno);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_connect
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_connect(Ip_fd sock, IP_CONST struct Ip_sockaddr *addr, Ip_socklen_t addrlen)
|
||||
{
|
||||
return (int)connect((int)sock, (struct sockaddr *)addr, (int)addrlen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_listen
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_listen(Ip_fd sock, int backlog)
|
||||
{
|
||||
return (int)listen((int)sock, (int) backlog);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_accept
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_accept(Ip_fd sock, struct Ip_sockaddr *addr, Ip_socklen_t *addrlenp)
|
||||
{
|
||||
int tmp_sock;
|
||||
|
||||
tmp_sock = (int)accept((int)sock, (struct sockaddr *)addr, (socklen_t *)addrlenp);
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
ipcom_curr_no_socks++;
|
||||
ipcom_psock_tot_no_socks++;
|
||||
#endif
|
||||
|
||||
return tmp_sock;
|
||||
}
|
||||
|
||||
#ifdef IPSCTP
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipsctp_peeloff
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipsctp_peeloff(Ip_fd sock, /*Ipsctp_assoc_t*/Ip_u32 assoc_id)
|
||||
{
|
||||
int tmp_sock;
|
||||
|
||||
tmp_sock = (int)sctp_peeloff((int)sock, (sctp_assoc_t)assoc_id);
|
||||
|
||||
#ifdef IP_DEBUG
|
||||
ipcom_curr_no_socks++;
|
||||
ipcom_psock_tot_no_socks++;
|
||||
#endif
|
||||
|
||||
return tmp_sock;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_setsockopt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_setsockopt(Ip_fd sock, int level, int optname, const void *optval, Ip_socklen_t optlen)
|
||||
{
|
||||
optname = ipcom_psock_ipoptname_to_optname(optname);
|
||||
|
||||
return sock < 0 ? -1 : setsockopt((int)sock, level, optname, (void*)optval, (int)optlen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getsockopt
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getsockopt(Ip_fd sock, int level, int optname, void *optval, Ip_socklen_t *optlenp)
|
||||
{
|
||||
optname = ipcom_psock_ipoptname_to_optname(optname);
|
||||
|
||||
return sock < 0 ? -1 : (int)getsockopt((int)sock, (int)level, (int)optname, optval, (socklen_t *)optlenp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getsockname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getsockname(Ip_fd sock, struct Ip_sockaddr *addr, Ip_socklen_t *addrlenp)
|
||||
{
|
||||
return getsockname((int)sock, (struct sockaddr *)addr, (socklen_t *)addrlenp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_getpeername
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_getpeername(Ip_fd sock, struct Ip_sockaddr *addr, Ip_socklen_t *addrlenp)
|
||||
{
|
||||
return getpeername((int)sock, (struct sockaddr *)addr, (socklen_t *)addrlenp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketwrite
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_socketwrite(Ip_fd sock, IP_CONST void *buf, Ip_size_t nbytes)
|
||||
{
|
||||
return ipcom_send(sock, buf, nbytes, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketwritev
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_socketwritev(Ip_fd fd, IP_CONST struct Ip_iovec *iov, int iovlen)
|
||||
{
|
||||
return (Ip_ssize_t) writev((int) fd, (struct iovec *) iov, iovlen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_send
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_send(Ip_fd sock, IP_CONST void *msg, Ip_size_t len, int flags)
|
||||
{
|
||||
return sock < 0 ? -1 : (Ip_ssize_t)send((int)sock, msg, len, flags);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_sendto
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_sendto(Ip_fd sock, IP_CONST void *msg, Ip_size_t len, int flags, const struct Ip_sockaddr *to, Ip_socklen_t tolen)
|
||||
{
|
||||
return (Ip_ssize_t)sendto((int)sock, (void *) msg, len, flags,
|
||||
(struct sockaddr *)to, (int)tolen);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketread
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_socketread(Ip_fd sock, void *buf, Ip_size_t nbytes)
|
||||
{
|
||||
return (Ip_ssize_t)recv((int)sock, buf, nbytes, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_recv
|
||||
*===========================================================================
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_recv(Ip_fd fd, void *buf, Ip_size_t len, int flags)
|
||||
{
|
||||
return recv((int) fd, buf, len, flags);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_recvfrom
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_recvfrom(Ip_fd sock, void *buf, Ip_size_t len, int flags, struct Ip_sockaddr *from, Ip_socklen_t *fromlenp)
|
||||
{
|
||||
return (Ip_ssize_t)recvfrom((int)sock, buf, len, flags,
|
||||
(struct sockaddr *)from, (socklen_t *)fromlenp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_recvmsg
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_recvmsg(Ip_fd sock, struct Ip_msghdr *msg, int flags)
|
||||
{
|
||||
return (Ip_ssize_t)recvmsg((int)sock, (struct msghdr*)msg, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_sendmsg
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_ssize_t
|
||||
ipcom_sendmsg(Ip_fd sock, IP_CONST struct Ip_msghdr *msg, int flags)
|
||||
{
|
||||
return (Ip_ssize_t)sendmsg((int)sock, (struct msghdr*)msg, flags);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketselect
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_socketselect(int width, Ip_fd_set *rfds, Ip_fd_set *wfds, Ip_fd_set *exfds, struct Ip_timeval *tmo)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (int)select((int)width, (fd_set *)rfds, (fd_set *)wfds, (fd_set *)exfds, (struct timeval *)tmo);
|
||||
if (ret < 0)
|
||||
{
|
||||
IPCOM_LOG1(DEBUG2, "ipcom_socketselect() :: failed, errno=%d", errno);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_socketioctl
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC int
|
||||
ipcom_socketioctl(Ip_fd sock, unsigned long request, void *argp)
|
||||
{
|
||||
/* the ioctl function is declared as
|
||||
* int ioctl(int sock, int request, int arg);
|
||||
* in the header ioLib.h. This is also how it is described in
|
||||
* the manuals. However, it is wrong. The "standard" declaration
|
||||
* found on most other OSs should be used, i.e.
|
||||
* int ioctl(int sock, int request, void* argp);
|
||||
*/
|
||||
switch(request)
|
||||
{
|
||||
/* 'Ip_pid_t' ioctls: */
|
||||
case IP_SIOCSPGRP:
|
||||
return 0;
|
||||
case IP_SIOCGPGRP:
|
||||
*(Ip_pid_t *)argp = ipcom_getpid();
|
||||
return 0;
|
||||
|
||||
/* 'int' ioctls: */
|
||||
case IP_FIONBIO:
|
||||
request = FIONBIO;
|
||||
break;
|
||||
case IP_FIONREAD:
|
||||
request = FIONREAD;
|
||||
break;
|
||||
|
||||
/* 'struct Ip_ifreq' ioctls: */
|
||||
case IP_SIOCGIFADDR:
|
||||
request = SIOCGIFADDR;
|
||||
break;
|
||||
case IP_SIOCSIFADDR:
|
||||
request = SIOCSIFADDR;
|
||||
break;
|
||||
case IP_SIOCGIFBRDADDR:
|
||||
request = SIOCGIFBRDADDR;
|
||||
break;
|
||||
case IP_SIOCGIFNETMASK:
|
||||
request = SIOCGIFNETMASK;
|
||||
break;
|
||||
case IP_SIOCSIFNETMASK:
|
||||
request = SIOCSIFNETMASK;
|
||||
break;
|
||||
case IP_SIOCGIFDSTADDR:
|
||||
request = SIOCGIFDSTADDR;
|
||||
break;
|
||||
case IP_SIOCSIFDSTADDR:
|
||||
request = SIOCSIFDSTADDR;
|
||||
break;
|
||||
case IP_SIOCAIFADDR:
|
||||
request = SIOCAIFADDR;
|
||||
break;
|
||||
case IP_SIOCDIFADDR:
|
||||
request = SIOCDIFADDR;
|
||||
break;
|
||||
case IP_SIOCGIFFLAGS:
|
||||
request = SIOCGIFFLAGS; /* warning: do IFF flags match? */
|
||||
break;
|
||||
case IP_SIOCSIFFLAGS:
|
||||
request = SIOCSIFFLAGS; /* warning: do IFF flags match? */
|
||||
break;
|
||||
case IP_SIOCGIFMTU:
|
||||
request = SIOCGIFMTU;
|
||||
break;
|
||||
case IP_SIOCSIFMTU:
|
||||
request = SIOCSIFMTU;
|
||||
break;
|
||||
#ifdef IP_SIOCGIFMETRIC
|
||||
case IP_SIOCGIFMETRIC:
|
||||
request = SIOCGIFMETRIC;
|
||||
break;
|
||||
#endif
|
||||
#ifdef IP_SIOCSIFMETRIC
|
||||
case IP_SIOCSIFMETRIC:
|
||||
request = SIOCSIFMETRIC;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
IP_PANIC2();
|
||||
break;
|
||||
}
|
||||
return ioctl((int)sock, (int)request, (_Vx_usr_arg_t)argp);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(IPCOM_VXWORKS_TEST_SOCKET_BACKEND) && !defined(IPCOM_USE_NATIVE_SOCK_API)
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_if_nametoindex
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC Ip_u32
|
||||
ipcom_if_nametoindex(IP_CONST char *ifname)
|
||||
{
|
||||
IP_PANIC();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipcom_if_indextoname
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC char *
|
||||
ipcom_if_indextoname(Ip_u32 ifindex, char *ifname)
|
||||
{
|
||||
IP_PANIC();
|
||||
return IP_NULL;
|
||||
}
|
||||
#endif /* !defined(IPCOM_VXWORKS_TEST_SOCKET_BACKEND) && !defined(IPCOM_USE_NATIVE_SOCK_API) */
|
||||
|
||||
#else
|
||||
int ipcom_psock_empty_file;
|
||||
#endif /* IPCOM_USE_SOCK == IPCOM_SOCK_NATIVE || defined(IPCOM_VXWORKS_TEST_SOCKET_BACKEND) */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
******************************************************************************
|
||||
* SOURCE FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_ramdisk.c,v $ $Revision: 1.3.126.1 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipcom/port/vxworks/src/ipcom_ramdisk.c,v $
|
||||
* $Author: fguo $ $Date: 2012-07-04 06:56:42 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* ipcom_ramdisk.c contains source code for initializing RAM disk support. The
|
||||
* module is intended to de-couple RAM disk support from IPCOM so that RAM
|
||||
* disk support can be scaled in/out at link time.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_config.h"
|
||||
|
||||
#if IPCOM_USE_FILE == IPCOM_FILE_NATIVE && defined(IPCOM_USE_RAM_DISK)
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#include "ipcom_type.h"
|
||||
#include "ipcom_file.h"
|
||||
#include "ipcom_clib.h"
|
||||
#include "ipcom_syslog.h"
|
||||
#include "ipcom_err.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <ramDrv.h>
|
||||
#include <dosFsLib.h>
|
||||
#if IP_PORT_VXWORKS >= 62
|
||||
#include <xbdRamDisk.h>
|
||||
#else
|
||||
#include <cbioLib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 EXTERN PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
#if (!defined(IPCOM_SYSLOG) || IPCOM_SYSLOG == 1) && !defined(IPCOM_USE_CLIB_PROTO)
|
||||
IP_EXTERN IP_PUBLIC void
|
||||
ipcom_syslog(Ip_u32 priority, const char *format, ...);
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPCOM_SYSLOG_PRIORITY IPCOM_SYSLOG_IPCOM_PRIORITY
|
||||
#undef IPCOM_SYSLOG_FACILITY
|
||||
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPCOM_DRV_ETH
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 7 LOCAL PROTOTYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 8 DATA
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 9 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* vxfs_ramdisk_init
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
*/
|
||||
IP_PUBLIC void
|
||||
vxfs_ramdisk_init(void)
|
||||
{
|
||||
char rd_dev_name [sizeof(IPCOM_FILE_ROOT) + 4];
|
||||
int rd_dev_name_len;
|
||||
|
||||
strlcpy (rd_dev_name, IPCOM_FILE_ROOT, sizeof(IPCOM_FILE_ROOT)+1);
|
||||
rd_dev_name_len = (int)strlen (rd_dev_name);
|
||||
|
||||
/* Remove the trailing slash */
|
||||
if (rd_dev_name[rd_dev_name_len-1] == '/' )
|
||||
rd_dev_name[rd_dev_name_len-1] = '\0';
|
||||
|
||||
if (xbdRamDiskDevCreate(IPCOM_RAM_DISK_BLOCK_SIZE,
|
||||
(IPCOM_RAM_DISK_NO_BLOCK * IPCOM_RAM_DISK_BLOCK_SIZE),
|
||||
FALSE, rd_dev_name) == NULLDEV)
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_ramdisk.c: vxfs_ramdisk_init, "
|
||||
"xbdRamDiskDevCreate() failed, errno=%d",
|
||||
ipcom_errno);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dosFsVolFormat (rd_dev_name, DOS_OPT_BLANK, NULL) != IPCOM_SUCCESS )
|
||||
{
|
||||
IPCOM_LOG1(ERR, "ipcom_ramdisk.c: vxfs_ramdisk_init, "
|
||||
"dosFsVolFormat() failed, errno=%d",
|
||||
ipcom_errno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
int ipcom_ramdisk_empty_file;
|
||||
#endif /* #if IPCOM_USE_FILE == IPCOM_FILE_NATIVE
|
||||
&& defined(IPCOM_USE_RAM_DISK) */
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user