|
suricata
|
#include "suricata-common.h"#include "util-byte.h"#include "util-unittest.h"#include "util-debug.h"#include "util-validate.h"
Go to the source code of this file.
Functions | |
| char * | BytesToString (const uint8_t *bytes, size_t nbytes) |
| Turn byte array into string. More... | |
| void | BytesToStringBuffer (const uint8_t *bytes, size_t nbytes, char *outstr, size_t outlen) |
| Turn byte array into string. More... | |
| int | ByteExtractUint64 (uint64_t *res, int e, uint16_t len, const uint8_t *bytes) |
| int | ByteExtractUint32 (uint32_t *res, int e, uint16_t len, const uint8_t *bytes) |
| int | ByteExtractUint16 (uint16_t *res, int e, uint16_t len, const uint8_t *bytes) |
| int | ByteExtractString (uint64_t *res, int base, size_t len, const char *str, bool strict) |
| int | ByteExtractStringUint64 (uint64_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringUint32 (uint32_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringUint16 (uint16_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringUint8 (uint8_t *res, int base, size_t len, const char *str) |
| int | StringParseUint64 (uint64_t *res, int base, size_t len, const char *str) |
| int | StringParseUint32 (uint32_t *res, int base, size_t len, const char *str) |
| int | StringParseUint16 (uint16_t *res, int base, size_t len, const char *str) |
| int | StringParseUint8 (uint8_t *res, int base, size_t len, const char *str) |
| int | StringParseU64RangeCheck (uint64_t *res, int base, size_t len, const char *str, uint64_t min, uint64_t max) |
| int | StringParseU32RangeCheck (uint32_t *res, int base, size_t len, const char *str, uint32_t min, uint32_t max) |
| int | StringParseU16RangeCheck (uint16_t *res, int base, size_t len, const char *str, uint16_t min, uint16_t max) |
| int | StringParseU8RangeCheck (uint8_t *res, int base, size_t len, const char *str, uint8_t min, uint8_t max) |
| int | ByteExtractStringSigned (int64_t *res, int base, size_t len, const char *str, bool strict) |
| int | ByteExtractStringInt64 (int64_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringInt32 (int32_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringInt16 (int16_t *res, int base, size_t len, const char *str) |
| int | ByteExtractStringInt8 (int8_t *res, int base, size_t len, const char *str) |
| int | StringParseInt64 (int64_t *res, int base, size_t len, const char *str) |
| int | StringParseInt32 (int32_t *res, int base, size_t len, const char *str) |
| int | StringParseInt16 (int16_t *res, int base, size_t len, const char *str) |
| int | StringParseInt8 (int8_t *res, int base, size_t len, const char *str) |
| int | StringParseI64RangeCheck (int64_t *res, int base, size_t len, const char *str, int64_t min, int64_t max) |
| int | StringParseI32RangeCheck (int32_t *res, int base, size_t len, const char *str, int32_t min, int32_t max) |
| int | StringParseI16RangeCheck (int16_t *res, int base, size_t len, const char *str, int16_t min, int16_t max) |
| int | StringParseI8RangeCheck (int8_t *res, int base, size_t len, const char *str, int8_t min, int8_t max) |
| int | HexToRaw (const uint8_t *in, size_t ins, uint8_t *out, size_t outs) |
| void | ByteRegisterTests (void) |
Byte utility functions
Definition in file util-byte.c.
| int ByteExtractString | ( | uint64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| bool | strict | ||
| ) |
Extract unsigned integer value from a string.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
| bool | Enable strict check for parsers |
Definition at line 188 of file util-byte.c.
| int ByteExtractStringInt16 | ( | int16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as uint16_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 579 of file util-byte.c.
| int ByteExtractStringInt32 | ( | int32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as uint32_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 554 of file util-byte.c.
| int ByteExtractStringInt64 | ( | int64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as uint64_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 549 of file util-byte.c.
| int ByteExtractStringInt8 | ( | int8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as uint8_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 604 of file util-byte.c.
| int ByteExtractStringSigned | ( | int64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| bool | strict | ||
| ) |
Extract signed integer value from a string.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
| bool | Enable strict check for parsers |
Definition at line 503 of file util-byte.c.
| int ByteExtractStringUint16 | ( | uint16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint16_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 265 of file util-byte.c.
| int ByteExtractStringUint32 | ( | uint32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint32_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 242 of file util-byte.c.
Referenced by SCGetGroupID(), and SCGetUserID().

| int ByteExtractStringUint64 | ( | uint64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint64_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 237 of file util-byte.c.
Referenced by DetectByteExtractDoMatch().

| int ByteExtractStringUint8 | ( | uint8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint8_t.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 288 of file util-byte.c.
| int ByteExtractUint16 | ( | uint16_t * | res, |
| int | e, | ||
| uint16_t | len, | ||
| const uint8_t * | bytes | ||
| ) |
Extract bytes from a byte string and convert to a unint16_t.
| res | Stores result |
| e | Endianness (BYTE_BIG_ENDIAN or BYTE_LITTLE_ENDIAN) |
| len | Number of bytes to extract (8 max) |
| bytes | Data to extract from |
Definition at line 167 of file util-byte.c.
References len.
| int ByteExtractUint32 | ( | uint32_t * | res, |
| int | e, | ||
| uint16_t | len, | ||
| const uint8_t * | bytes | ||
| ) |
| Greater | than 0 if successful, 0 or negative on failure. |
Definition at line 146 of file util-byte.c.
References len.
| int ByteExtractUint64 | ( | uint64_t * | res, |
| int | e, | ||
| uint16_t | len, | ||
| const uint8_t * | bytes | ||
| ) |
Extract bytes from a byte string and convert to a unint64_t.
| res | Stores result |
| e | Endianness (BYTE_BIG_ENDIAN or BYTE_LITTLE_ENDIAN) |
| len | Number of bytes to extract (8 max) |
| bytes | Data to extract from |
Definition at line 122 of file util-byte.c.
References len.
Referenced by DetectByteExtractDoMatch().

| void ByteRegisterTests | ( | void | ) |
Definition at line 1076 of file util-byte.c.
References UtRegisterTest().

| char* BytesToString | ( | const uint8_t * | bytes, |
| size_t | nbytes | ||
| ) |
Turn byte array into string.
All non-printables are copied over, except for '\0', which is turned into literal \0 in the string.
| bytes | byte array |
| nbytes | number of bytes |
Definition at line 41 of file util-byte.c.
| void BytesToStringBuffer | ( | const uint8_t * | bytes, |
| size_t | nbytes, | ||
| char * | outstr, | ||
| size_t | outlen | ||
| ) |
Turn byte array into string.
All non-printables are copied over, except for '\0', which is turned into literal \0 in the string.
| bytes | byte array |
| nbytes | number of bytes |
| outstr[out] | buffer to fill |
| outlen | size of outstr. Must be at least 2 * nbytes + 1 in size |
Definition at line 85 of file util-byte.c.
References DEBUG_VALIDATE_BUG_ON, dst, and strlcpy().

| int HexToRaw | ( | const uint8_t * | in, |
| size_t | ins, | ||
| uint8_t * | out, | ||
| size_t | outs | ||
| ) |
Definition at line 818 of file util-byte.c.
References SCLogError.
| int StringParseI16RangeCheck | ( | int16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| int16_t | min, | ||
| int16_t | max | ||
| ) |
Extract signed integer value from a string as int16_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 758 of file util-byte.c.
| int StringParseI32RangeCheck | ( | int32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| int32_t | min, | ||
| int32_t | max | ||
| ) |
Extract signed integer value from a string as int32_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 728 of file util-byte.c.
| int StringParseI64RangeCheck | ( | int64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| int64_t | min, | ||
| int64_t | max | ||
| ) |
Extract signed integer value from a string as int64_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 709 of file util-byte.c.
| int StringParseI8RangeCheck | ( | int8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| int8_t | min, | ||
| int8_t | max | ||
| ) |
Extract signed integer value from a string as int8_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 788 of file util-byte.c.
| int StringParseInt16 | ( | int16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as int16_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 659 of file util-byte.c.
| int StringParseInt32 | ( | int32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as int32_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 634 of file util-byte.c.
Referenced by SCKernelVersionIsAtLeast().

| int StringParseInt64 | ( | int64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as int64_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 629 of file util-byte.c.
Referenced by UtilCpuGetNumProcessorsConfigured().

| int StringParseInt8 | ( | int8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract signed integer value from a string as int8_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 684 of file util-byte.c.
| int StringParseU16RangeCheck | ( | uint16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| uint16_t | min, | ||
| uint16_t | max | ||
| ) |
Extract unsigned integer value from a string as uint16_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 442 of file util-byte.c.
| int StringParseU32RangeCheck | ( | uint32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| uint32_t | min, | ||
| uint32_t | max | ||
| ) |
Extract unsigned integer value from a string as uint32_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 413 of file util-byte.c.
| int StringParseU64RangeCheck | ( | uint64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| uint64_t | min, | ||
| uint64_t | max | ||
| ) |
Extract unsigned integer value from a string as uint64_t strictly within the range.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 394 of file util-byte.c.
| int StringParseU8RangeCheck | ( | uint8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str, | ||
| uint8_t | min, | ||
| uint8_t | max | ||
| ) |
| Greater | than 0 if successful, 0 or negative on failure. |
Definition at line 474 of file util-byte.c.
Referenced by SCRadix4AddKeyIPV4String(), and SCRadix6AddKeyIPV6String().

| int StringParseUint16 | ( | uint16_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
| Greater | than 0 if successful, 0 or negative on failure. |
Definition at line 343 of file util-byte.c.
Referenced by IPFWRegisterQueue(), and PostConfLoadedSetup().

| int StringParseUint32 | ( | uint32_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint32_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 316 of file util-byte.c.
Referenced by BuildCpusetWithCallback(), FlowInitConfig(), FlowInitFlowProto(), HttpRangeContainersInit(), and SCConfLogOpenGeneric().

| int StringParseUint64 | ( | uint64_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
Extract unsigned integer value from a string as uint64_t strictly.
| res | Stores result |
| base | Base of the number to extract |
| len | Number of bytes to extract (23 max or 0 for unbounded) |
| str | String to extract from |
Definition at line 311 of file util-byte.c.
| int StringParseUint8 | ( | uint8_t * | res, |
| int | base, | ||
| size_t | len, | ||
| const char * | str | ||
| ) |
| Greater | than 0 if successful, 0 or negative on failure. |
Definition at line 370 of file util-byte.c.
Referenced by IPv4AddressStringIsValid().
