Feature: support local host name & ptr resolve.
This commit is contained in:
27
src/util.c
27
src/util.c
@@ -133,7 +133,7 @@ errout:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int getaddr_by_host(char *host, struct sockaddr *addr, socklen_t *addr_len)
|
||||
int getaddr_by_host(const char *host, struct sockaddr *addr, socklen_t *addr_len)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *result = NULL;
|
||||
@@ -473,6 +473,31 @@ char *reverse_string(char *output, const char *input, int len, int to_lower_case
|
||||
return begin;
|
||||
}
|
||||
|
||||
char *to_lower_case(char *output, const char *input, int len)
|
||||
{
|
||||
char *begin = output;
|
||||
int i = 0;
|
||||
if (len <= 0) {
|
||||
*output = 0;
|
||||
return output;
|
||||
}
|
||||
|
||||
len--;
|
||||
while (i < len && *(input + i) != '\0') {
|
||||
*output = *(input + i);
|
||||
if (*output >= 'A' && *output <= 'Z') {
|
||||
/* To lower case */
|
||||
*output = *output + 32;
|
||||
}
|
||||
output++;
|
||||
i++;
|
||||
}
|
||||
|
||||
*output = 0;
|
||||
|
||||
return begin;
|
||||
}
|
||||
|
||||
static inline void _ipset_add_attr(struct nlmsghdr *netlink_head, uint16_t type, size_t len, const void *data)
|
||||
{
|
||||
struct ipset_netlink_attr *attr = (void *)netlink_head + NETLINK_ALIGN(netlink_head->nlmsg_len);
|
||||
|
||||
Reference in New Issue
Block a user