Go to the documentation of this file.
40 memset(&addr, 0,
sizeof(addr));
42 uint32_t
len = strlen(
str);
44 for (i = 0; i <
len; i++) {
45 if (!(
str[i] ==
'.' || isdigit(
str[i]))) {
53 addr[dots][alen] =
'\0';
61 addr[dots][alen++] =
str[i];
67 addr[dots][alen] =
'\0';
68 for (
int x = 0; x < 4; x++) {
71 SCLogDebug(
"invalid value for address byte: %s", addr[x]);
85 bool colon_seen =
false;
87 uint32_t
len = strlen(
str);
89 for (i = 0; i <
len &&
str[i] != 0; i++) {
90 if (!(
str[i] ==
'.' ||
str[i] ==
':' ||
98 }
else if (
str[i] ==
'.') {
131 struct in_addr *addr = NULL;
136 if ( (addr =
SCMalloc(
sizeof(
struct in_addr))) == NULL) {
138 "Fatal error encountered in ValidateIPV4Address. Exiting...");
141 if (inet_pton(AF_INET, addr_str, addr) <= 0) {
161 struct in6_addr *addr = NULL;
166 if ( (addr =
SCMalloc(
sizeof(
struct in6_addr))) == NULL) {
168 "Fatal error encountered in ValidateIPV6Address. Exiting...");
171 if (inet_pton(AF_INET6, addr_str, addr) <= 0) {
192 int bytes = key_bitlen / 8;
194 for (i = 0; i < bytes; i++) {
196 if ( ((i + 1) * 8) > netmask) {
197 if ( ((i + 1) * 8 - netmask) < 8)
198 mask = UINT_MAX << ((i + 1) * 8 - netmask);
void MaskIPNetblock(uint8_t *stream, int netmask, int key_bitlen)
Culls the non-netmask portion of the IP address. For example an IP address 192.168....
bool IPv4AddressStringIsValid(const char *str)
determine if a string is a valid ipv4 address
int StringParseUint8(uint8_t *res, int base, size_t len, const char *str)
struct in_addr * ValidateIPV4Address(const char *addr_str)
Validates an IPV4 address and returns the network endian arranged version of the IPV4 address.
bool IPv6AddressStringIsValid(const char *str)
determine if a string is a valid ipv6 address
struct in6_addr * ValidateIPV6Address(const char *addr_str)
Validates an IPV6 address and returns the network endian arranged version of the IPV6 addresss.
#define FatalError(x,...)