Go to the documentation of this file.
41 memset(&addr, 0,
sizeof(addr));
43 uint32_t
len = strlen(
str);
45 for (i = 0; i <
len; i++) {
46 if (!(
str[i] ==
'.' || isdigit(
str[i]))) {
54 addr[dots][alen] =
'\0';
62 addr[dots][alen++] =
str[i];
68 addr[dots][alen] =
'\0';
69 for (
int x = 0; x < 4; x++) {
72 SCLogDebug(
"invalid value for address byte: %s", addr[x]);
86 bool colon_seen =
false;
88 uint32_t
len = strlen(
str);
90 for (i = 0; i <
len &&
str[i] != 0; i++) {
91 if (!(
str[i] ==
'.' ||
str[i] ==
':' ||
99 }
else if (
str[i] ==
'.') {
132 struct in_addr *addr = NULL;
137 if ( (addr =
SCMalloc(
sizeof(
struct in_addr))) == NULL) {
138 FatalError(
"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) {
167 FatalError(
"Fatal error encountered in ValidateIPV6Address. Exiting...");
170 if (inet_pton(AF_INET6, addr_str, addr) <= 0) {
191 int bytes = key_bitlen / 8;
193 for (i = 0; i < bytes; i++) {
195 if ( ((i + 1) * 8) > netmask) {
196 if ( ((i + 1) * 8 - netmask) < 8)
197 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 address.