diff --git a/fsw/for_build/Makefile b/fsw/for_build/Makefile new file mode 100644 index 0000000..c50b7ba --- /dev/null +++ b/fsw/for_build/Makefile @@ -0,0 +1,112 @@ +############################################################################### +# File: CFS Application Makefile +# +# $Id: Makefile 1.6 2009/07/09 11:41:26EDT rmcgraw Exp $ +# +# $Log: Makefile $ +# Revision 1.6 2009/07/09 11:41:26EDT rmcgraw +# DCR8291:1 Changed CFE_MISSION_INC to CFS_MISSION_INC and added log if needed +# +############################################################################### +# +# Subsystem produced by this makefile. +# +APPTARGET = cfs_lib + +# +# Entry Point for task +# +ENTRY_PT = CFS_LibInit + +# +# Object files required to build subsystem. +# +OBJS = cfs_utils.o + +# +# Source files required to build subsystem; used to generate dependencies. +# As long as there are no assembly files this can be automated. +# +SOURCES = $(OBJS:.o=.c) + + +## +## Specify extra C Flags needed to build this subsystem +## +LOCAL_COPTS = + + +## +## EXEDIR is defined here, just in case it needs to be different for a custom +## build +## +EXEDIR=../exe + +## +## Certain OSs and Application Loaders require the following option for +## Shared libraries. Currently only needed for vxWorks 5.5 and RTEMS. +## For each shared library that this app depends on, you need to have an +## entry like the following: +## -R../tst_lib/tst_lib.elf +## +SHARED_LIB_LINK = + +######################################################################## +# Should not have to change below this line, except for customized +# Mission and cFE directory structures +######################################################################## + +# +# Set build type to CFE_APP. This allows us to +# define different compiler flags for the cFE Core and Apps. +# +BUILD_TYPE = CFE_APP + +## +## Include all necessary cFE make rules +## Any of these can be copied to a local file and +## changed if needed. +## +## +## cfe-config.mak contains PSP and OS selection +## +include ../cfe/cfe-config.mak +## +## debug-opts.mak contains debug switches +## +include ../cfe/debug-opts.mak +## +## compiler-opts.mak contains compiler definitions and switches/defines +## +include $(CFE_PSP_SRC)/$(PSP)/make/compiler-opts.mak + +## +## Setup the include path for this subsystem +## The OS specific includes are in the build-rules.make file +## +## If this subsystem needs include files from another app, add the path here. +## +INCLUDE_PATH = \ +-I$(OSAL_SRC)/inc \ +-I$(CFE_CORE_SRC)/inc \ +-I$(CFE_PSP_SRC)/inc \ +-I$(CFE_PSP_SRC)/$(PSP)/inc \ +-I$(CFS_APP_SRC)/inc \ +-I$(CFS_APP_SRC)/$(APPTARGET)/fsw/src \ +-I$(CFS_MISSION_INC) \ +-I../cfe/inc \ +-I../inc + +## +## Define the VPATH make variable. +## This can be modified to include source from another directory. +## If there is no corresponding app in the cfs-apps directory, then this can be discarded, or +## if the mission chooses to put the src in another directory such as "src", then that can be +## added here as well. +## +VPATH = $(CFS_APP_SRC)/$(APPTARGET)/fsw/src + +## +## Include the common make rules for building a cFE Application +## +include $(CFE_CORE_SRC)/make/app-rules.mak diff --git a/fsw/public_inc/cfs_utils.h b/fsw/public_inc/cfs_utils.h new file mode 100644 index 0000000..9ac806d --- /dev/null +++ b/fsw/public_inc/cfs_utils.h @@ -0,0 +1,256 @@ +/************************************************************************* +** File: +** $Id: cfs_utils.h 1.6 2015/03/02 18:30:04EST sstrege Exp $ +** +** Copyright © 2007-2014 United States Government as represented by the +** Administrator of the National Aeronautics and Space Administration. +** All Other Rights Reserved. +** +** This software was created at NASA's Goddard Space Flight Center. +** This software is governed by the NASA Open Source Agreement and may be +** used, distributed and modified only pursuant to the terms of that +** agreement. +** +** Purpose: +** Specification for the CFS shared library functions. +** +** References: +** +** $Log: cfs_utils.h $ +** Revision 1.6 2015/03/02 18:30:04EST sstrege +** Added copyright information +** Revision 1.5 2009/08/31 17:46:42EDT lwalling +** Add function CFS_VerifyString() to CFS Library +** Revision 1.4 2009/05/26 13:31:07EDT lwalling +** Create common packet filter function in global CFS library +** Revision 1.3 2008/10/06 09:52:08EDT rjmcgraw +** DCR4401:1 Removed extraneous tabs and unprintable characters +** Revision 1.2 2008/05/15 09:39:41EDT rjmcgraw +** DCR2179:1 Changed doxygen link OS_SymLookup to OS_SymbolLookup +** Revision 1.1 2008/05/13 13:35:14EDT rjmcgraw +** Initial revision +** Member added to project cfs_lib +** +*************************************************************************/ +#ifndef _cfs_utils_h_ +#define _cfs_utils_h_ + +/************************************************************************ +** Includes +*************************************************************************/ +#include "cfe.h" + +/************************************************************************ +** Type Definitions +*************************************************************************/ +/** +** \brief Symbolic Address Type +*/ +typedef struct +{ + uint32 Offset;/**< \brief Optional offset that is used as the + absolute address if the SymName string is NUL */ + char SymName[OS_MAX_SYM_LEN];/**< \brief Symbol name string */ +} CFS_SymAddr_t; + +/************************************************************************* +** Exported Functions +*************************************************************************/ +/************************************************************************/ +/** \brief Compute CRC from a file +** +** \par Description +** This function will compute the cyclic redundancy check (CRC) +** value of data in a file +** +** \par Assumptions, External Events, and Notes: +** The computation starts from the current location of the +** file pointer to the end of file +** +** \param [in] FileHandle The open file handle of the file to scan +** +** \param [in] CrcPtr Where to store the computed CRC. +** +** \param [in] TypeCRC One of the enumerated CRC types supported +** by the #CFE_ES_CalculateCRC function +** +** \param [out] *CrcPtr The computed CRC. Only updated if the return +** value is #OS_SUCCESS +** +** \returns +** \retstmt Returns #OS_SUCCESS if no error \endcode +** \retstmt The return code from #OS_read if an error occured \endcode +** \endreturns +** +** \sa #CFE_ES_CalculateCRC, #OS_read +** +*************************************************************************/ +int32 CFS_ComputeCRCFromFile(uint32 FileHandle, + uint32 *CrcPtr, + uint32 TypeCRC); + +/************************************************************************/ +/** \brief Check for invalid filename +** +** \par Description +** This function will scan a filename string for invalid characters +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param [in] Filename The file name string to scan +** +** \param [in] Length The string length of Filename +** +** \returns +** \retstmt Returns TRUE if the file name is valid \endcode +** \retstmt Returns FALSE if an invalid character was found \endcode +** \endreturns +** +*************************************************************************/ +boolean CFS_IsValidFilename(char *Filename, + uint32 Length); + +/************************************************************************/ +/** \brief Resolve symbolic address +** +** \par Description +** This routine will resolve a symbol name and optional address +** offset to an absolute address +** +** \par Assumptions, External Events, and Notes: +** If the symbol name is a NUL (empty) string, then the offset +** becomes the absolute address +** +** \param [in] SymAddr A #CFS_SymAddr_t pointer that holds +** the symbol name and optional offset +** +** \param [in] ResolvedAddr A pointer to the location to store +** the resolved address in +** +** \param [out] *ResolvedAddr The fully resolved address. Only valid +** if the return value is TRUE +* +** \returns +** \retstmt Returns TRUE if the resolution was successful \endcode +** \retstmt Returns FALSE if the resolution was not successful \endcode +** \endreturns +** +** \sa #OS_SymbolLookup +** +*************************************************************************/ +boolean CFS_ResolveSymAddr(CFS_SymAddr_t *SymAddr, + uint32 *ResolvedAddr); + +/************************************************************************/ +/** \brief Verify 32 bit alignment +** +** \par Description +** This routine will check an address and data size argument pair +** for correct 32 bit alignment +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param [in] Address The address to check for proper alignment +** +** \param [in] Size The size in bytes to check for proper +** alignment +** +** \returns +** \retstmt Returns TRUE if both Address and Size are 32 bit aligned \endcode +** \retstmt Returns FALSE if either Address or Size is not 32 bit aligned \endcode +** \endreturns +** +** \sa #CFS_Verify16Aligned +** +*************************************************************************/ +boolean CFS_Verify32Aligned(uint32 Address, + uint32 Size); + +/************************************************************************/ +/** \brief Verify 16 bit alignment +** +** \par Description +** This routine will check an address and data size argument pair +** for correct 16 bit alignment +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param [in] Address The address to check for proper alignment +** +** \param [in] Size The size in bytes to check for proper +** alignment +** +** \returns +** \retstmt Returns TRUE if both Address and Size are 16 bit aligned \endcode +** \retstmt Returns FALSE if either Address or Size is not 16 bit aligned \endcode +** \endreturns +** +** \sa #CFS_Verify32Aligned +** +*************************************************************************/ +boolean CFS_Verify16Aligned(uint32 Address, + uint32 Size); + +/************************************************************************/ +/** \brief Determine whether Software Bus message packet is filtered +** +** \par Description +** This routine will apply the CFS filter algorithm to the packet +** to determine whether the packet should be filtered. This same +** algorithm may be used by multiple applications (DS, TO, etc.) +** +** \par Assumptions, External Events, and Notes: +** None +** +** \param [in] MessagePtr Pointer to a Software Bus message packet +** +** \param [in] FilterType Packet sequence count (1) or timestamp (2) +** +** \param [in] Algorithm_N Algorithm parameter N "pass this many" +** \param [in] Algorithm_X Algorithm parameter X "out of this many" +** \param [in] Algorithm_O Algorithm parameter O "at this offset" +** +** \returns +** \retstmt Returns TRUE if the packet should be filtered (not used) \endcode +** \retstmt Returns FALSE if the packet should not be filtered (used) \endcode +** \endreturns +** +** \sa #CFS_IsPacketFiltered +** +*************************************************************************/ +boolean CFS_IsPacketFiltered(CFE_SB_MsgPtr_t MessagePtr, + uint16 FilterType, + uint16 Algorithm_N, + uint16 Algorithm_X, + uint16 Algorithm_O); + +/*******************************************************************/ +/* \brief Verify string data +** +** \par Description +** This common function performs the following evaluations: +** - Is the buffer empty? (if yes, result OK if not required) +** - Does string have a terminator? (if not, result BAD) +** - Does filename have valid chars? (only filenames tested) +** +** \par Assumptions, External Events, and Notes: +** (none) +** +** \param [in] Pointer to buffer containing string +** \param [in] Length (in bytes) of buffer +** \param [in] Is string required or optional? +** \param [in] Is string part of a filename? (limited chars) +** +** \sa #CFS_VerifyString +*/ +boolean CFS_VerifyString(char *Buffer, int32 BufferSize, + boolean StringIsRequired, boolean NeedCharTest); + +#endif /* _cfs_utils_h_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/fsw/src/cfs_lib_version.h b/fsw/src/cfs_lib_version.h new file mode 100644 index 0000000..8ee2c77 --- /dev/null +++ b/fsw/src/cfs_lib_version.h @@ -0,0 +1,53 @@ +/************************************************************************ +** File: +** $Id: cfs_lib_version.h 1.1.4.6 2015/03/02 18:40:20EST sstrege Exp $ +** +** Copyright © 2007-2014 United States Government as represented by the +** Administrator of the National Aeronautics and Space Administration. +** All Other Rights Reserved. +** +** This software was created at NASA's Goddard Space Flight Center. +** This software is governed by the NASA Open Source Agreement and may be +** used, distributed and modified only pursuant to the terms of that +** agreement. +** +** Purpose: +** The CFS Lib header file containing version number +** +** Notes: +** +** $Log: cfs_lib_version.h $ +** Revision 1.1.4.6 2015/03/02 18:40:20EST sstrege +** Changing the version number to 2.2.0.0 for documentation update release. +** Revision 1.1.4.5 2015/03/02 18:33:06EST sstrege +** Added copyright information +** Revision 1.1.4.4 2011/12/15 12:54:17EST nschweis +** Changing the version number for the variant to 9.9.9. +** Revision 1.1.4.3 2011/12/15 12:47:31EST nschweis +** Changing the version number to 2.2.0.0 for Release. +** Revision 1.1.4.2 2011/12/09 11:41:23EST nschweis +** Changing the version number for the variant to 9.9.9. +** Using CP 4323:98. +** Revision 1.1.4.1 2011/12/09 11:33:36EST nschweis +** Changing the version number for the build to 2.2.0. +** Using CP 4323:98. +** Revision 1.1 2008/09/19 14:52:41EDT rjmcgraw +** Initial revision +** Member added to project c:/MKSDATA/MKS-REPOSITORY/CFS-REPOSITORY/cfs_lib/fsw/src/project.pj +** +*************************************************************************/ +#ifndef _cfs_lib_version_h_ +#define _cfs_lib_version_h_ + + +#define CFS_LIB_MAJOR_VERSION 2 +#define CFS_LIB_MINOR_VERSION 2 +#define CFS_LIB_REVISION 0 +#define CFS_LIB_MISSION_REV 0 + + +#endif /* _cfs_lib_version_h_ */ + +/************************/ +/* End of File Comment */ +/************************/ diff --git a/fsw/src/cfs_utils.c b/fsw/src/cfs_utils.c new file mode 100644 index 0000000..6b66eba --- /dev/null +++ b/fsw/src/cfs_utils.c @@ -0,0 +1,534 @@ +/************************************************************************* +** File: +** $Id: cfs_utils.c 1.14 2015/03/02 18:30:05EST sstrege Exp $ +** +** Copyright © 2007-2014 United States Government as represented by the +** Administrator of the National Aeronautics and Space Administration. +** All Other Rights Reserved. +** +** This software was created at NASA's Goddard Space Flight Center. +** This software is governed by the NASA Open Source Agreement and may be +** used, distributed and modified only pursuant to the terms of that +** agreement. +** +** Purpose: +** Shared library functions for CFS applications +** +** $Log: cfs_utils.c $ +** Revision 1.14 2015/03/02 18:30:05EST sstrege +** Added copyright information +** Revision 1.13 2011/05/20 13:24:20EDT lwalling +** Modify packet filter to match algorithm used by SDO, GPM, etc. +** Revision 1.12 2010/09/21 14:36:34EDT wmoleski +** The sequence count in a ccsds packet header consists of the lower 14 bits. The code was using +** the entire 16 bit value to determine whether the packet should be filtered. This was changed to +** extract only the lower 14 bits for the sequence count. +** Revision 1.11 2010/09/21 08:50:05EDT wmoleski +** Deleted the line of code that checked if the currect character was a '%' for the valid filename check function. +** Revision 1.10 2009/08/31 17:46:41EDT lwalling +** Add function CFS_VerifyString() to CFS Library +** Revision 1.9 2009/08/13 10:04:30EDT lwalling +** Change test for (N >= X) to (N > X) in CFS_IsPacketFiltered() +** Revision 1.8 2009/05/26 13:31:07EDT lwalling +** Create common packet filter function in global CFS library +** Revision 1.7 2008/10/06 09:38:25EDT rjmcgraw +** DCR4400:1 Changed return on CFS_LibInit from void to int32 +** Revision 1.6 2008/09/19 15:30:51EDT rjmcgraw +** DCR4337:1 Added #include version.h and display version after initialization +** is complete +** Revision 1.5 2008/09/09 10:59:32EDT njyanchik +** I accidentally updated the list of allowable characters with a list of +** not-allowed characters. I +** need to fix it. +** Revision 1.4 2008/08/08 15:38:01BST njyanchik +** Since there was already a function for detecting invalid file names, I +** updated the list of the +** invalid characters to the list that is specified in the DCR. +** Revision 1.3 2008/05/15 14:40:33BST rjmcgraw +** DCR2179:1 Changed fucntion call OS_SymLookup to OS_SymbolLookup +** Revision 1.2 2008/05/13 13:47:02EDT rjmcgraw +** DCR2179:1 Changed include filename from cfs_lib.h to cfs_utils.h +** Revision 1.1 2008/05/13 13:13:28EDT rjmcgraw +** Initial revision +** Member added to CFS project +** +*************************************************************************/ + +/************************************************************************* +** Includes +*************************************************************************/ +#include "cfs_utils.h" +#include +#include +#include "cfs_lib_version.h" + +/************************************************************************* +** Macro Definitions +*************************************************************************/ +/** +** \name Crc File Buffer Size */ +#define FILE_CRC_BUFFER_SIZE 200 /**< \brief Number of bytes per file + read when computing the crc from + a file */ + +#define CFS_STRING_TERMINATOR '\0' /**< \brief ASCIIZ string terminator character */ + +#define CFS_PKT_SEQUENCE_BASED_FILTER_TYPE 1 +#define CFS_PKT_TIME_BASED_FILTER_TYPE 2 + +#define CFS_16_MSB_SUBSECS_SHIFT 16 +#define CFS_11_LSB_SECONDS_MASK 0x07FF +#define CFS_11_LSB_SECONDS_SHIFT 4 +#define CFS_4_MSB_SUBSECS_MASK 0xF000 +#define CFS_4_MSB_SUBSECS_SHIFT 12 + +/************************************************************************* +** Private Function Prototypes +*************************************************************************/ +int32 CFS_LibInit(void); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* CFS Library Initialization Routine */ +/* cFE requires that a library have an initialization routine */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 CFS_LibInit(void) +{ + + OS_printf ("CFS Lib Initialized. Version %d.%d.%d.%d", + CFS_LIB_MAJOR_VERSION, + CFS_LIB_MINOR_VERSION, + CFS_LIB_REVISION, + CFS_LIB_MISSION_REV); + + return OS_SUCCESS; + +}/* End CFS_LibInit */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Compute the CRC of data in a file */ +/* Operates from the current location of the file poiner to EOF */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 CFS_ComputeCRCFromFile(uint32 FileHandle, + uint32 *CrcPtr, + uint32 TypeCRC) +{ + int32 ByteCntr; + int32 OS_Status = OS_SUCCESS; + uint32 TempCrc = 0; +static uint8 DataArray[FILE_CRC_BUFFER_SIZE]; + + do + { + /* + ** Read in some data + */ + ByteCntr = OS_read(FileHandle, DataArray, sizeof(DataArray)); + + /* + ** If we didn't hit end of file on the last read... + */ + if (ByteCntr > 0) + { + /* + ** Calculate the CRC based upon the previous CRC calculation + */ + TempCrc = CFE_ES_CalculateCRC(DataArray, ByteCntr, TempCrc, TypeCRC); + } + + } + while(ByteCntr > 0); + + /* + ** Check if we broke out of the loop because of an error return + ** from the OS_read call + */ + if (ByteCntr < 0) + { + OS_Status = ByteCntr; + } + else + { + *CrcPtr = TempCrc; + } + + return(OS_Status); + +} /* End CFS_ComputeCRCFromFile */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Check a file name string for undesirable characters */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +boolean CFS_IsValidFilename(char *Filename, + uint32 Length) +{ + boolean Valid = TRUE; + int32 i; + + /* + ** Test for a NUL string + */ + if(Filename[0] == '\0') + { + Valid = FALSE; + } + else + { + /* + ** Scan string for disallowed characters + */ + for(i=0; iSymName[OS_MAX_SYM_LEN - 1] = '\0'; + + /* + ** If the symbol name string is a nul string + ** we use the offset as the absolute address + */ + if(strlen(SymAddr->SymName) == 0) + { + *ResolvedAddr = SymAddr->Offset; + Valid = TRUE; + } + else + { + /* + ** If symbol name is not an empty string look it up + ** using the OSAL API and add the offset if it succeeds + */ + OS_Status = OS_SymbolLookup(ResolvedAddr, SymAddr->SymName); + if (OS_Status == OS_SUCCESS) + { + *ResolvedAddr += SymAddr->Offset; + Valid = TRUE; + } + else + Valid = FALSE; + } + return (Valid); + +}/* End CFS_ResolveSymAddr */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Verify an address and data size are 32 bit aligned */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +boolean CFS_Verify32Aligned(uint32 Address, + uint32 Size) +{ + boolean IsAligned; + + if(Address % sizeof(uint32) != 0) + { + IsAligned = FALSE; + } + else if(Size % sizeof(uint32) != 0) + { + IsAligned = FALSE; + } + else + { + IsAligned = TRUE; + } + + return(IsAligned); + +} /* End CFS_Verify32Aligned */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Verify an address and data size are 16 bit aligned */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +boolean CFS_Verify16Aligned(uint32 Address, + uint32 Size) +{ + boolean IsAligned; + + if(Address % sizeof(uint16) != 0) + { + IsAligned = FALSE; + } + else if(Size % sizeof(uint16) != 0) + { + IsAligned = FALSE; + } + else + { + IsAligned = TRUE; + } + + return(IsAligned); + +} /* End CFS_Verify16Aligned */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Apply common filter algorithm to Software Bus packet */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +boolean CFS_IsPacketFiltered(CFE_SB_MsgPtr_t MessagePtr, + uint16 FilterType, + uint16 Algorithm_N, + uint16 Algorithm_X, + uint16 Algorithm_O) +{ + /* + ** Algorithm_N = the filter will pass this many packets + ** Algorithm_X = out of every group of this many packets + ** Algorithm_O = starting at this offset within the group + */ + boolean PacketIsFiltered = FALSE; + CFE_TIME_SysTime_t PacketTime; + uint16 PacketValue; + uint16 Seconds; + uint16 Subsecs; + + /* + ** Verify input values (all errors = packet is filtered)... + */ + if (Algorithm_X == 0) + { + /* + ** Group size of zero will result in divide by zero... + */ + PacketIsFiltered = TRUE; + } + else if (Algorithm_N == 0) + { + /* + ** Pass count of zero will result in zero packets... + */ + PacketIsFiltered = TRUE; + } + else if (Algorithm_N > Algorithm_X) + { + /* + ** Pass count cannot exceed group size... + */ + PacketIsFiltered = TRUE; + } + else if (Algorithm_O >= Algorithm_X) + { + /* + ** Group offset must be less than group size... + */ + PacketIsFiltered = TRUE; + } + else if ((FilterType != CFS_PKT_TIME_BASED_FILTER_TYPE) && + (FilterType != CFS_PKT_SEQUENCE_BASED_FILTER_TYPE)) + { + /* + ** Invalid - unknown filter type... + */ + PacketIsFiltered = TRUE; + } + else + { + if (FilterType == CFS_PKT_SEQUENCE_BASED_FILTER_TYPE) + { + /* + ** Create packet filter value from packet sequence count... + */ + PacketValue = CCSDS_RD_SEQ(MessagePtr->Hdr); + } + else + { + /* + ** Create packet filter value from packet timestamp... + */ + PacketTime = CFE_SB_GetMsgTime(MessagePtr); + + /* + ** Get the least significant 11 bits of timestamp seconds... + */ + Seconds = (uint16) PacketTime.Seconds; + Seconds = Seconds & CFS_11_LSB_SECONDS_MASK; + + /* + ** Get the most significant 4 bits of timestamp subsecs... + */ + Subsecs = (uint16) (PacketTime.Subseconds >> CFS_16_MSB_SUBSECS_SHIFT); + Subsecs = Subsecs & CFS_4_MSB_SUBSECS_MASK; + + /* + ** Shift seconds and subsecs to allow merge... + */ + Seconds = Seconds << CFS_11_LSB_SECONDS_SHIFT; + Subsecs = Subsecs >> CFS_4_MSB_SUBSECS_SHIFT; + + /* + ** Merge seconds and subsecs to create packet filter value... + */ + PacketValue = Seconds | Subsecs; + } + + /* + ** Apply the filter algorithm (common for both filter types)... + */ + if (PacketValue < Algorithm_O) + { + /* + ** Value is less than offset of passed range... + */ + PacketIsFiltered = TRUE; + } + else if (((PacketValue - Algorithm_O) % Algorithm_X) < Algorithm_N) + { + /* + ** This packet was passed by the filter algorithm... + */ + PacketIsFiltered = FALSE; + } + else + { + /* + ** This packet was filtered by the filter algorithm... + */ + PacketIsFiltered = TRUE; + } + } + + return(PacketIsFiltered); + +} /* End of CFS_IsPacketFiltered() */ + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* CFS_VerifyString() - verify string data */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +boolean CFS_VerifyString(char *Buffer, int32 BufferSize, + boolean StringIsRequired, boolean NeedCharTest) +{ + boolean FoundTerminator; + boolean CharsAreGood; + boolean Result = FALSE; + int32 i; + + if (Buffer[0] == CFS_STRING_TERMINATOR) + { + /* + ** Buffer is empty... + */ + if (StringIsRequired) + { + Result = FALSE; + } + else + { + Result = TRUE; + } + } + else + { + /* + ** Buffer is not empty... + */ + FoundTerminator = FALSE; + CharsAreGood = FALSE; + + for (i = 0; i < BufferSize; i++) + { + /* + ** Find string terminator... + */ + if (Buffer[i] == CFS_STRING_TERMINATOR) + { + FoundTerminator = TRUE; + + if (NeedCharTest) + { + /* + ** Verify that chars are legal for filenames... + */ + CharsAreGood = CFS_IsValidFilename(Buffer, i); + } + else + { + /* + ** All chars are OK for descriptive text... + */ + CharsAreGood = TRUE; + } + break; + } + } + + /* + ** Verify that string has valid chars and a terminator... + */ + Result = ((FoundTerminator) && (CharsAreGood)); + } + + return(Result); + +} /* End of CFS_VerifyString() */ + + +/************************/ +/* End of File Comment */ +/************************/