zcutils: integrate zevenet core utils

Integration of the zevenet core utils in order to improve maintenance
of the l4 load balancer core (nftlb) and l7 load balancer proxy (zproxy)
common functions.

Signed-off-by: nevola <laura.garcia@zevenet.com>
This commit is contained in:
nevola 2022-11-22 14:10:03 +01:00
parent fe3cd0b679
commit c7b9ae659c
47 changed files with 2567 additions and 852 deletions

View File

@ -1,5 +1,6 @@
AM_CPPFLAGS = -I$(top_srcdir)/include ${LIBNFTABLES_CFLAGS} \
${LIBJSON_CFLAGS} ${LIBMNL_CFLAGS}
${LIBJSON_CFLAGS} ${LIBMNL_CFLAGS} \
-I$(top_srcdir)/zcutils/include
AM_CFLAGS = -std=gnu99 -W -Wall -Wno-unused-parameter \
-Wmissing-prototypes -Wno-strict-aliasing -rdynamic

View File

@ -4,7 +4,6 @@ sbin_PROGRAMS = nftlb
nftlb_SOURCES = config.c \
main.c \
sbuffer.c \
objects.c \
farms.c \
backends.c \
@ -17,9 +16,13 @@ nftlb_SOURCES = config.c \
farmpolicy.c \
sessions.c \
checksum.c \
tools.c \
addresses.c \
farmaddress.c \
addresspolicy.c \
nftst.c
nftst.c \
../zcutils/src/zcu_backtrace.c \
../zcutils/src/zcu_log.c \
../zcutils/src/zcu_network.c \
../zcutils/src/zcu_sbuffer.c \
../zcutils/src/zcu_string.c
nftlb_LDADD = ${LIBNFTABLES_LIBS} ${LIBJSON_LIBS} ${LIBMNL_LIBS} -lev

View File

@ -33,8 +33,7 @@
#include "network.h"
#include "config.h"
#include "nft.h"
#include "tools.h"
#include "zcu_log.h"
struct address * address_create(char *name)
{
@ -42,7 +41,7 @@ struct address * address_create(char *name)
struct address *paddress = (struct address *)malloc(sizeof(struct address));
if (!paddress) {
tools_printlog(LOG_ERR, "Address memory allocation error");
zcu_log_print(LOG_ERR, "Address memory allocation error");
return NULL;
}
@ -81,7 +80,7 @@ int address_delete(struct address *paddress)
if (!paddress)
return 0;
tools_printlog(LOG_DEBUG, "%s():%d: deleting address %s",
zcu_log_print(LOG_DEBUG, "%s():%d: deleting address %s",
__FUNCTION__, __LINE__, paddress->name);
list_del(&paddress->list);
@ -178,41 +177,41 @@ void address_print(struct address *a)
{
char buf[100] = {};
tools_printlog(LOG_DEBUG," [address] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, a->name);
zcu_log_print(LOG_DEBUG," [address] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, a->name);
if (a->fqdn)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, a->fqdn);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, a->fqdn);
if (a->iface)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
if (a->iethaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
tools_printlog(LOG_DEBUG," *[ifidx] %d", a->ifidx);
zcu_log_print(LOG_DEBUG," *[ifidx] %d", a->ifidx);
if (a->ipaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, a->ipaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, a->ipaddr);
if (a->ports)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORTS, a->ports);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORTS, a->ports);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
obj_print_verdict(a->verdict, (char *)buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_VERDICT, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_VERDICT, buf);
if (a->logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, a->logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, a->logprefix);
obj_print_rtlimit(buf, a->logrtlimit, a->logrtlimit_unit);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG_RTLIMIT, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG_RTLIMIT, buf);
tools_printlog(LOG_DEBUG," *[used] %d", a->used);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, a->action);
tools_printlog(LOG_DEBUG," *[policies_action] %d", a->policies_action);
tools_printlog(LOG_DEBUG," *[nft_chains] %x", a->nft_chains);
zcu_log_print(LOG_DEBUG," *[used] %d", a->used);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, a->action);
zcu_log_print(LOG_DEBUG," *[policies_action] %d", a->policies_action);
zcu_log_print(LOG_DEBUG," *[nft_chains] %x", a->nft_chains);
if (a->policies_used > 0)
addresspolicy_s_print(a);
@ -226,10 +225,10 @@ static int address_set_iface_info(struct address *a)
int if_index;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: address %s set interface info for interface", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s set interface info for interface", __FUNCTION__, __LINE__, a->name);
if (a->iface && strcmp(a->iface, IFACE_LOOPBACK) == 0) {
tools_printlog(LOG_DEBUG, "%s():%d: address %s doesn't require input netinfo, loopback interface", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s doesn't require input netinfo, loopback interface", __FUNCTION__, __LINE__, a->name);
a->ifidx = 0;
return 0;
}
@ -237,7 +236,7 @@ static int address_set_iface_info(struct address *a)
ret = net_get_local_ifname_per_vip(a->ipaddr, if_str);
if (ret != 0) {
tools_printlog(LOG_ERR, "%s():%d: inbound interface not found with IP %s by address %s", __FUNCTION__, __LINE__, a->ipaddr, a->name);
zcu_log_print(LOG_ERR, "%s():%d: inbound interface not found with IP %s by address %s", __FUNCTION__, __LINE__, a->ipaddr, a->name);
return -1;
}
@ -249,7 +248,7 @@ static int address_set_iface_info(struct address *a)
if_index = if_nametoindex(a->iface);
if (if_index == 0) {
tools_printlog(LOG_ERR, "%s():%d: index of the inbound interface %s in address %s not found", __FUNCTION__, __LINE__, a->iface, a->name);
zcu_log_print(LOG_ERR, "%s():%d: index of the inbound interface %s in address %s not found", __FUNCTION__, __LINE__, a->iface, a->name);
return -1;
}
@ -282,7 +281,7 @@ static int address_set_verdict(struct address *a, int new_value)
{
int old_value = a->verdict;
tools_printlog(LOG_DEBUG, "%s():%d: address %s old verdict %d new verdict %d", __FUNCTION__, __LINE__, a->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s old verdict %d new verdict %d", __FUNCTION__, __LINE__, a->name, old_value, new_value);
if (new_value == VALUE_VERDICT_NONE)
return 1;
@ -294,7 +293,7 @@ static int address_set_verdict(struct address *a, int new_value)
int address_set_netinfo(struct address *a)
{
tools_printlog(LOG_DEBUG, "%s():%d: address %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s", __FUNCTION__, __LINE__, a->name);
address_set_iface_info(a);
farm_s_set_oface_info(a);
@ -309,7 +308,7 @@ int address_changed(struct config_pair *c)
if (!a)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: address %s with param %d", __FUNCTION__, __LINE__, a->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s with param %d", __FUNCTION__, __LINE__, a->name, c->key);
switch (c->key) {
case KEY_NAME:
@ -400,7 +399,7 @@ int address_set_attribute(struct config_pair *c)
int ret = PARSER_FAILED;
if (c->key != KEY_NAME && !a) {
tools_printlog(LOG_INFO, "%s():%d: address UNKNOWN", __FUNCTION__, __LINE__);
zcu_log_print(LOG_INFO, "%s():%d: address UNKNOWN", __FUNCTION__, __LINE__);
return PARSER_OBJ_UNKNOWN;
}
@ -482,7 +481,7 @@ int address_not_used(struct address *a)
int address_set_action(struct address *a, int action)
{
tools_printlog(LOG_DEBUG, "%s():%d: address %s action is %d - new action %d", __FUNCTION__, __LINE__, a->name, a->action, action);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s action is %d - new action %d", __FUNCTION__, __LINE__, a->name, a->action, action);
if (a->action == action)
return 0;
@ -528,12 +527,12 @@ int address_no_ipaddr(struct address *a)
int address_rulerize(struct address *a)
{
tools_printlog(LOG_DEBUG, "%s():%d: rulerize address %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize address %s", __FUNCTION__, __LINE__, a->name);
address_print(a);
if (a->used) {
tools_printlog(LOG_INFO, "%s():%d: address %s won't be rulerized", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_INFO, "%s():%d: address %s won't be rulerized", __FUNCTION__, __LINE__, a->name);
return 0;
}
@ -547,7 +546,7 @@ int address_s_rulerize(void)
int ret = 0;
int output = 0;
tools_printlog(LOG_DEBUG, "%s():%d: rulerize addresses", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize addresses", __FUNCTION__, __LINE__);
list_for_each_entry_safe(a, next, addresses, list) {
ret = address_rulerize(a);
@ -567,7 +566,7 @@ int address_s_lookup_policy_action(char *name, int action)
struct list_head *addresses = obj_get_addresses();
struct address *a, *next;
tools_printlog(LOG_DEBUG, "%s():%d: name %s action %d", __FUNCTION__, __LINE__, name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: name %s action %d", __FUNCTION__, __LINE__, name, action);
list_for_each_entry_safe(a, next, addresses, list)
addresspolicy_s_lookup_policy_action(a, name, action);
@ -577,7 +576,7 @@ int address_s_lookup_policy_action(char *name, int action)
int address_validate_iface(struct address *a)
{
tools_printlog(LOG_DEBUG, "%s():%d: validating inbound address interface of %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating inbound address interface of %s", __FUNCTION__, __LINE__, a->name);
if (!a || !a->iface || obj_equ_attribute_string(a->iface, ""))
return 1;
return 0;
@ -585,7 +584,7 @@ int address_validate_iface(struct address *a)
int address_validate_iether(struct address *a)
{
tools_printlog(LOG_DEBUG, "%s():%d: validating inbound address ether of %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating inbound address ether of %s", __FUNCTION__, __LINE__, a->name);
if (!a || !a->iethaddr || obj_equ_attribute_string(a->iethaddr, ""))
return 1;
return 0;

View File

@ -26,18 +26,17 @@
#include "addresspolicy.h"
#include "objects.h"
#include "network.h"
#include "tools.h"
#include "zcu_log.h"
static struct addresspolicy * addresspolicy_create(struct address *a, struct policy *p)
{
struct addresspolicy *ap = (struct addresspolicy *)malloc(sizeof(struct addresspolicy));
if (!ap) {
tools_printlog(LOG_ERR, "address policy memory allocation error");
zcu_log_print(LOG_ERR, "address policy memory allocation error");
return NULL;
}
tools_printlog(LOG_DEBUG, "%s():%d: address %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s", __FUNCTION__, __LINE__, a->name);
ap->address = a;
ap->policy = p;
@ -80,9 +79,9 @@ void addresspolicy_s_print(struct address *a)
struct addresspolicy *ap;
list_for_each_entry(ap, &a->policies, list) {
tools_printlog(LOG_DEBUG," [policy] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, ap->policy->name);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, ap->action);
zcu_log_print(LOG_DEBUG," [policy] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, ap->policy->name);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, ap->action);
}
}
@ -139,7 +138,7 @@ int addresspolicy_s_lookup_policy_action(struct address *a, char *name, int acti
struct addresspolicy *ap;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: address %s action is %d - new action %d", __FUNCTION__, __LINE__, a->name, a->action, action);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s action is %d - new action %d", __FUNCTION__, __LINE__, a->name, a->action, action);
ap = addresspolicy_lookup_by_name(a, name);
if (ap)
@ -185,7 +184,7 @@ int addresspolicy_pre_actionable(struct config_pair *c)
if (!a)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable address policy for address %s", __FUNCTION__, __LINE__, a->name);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable address policy for address %s", __FUNCTION__, __LINE__, a->name);
address_set_action(a, ACTION_RELOAD);
address_rulerize(a);
@ -201,7 +200,7 @@ int addresspolicy_pos_actionable(struct config_pair *c)
if (!ap || !a)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable address policy %s for address %s with param %d", __FUNCTION__, __LINE__, ap->policy->name, a->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable address policy %s for address %s with param %d", __FUNCTION__, __LINE__, ap->policy->name, a->name, c->key);
address_set_action(a, ACTION_RELOAD);

View File

@ -30,7 +30,7 @@
#include "objects.h"
#include "network.h"
#include "sessions.h"
#include "tools.h"
#include "zcu_log.h"
#define BACKEND_MARK_MIN 0x00000001
#define BACKEND_MARK_MAX 0x00000FFF
@ -67,7 +67,7 @@ static struct backend * backend_create(struct farm *f, char *name)
{
struct backend *b = (struct backend *)malloc(sizeof(struct backend));
if (!b) {
tools_printlog(LOG_ERR, "Backend memory allocation error");
zcu_log_print(LOG_ERR, "Backend memory allocation error");
return NULL;
}
@ -126,7 +126,7 @@ static int backend_below_prio(struct backend *b)
{
struct farm *f = b->parent;
tools_printlog(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d <= farm prio %d",
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d <= farm prio %d",
__FUNCTION__, __LINE__, b->name, obj_print_state(b->state), b->priority, f->priority);
return (b->priority <= f->priority);
@ -136,7 +136,7 @@ static int backend_s_set_ports(struct farm *f)
{
struct backend *b;
tools_printlog(LOG_DEBUG, "%s():%d: finding backends with port for %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: finding backends with port for %s", __FUNCTION__, __LINE__, f->name);
list_for_each_entry(b, &f->backends, list) {
if (strcmp(b->port, DEFAULT_PORT) == 0) {
@ -181,38 +181,38 @@ void backend_s_print(struct farm *f)
struct backend *b;
list_for_each_entry(b, &f->backends, list) {
tools_printlog(LOG_DEBUG," [backend] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, b->name);
zcu_log_print(LOG_DEBUG," [backend] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, b->name);
if (b->fqdn)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, b->fqdn);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, b->fqdn);
if (b->oface)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_OFACE, b->oface);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_OFACE, b->oface);
tools_printlog(LOG_DEBUG," *[ofidx] %d", b->ofidx);
zcu_log_print(LOG_DEBUG," *[ofidx] %d", b->ofidx);
if (b->ipaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, b->ipaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, b->ipaddr);
if (b->ethaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_ETHADDR, b->ethaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_ETHADDR, b->ethaddr);
if (b->port)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORT, b->port);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORT, b->port);
if (b->srcaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_SRCADDR, b->srcaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_SRCADDR, b->srcaddr);
tools_printlog(LOG_DEBUG," [%s] 0x%x", CONFIG_KEY_MARK, b->mark);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_ESTCONNLIMIT, b->estconnlimit);
zcu_log_print(LOG_DEBUG," [%s] 0x%x", CONFIG_KEY_MARK, b->mark);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_ESTCONNLIMIT, b->estconnlimit);
if (b->estconnlimit_logprefix && strcmp(b->estconnlimit_logprefix, DEFAULT_B_ESTCONNLIMIT_LOGPREFIX) != 0)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_ESTCONNLIMIT_LOGPREFIX, b->estconnlimit_logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_ESTCONNLIMIT_LOGPREFIX, b->estconnlimit_logprefix);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_WEIGHT, b->weight);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_PRIORITY, b->priority);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_STATE, obj_print_state(b->state));
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, b->action);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_WEIGHT, b->weight);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_PRIORITY, b->priority);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_STATE, obj_print_state(b->state));
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, b->action);
}
}
@ -220,7 +220,7 @@ struct backend * backend_lookup_by_key(struct farm *f, int key, const char *name
{
struct backend *b;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s key %d name %s value %d", __FUNCTION__, __LINE__, f->name, key, name, value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s key %d name %s value %d", __FUNCTION__, __LINE__, f->name, key, name, value);
list_for_each_entry(b, &f->backends, list) {
switch (key) {
@ -265,7 +265,7 @@ static int backend_set_ipaddr_from_ether(struct backend *b)
fa = farmaddress_get_first(f);
if (!fa) {
tools_printlog(LOG_INFO, "%s():%d: no farm address configured in %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_INFO, "%s():%d: no farm address configured in %s", __FUNCTION__, __LINE__, f->name);
return -1;
}
@ -305,7 +305,7 @@ static int backend_set_ipaddr_from_ether(struct backend *b)
sprintf(streth, "%02x:%02x:%02x:%02x:%02x:%02x", dst_ethaddr[0],
dst_ethaddr[1], dst_ethaddr[2], dst_ethaddr[3], dst_ethaddr[4], dst_ethaddr[5]);
tools_printlog(LOG_DEBUG, "%s():%d: discovered ether address for %s is %s", __FUNCTION__, __LINE__, b->name, streth);
zcu_log_print(LOG_DEBUG, "%s():%d: discovered ether address for %s is %s", __FUNCTION__, __LINE__, b->name, streth);
if (b->ethaddr)
free(b->ethaddr);
@ -320,7 +320,7 @@ static int backend_set_weight(struct backend *b, int new_value)
struct farm *f = b->parent;
int old_value = b->weight;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
__FUNCTION__, __LINE__, old_value, new_value);
b->weight = new_value;
@ -335,7 +335,7 @@ static int backend_set_estconnlimit(struct backend *b, int new_value)
{
int old_value = b->estconnlimit;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
__FUNCTION__, __LINE__, old_value, new_value);
if (new_value == old_value)
@ -350,7 +350,7 @@ static void backend_s_update_counters(struct farm *f)
{
struct backend *bp, *next;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
f->bcks_available = 0;
f->bcks_usable = 0;
@ -370,7 +370,7 @@ static int backend_set_priority(struct backend *b, int new_value)
{
int old_value = b->priority;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
__FUNCTION__, __LINE__, old_value, new_value);
if (new_value <= 0)
@ -386,7 +386,7 @@ static int backend_s_set_srcaddr(struct farm *f)
{
struct backend *b;
tools_printlog(LOG_DEBUG, "%s():%d: finding backends with srouce address for %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: finding backends with srouce address for %s", __FUNCTION__, __LINE__, f->name);
list_for_each_entry(b, &f->backends, list) {
if (b->srcaddr && strcmp(b->srcaddr, "") != 0) {
@ -406,7 +406,7 @@ static int backend_set_mark(struct backend *b, int new_value)
if (new_value < BACKEND_MARK_MIN || new_value > BACKEND_MARK_MAX)
return 0;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
__FUNCTION__, __LINE__, old_value, new_value);
b->mark = new_value;
@ -418,7 +418,7 @@ static int backend_set_port(struct backend *b, char *new_value)
{
char *old_value = b->port;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
__FUNCTION__, __LINE__, old_value, new_value);
if (strcmp(b->port, DEFAULT_PORT) != 0)
@ -438,7 +438,7 @@ static int backend_set_srcaddr(struct backend *b, char *new_value)
{
char *old_value = b->srcaddr;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
__FUNCTION__, __LINE__, old_value, new_value);
if (b->srcaddr)
@ -460,25 +460,25 @@ static int backend_set_ifinfo(struct backend *b)
int if_index;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: backend %s set interface info", __FUNCTION__, __LINE__, b->name);
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s set interface info", __FUNCTION__, __LINE__, b->name);
if (!farm_is_ingress_mode(f) || (f->state != VALUE_STATE_UP && f->state != VALUE_STATE_CONFERR))
return 0;
if (f->oface && strcmp(f->oface, IFACE_LOOPBACK) == 0) {
tools_printlog(LOG_DEBUG, "%s():%d: backend %s in farm %s doesn't require output netinfo, loopback interface", __FUNCTION__, __LINE__, b->name, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s in farm %s doesn't require output netinfo, loopback interface", __FUNCTION__, __LINE__, b->name, f->name);
f->ofidx = 0;
return 0;
}
if (!b || b->ipaddr == DEFAULT_IPADDR) {
tools_printlog(LOG_ERR, "%s():%d: there is no backend yet in the farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_ERR, "%s():%d: there is no backend yet in the farm %s", __FUNCTION__, __LINE__, f->name);
return 0;
}
ret = net_get_local_ifidx_per_remote_host(b->ipaddr, &if_index);
if (ret == -1) {
tools_printlog(LOG_ERR, "%s():%d: unable to get the outbound interface to %s for the backend %s in farm %s", __FUNCTION__, __LINE__, b->ipaddr, b->name, f->name);
zcu_log_print(LOG_ERR, "%s():%d: unable to get the outbound interface to %s for the backend %s in farm %s", __FUNCTION__, __LINE__, b->ipaddr, b->name, f->name);
return -1;
}
@ -491,7 +491,7 @@ static int backend_set_ifinfo(struct backend *b)
}
if (if_indextoname(if_index, if_str) == NULL) {
tools_printlog(LOG_ERR, "%s():%d: unable to get the outbound interface name with index %d required by the backend %s in farm %s", __FUNCTION__, __LINE__, if_index, b->name, f->name);
zcu_log_print(LOG_ERR, "%s():%d: unable to get the outbound interface name with index %d required by the backend %s in farm %s", __FUNCTION__, __LINE__, if_index, b->name, f->name);
return -1;
}
@ -515,7 +515,7 @@ static int backend_set_ipaddr(struct backend *b, char *new_value)
char *old_value = b->ipaddr;
int netconfig;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %s, but new value will be %s",
__FUNCTION__, __LINE__, old_value, new_value);
if (b->ipaddr)
@ -541,7 +541,7 @@ static int backend_set_ipaddr(struct backend *b, char *new_value)
int backend_is_usable(struct backend *b)
{
tools_printlog(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d",
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d",
__FUNCTION__, __LINE__, b->name, obj_print_state(b->state), b->priority);
return ((b->state == VALUE_STATE_UP || b->state == VALUE_STATE_OFF) && backend_below_prio(b));
@ -562,7 +562,7 @@ int backend_changed(struct config_pair *c)
if (!f || !b)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s backend %s with param %d", __FUNCTION__, __LINE__, f->name, b->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s backend %s with param %d", __FUNCTION__, __LINE__, f->name, b->name, c->key);
switch (c->key) {
case KEY_NAME:
@ -618,7 +618,7 @@ int backend_validate(struct backend *b)
{
struct farm *f = b->parent;
tools_printlog(LOG_DEBUG, "%s():%d: validating backend %s of farm %s",
zcu_log_print(LOG_DEBUG, "%s():%d: validating backend %s of farm %s",
__FUNCTION__, __LINE__, b->name, f->name);
if (farm_is_ingress_mode(f) &&
@ -633,7 +633,7 @@ int backend_validate(struct backend *b)
int backend_is_available(struct backend *b)
{
tools_printlog(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d",
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s state is %s and priority %d",
__FUNCTION__, __LINE__, b->name, obj_print_state(b->state), b->priority);
return (backend_validate(b) && (b->state == VALUE_STATE_UP) && backend_below_prio(b));
@ -643,7 +643,7 @@ int backend_set_action(struct backend *b, int action)
{
int is_actionated = 0;
tools_printlog(LOG_DEBUG, "%s():%d: bck %s action %d state %d - new action %d",
zcu_log_print(LOG_DEBUG, "%s():%d: bck %s action %d state %d - new action %d",
__FUNCTION__, __LINE__, b->name, b->action, b->state, action);
if (action == ACTION_DELETE) {
@ -797,7 +797,7 @@ int backend_set_state(struct backend *b, int new_value)
int old_value = b->state;
struct farm *f = b->parent;
tools_printlog(LOG_DEBUG, "%s():%d: backend %s current value is %s, but new value will be %s",
zcu_log_print(LOG_DEBUG, "%s():%d: backend %s current value is %s, but new value will be %s",
__FUNCTION__, __LINE__, b->name, obj_print_state(old_value), obj_print_state(new_value));
if (new_value == VALUE_STATE_UP) {
@ -863,7 +863,7 @@ int backend_s_set_ether_by_ipaddr(struct farm *f, const char *ip_bck, char *ethe
if (strcmp(b->ipaddr, ip_bck) != 0)
continue;
tools_printlog(LOG_DEBUG, "%s():%d: backend with ip address %s found", __FUNCTION__, __LINE__, ip_bck);
zcu_log_print(LOG_DEBUG, "%s():%d: backend with ip address %s found", __FUNCTION__, __LINE__, ip_bck);
if (!b->ethaddr || (b->ethaddr && strcmp(b->ethaddr, ether_bck) != 0)) {
if (f->persistence != VALUE_META_NONE)
@ -879,7 +879,7 @@ int backend_s_set_ether_by_ipaddr(struct farm *f, const char *ip_bck, char *ethe
session_s_delete(f, SESSION_TYPE_TIMED);
}
tools_printlog(LOG_INFO, "%s():%d: ether address changed for backend %s with %s", __FUNCTION__, __LINE__, b->name, ether_bck);
zcu_log_print(LOG_INFO, "%s():%d: ether address changed for backend %s with %s", __FUNCTION__, __LINE__, b->name, ether_bck);
}
}
@ -900,7 +900,7 @@ int backend_s_set_netinfo(struct farm *f)
struct backend *b;
int changed = 0;
tools_printlog(LOG_DEBUG, "%s():%d: finding backends for %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: finding backends for %s", __FUNCTION__, __LINE__, f->name);
list_for_each_entry(b, &f->backends, list) {
if (backend_validate(b))
@ -927,7 +927,7 @@ int bck_pre_actionable(struct config_pair *c)
if (!f || !b)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable backend %s of farm %s with param %d", __FUNCTION__, __LINE__, b->name, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable backend %s of farm %s with param %d", __FUNCTION__, __LINE__, b->name, f->name, c->key);
// changing priority of a down backend could affect others, force a farm restart
if (b->state != VALUE_STATE_UP && b->state != VALUE_STATE_CONFERR && c->key == KEY_PRIORITY) {
@ -980,7 +980,7 @@ int bck_pos_actionable(struct config_pair *c, int action)
if (!f || !b)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable backend %s of farm %s with param %d action %d", __FUNCTION__, __LINE__, b->name, f->name, c->key, action);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable backend %s of farm %s with param %d action %d", __FUNCTION__, __LINE__, b->name, f->name, c->key, action);
switch (action) {
case ACTION_START:

View File

@ -36,7 +36,7 @@
#include "addresses.h"
#include "farmaddress.h"
#include "addresspolicy.h"
#include "tools.h"
#include "zcu_log.h"
#define CONFIG_MAXBUF 4096
#define CONFIG_OUTBUF_SIZE 1024
@ -77,7 +77,7 @@ static int config_value_family(const char *value)
return VALUE_FAMILY_INET;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_FAMILY, CONFIG_VALUE_FAMILY_IPV4);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_FAMILY, CONFIG_VALUE_FAMILY_IPV4);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_FAMILY, CONFIG_VALUE_FAMILY_IPV4);
return VALUE_FAMILY_IPV4;
}
@ -95,7 +95,7 @@ static int config_value_mode(const char *value)
return VALUE_MODE_LOCAL;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_MODE, CONFIG_VALUE_MODE_SNAT);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_MODE, CONFIG_VALUE_MODE_SNAT);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_MODE, CONFIG_VALUE_MODE_SNAT);
return VALUE_MODE_SNAT;
}
@ -111,7 +111,7 @@ static int config_value_proto(const char *value)
return VALUE_PROTO_ALL;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_PROTO, CONFIG_VALUE_PROTO_TCP);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_PROTO, CONFIG_VALUE_PROTO_TCP);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_PROTO, CONFIG_VALUE_PROTO_TCP);
return VALUE_PROTO_TCP;
}
@ -127,7 +127,7 @@ static int config_value_sched(const char *value)
return VALUE_SCHED_SYMHASH;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_SCHED, CONFIG_VALUE_SCHED_RR);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_SCHED, CONFIG_VALUE_SCHED_RR);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_SCHED, CONFIG_VALUE_SCHED_RR);
return VALUE_SCHED_RR;
}
@ -155,7 +155,7 @@ static int config_value_meta(const char *value)
if (mask == 0) {
config_set_output(". Parsing unknown value '%s', using default '%s'", value, CONFIG_VALUE_META_NONE);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_VALUE_META_NONE);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_VALUE_META_NONE);
}
return mask;
@ -177,7 +177,7 @@ static int config_value_helper(const char *value)
return VALUE_HELPER_TFTP;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_HELPER, CONFIG_VALUE_HELPER_NONE);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_HELPER, CONFIG_VALUE_HELPER_NONE);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_HELPER, CONFIG_VALUE_HELPER_NONE);
return VALUE_HELPER_NONE;
}
@ -199,7 +199,7 @@ static int config_value_log(const char *value)
if (logmask == 0) {
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_LOG, CONFIG_VALUE_LOG_NONE);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_LOG, CONFIG_VALUE_LOG_NONE);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_LOG, CONFIG_VALUE_LOG_NONE);
}
return logmask;
@ -213,7 +213,7 @@ static int config_value_switch(const char *value)
return VALUE_SWITCH_OFF;
config_set_output(". Parsing unknown value '%s', using default '%s'", value, CONFIG_VALUE_SWITCH_OFF);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_VALUE_SWITCH_OFF);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_VALUE_SWITCH_OFF);
return VALUE_SWITCH_OFF;
}
@ -229,7 +229,7 @@ static int config_value_state(const char *value)
return VALUE_STATE_CONFERR;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_STATE, CONFIG_VALUE_STATE_UP);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_STATE, CONFIG_VALUE_STATE_UP);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_STATE, CONFIG_VALUE_STATE_UP);
return VALUE_STATE_UP;
}
@ -257,7 +257,7 @@ static int config_value_type(const char *value)
return VALUE_TYPE_ALLOW;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_TYPE, CONFIG_VALUE_POLICIES_TYPE_BL);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_TYPE, CONFIG_VALUE_POLICIES_TYPE_BL);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_TYPE, CONFIG_VALUE_POLICIES_TYPE_BL);
return VALUE_TYPE_DENY;
}
@ -274,7 +274,7 @@ static int config_value_verdict(const char *value)
if (verdictmask == VALUE_VERDICT_NONE) {
config_set_output(". Parsing unknown value '%s' in '%s'", value, CONFIG_KEY_VERDICT);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_VERDICT);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_VERDICT);
return VALUE_VERDICT_NONE;
}
@ -289,7 +289,7 @@ static int config_value_route(const char *value)
return VALUE_ROUTE_OUT;
config_set_output(". Parsing unknown value '%s' in '%s', using default '%s'", value, CONFIG_KEY_ROUTE, CONFIG_VALUE_ROUTE_IN);
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_ROUTE, CONFIG_VALUE_ROUTE_IN);
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s', using default '%s'", __FUNCTION__, __LINE__, value, CONFIG_KEY_ROUTE, CONFIG_VALUE_ROUTE_IN);
return VALUE_ROUTE_IN;
}
@ -313,7 +313,7 @@ static int config_value_ratelimit(int key, int *int_value, int *int_unit, const
*int_unit = VALUE_UNIT_WEEK;
else {
config_set_output(". Parsing unknown value '%s' in '%s'", value, obj_print_key(key));
tools_printlog(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s'", __FUNCTION__, __LINE__, value, obj_print_key(key));
zcu_log_print(LOG_ERR, "%s():%d: parsing unknown value '%s' in '%s'", __FUNCTION__, __LINE__, value, obj_print_key(key));
return PARSER_VALID_FAILED;
}
@ -372,7 +372,7 @@ static int config_value(const char *value)
break;
}
config_set_output(". Invalid value of key '%s' must be >=1", obj_print_key(c.key));
tools_printlog(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=1", __FUNCTION__, __LINE__, obj_print_key(c.key));
zcu_log_print(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=1", __FUNCTION__, __LINE__, obj_print_key(c.key));
break;
case KEY_RESPONSETTL:
case KEY_PERSISTTM:
@ -388,7 +388,7 @@ static int config_value(const char *value)
break;
}
config_set_output(". Invalid value of key '%s' must be >=0", obj_print_key(c.key));
tools_printlog(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=0", __FUNCTION__, __LINE__, obj_print_key(c.key));
zcu_log_print(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=0", __FUNCTION__, __LINE__, obj_print_key(c.key));
break;
case KEY_NEWRTLIMIT:
case KEY_RSTRTLIMIT:
@ -403,7 +403,7 @@ static int config_value(const char *value)
break;
}
config_set_output(". Invalid value of key '%s' must be >=-1", obj_print_key(c.key));
tools_printlog(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=-1", __FUNCTION__, __LINE__, obj_print_key(c.key));
zcu_log_print(LOG_ERR, "%s():%d: invalid value of key '%s' must be >=-1", __FUNCTION__, __LINE__, obj_print_key(c.key));
break;
case KEY_ACTION:
c.int_value = config_value_action(value);
@ -431,7 +431,7 @@ static int config_value(const char *value)
case KEY_DATA:
if (strcmp(value, "") == 0) {
config_set_output(". Key '%s' cannot be empty", obj_print_key(c.key));
tools_printlog(LOG_ERR, "%s():%d: key '%s' cannot be empty", __FUNCTION__, __LINE__, obj_print_key(c.key));
zcu_log_print(LOG_ERR, "%s():%d: key '%s' cannot be empty", __FUNCTION__, __LINE__, obj_print_key(c.key));
break;
}
/* fallthrough */
@ -462,7 +462,7 @@ static int config_value(const char *value)
break;
default:
config_set_output(". Unknown parsed key with index '%d'", c.key);
tools_printlog(LOG_ERR, "%s():%d: unknown parsed key with index '%d'", __FUNCTION__, __LINE__, c.key);
zcu_log_print(LOG_ERR, "%s():%d: unknown parsed key with index '%d'", __FUNCTION__, __LINE__, c.key);
ret = PARSER_OBJ_UNKNOWN;
break;
}
@ -598,7 +598,7 @@ static int config_key(const char *key)
return KEY_COUNTER_BYTES;
config_set_output(". Unknown key '%s'", key);
tools_printlog(LOG_ERR, "%s():%d: unknown key '%s'", __FUNCTION__, __LINE__, key);
zcu_log_print(LOG_ERR, "%s():%d: unknown key '%s'", __FUNCTION__, __LINE__, key);
return -1;
}
@ -633,7 +633,7 @@ static int config_json_object(json_t *element, int level, int source, int apply_
if (jump_config_value(level, c.key) == 0) {
ret = config_json(value, level, source, c.key, apply_action);
if (ret) {
tools_printlog(LOG_ERR, "%s():%d: error parsing object in level %d", __FUNCTION__, __LINE__, c.level);
zcu_log_print(LOG_ERR, "%s():%d: error parsing object in level %d", __FUNCTION__, __LINE__, c.level);
return ret;
}
}
@ -667,7 +667,7 @@ static int config_json_string(json_t *element, int level, int source, int apply_
if (ret != PARSER_OK)
return ret;
tools_printlog(LOG_DEBUG, "%s():%d: %d(level) %d(key) %s(value) %d(value) %d(value2) apply_action %d", __FUNCTION__, __LINE__, c.level, c.key, c.str_value, c.int_value, c.int_value2, apply_action);
zcu_log_print(LOG_DEBUG, "%s():%d: %d(level) %d(key) %s(value) %d(value) %d(value2) apply_action %d", __FUNCTION__, __LINE__, c.level, c.key, c.str_value, c.int_value, c.int_value2, apply_action);
ret = obj_set_attribute(&c, source, apply_action);
init_pair(&c);
@ -679,7 +679,7 @@ static int config_json(json_t *element, int level, int source, int key, int appl
{
int ret = PARSER_OK;
tools_printlog(LOG_DEBUG, "%s():%d: %d(level) %d(source)", __FUNCTION__, __LINE__, level, source);
zcu_log_print(LOG_DEBUG, "%s():%d: %d(level) %d(source)", __FUNCTION__, __LINE__, level, source);
switch (json_typeof(element)) {
case JSON_OBJECT:
@ -722,7 +722,7 @@ static int config_json(json_t *element, int level, int source, int key, int appl
break;
default:
tools_printlog(LOG_ERR, "Configuration file unknown element type %d", json_typeof(element));
zcu_log_print(LOG_ERR, "Configuration file unknown element type %d", json_typeof(element));
}
return ret;
@ -745,7 +745,7 @@ int config_file(const char *file)
fd = fopen(file, "r");
if (fd == NULL) {
tools_printlog(LOG_ERR, "Error open configuration file %s", file);
zcu_log_print(LOG_ERR, "Error open configuration file %s", file);
return PARSER_FAILED;
}
@ -755,7 +755,7 @@ int config_file(const char *file)
ret = config_json(root, LEVEL_INIT, CONFIG_SRC_FILE, -1, ACTION_START);
json_decref(root);
} else {
tools_printlog(LOG_ERR, "Configuration file error '%s' on line %d: %s", file, error.line, error.text);
zcu_log_print(LOG_ERR, "Configuration file error '%s' on line %d: %s", file, error.line, error.text);
ret = PARSER_STRUCT_FAILED;
}
@ -791,7 +791,7 @@ int config_buffer(const char *buf, int apply_action)
json_t *root;
int ret = PARSER_OK;
tools_printlog(LOG_NOTICE, "%s():%d: payload %d : %s", __FUNCTION__, __LINE__, (int)strlen(buf), buf);
zcu_log_print(LOG_NOTICE, "%s():%d: payload %d : %s", __FUNCTION__, __LINE__, (int)strlen(buf), buf);
root = json_loadb(buf, strlen(buf), JSON_ALLOW_NUL, &error);
@ -799,7 +799,7 @@ int config_buffer(const char *buf, int apply_action)
ret = config_json(root, LEVEL_INIT, CONFIG_SRC_BUFFER, -1, apply_action);
json_decref(root);
} else {
tools_printlog(LOG_ERR, "Configuration error on line %d: %s", error.line, error.text);
zcu_log_print(LOG_ERR, "Configuration error on line %d: %s", error.line, error.text);
ret = PARSER_STRUCT_FAILED;
}

View File

@ -26,14 +26,15 @@
#include "elements.h"
#include "policies.h"
#include "objects.h"
#include "tools.h"
#include "nft.h"
#include "zcu_string.h"
#include "zcu_log.h"
static struct element * element_create(struct policy *p, char *data, char *time, char *counter_pkts, char *counter_bytes)
{
struct element *e = (struct element *)malloc(sizeof(struct element));
if (!e) {
tools_printlog(LOG_ERR, "element memory allocation error");
zcu_log_print(LOG_ERR, "element memory allocation error");
return NULL;
}
@ -107,21 +108,21 @@ new_element:
fin_ptr = fin1_ptr;
}
tools_snprintf(elem_addr, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_addr, fin_ptr - ini_ptr, ini_ptr);
fin_ptr += 1;
ini_ptr = fin_ptr;
if ((fin_ptr = strstr(ini_ptr, " bytes ")) != NULL) {
ini_ptr += 16;
tools_snprintf(elem_pkts, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_pkts, fin_ptr - ini_ptr, ini_ptr);
ini_ptr += 8;
if ((fin_ptr = strstr(ini_ptr, ",")) != NULL || (fin_ptr = strstr(ini_ptr, " ")) != NULL) {
tools_snprintf(elem_bytes, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_bytes, fin_ptr - ini_ptr, ini_ptr);
ini_ptr = ++fin_ptr;
}
} else {
tools_snprintf(elem_pkts, 3, DEFAULT_COUNTER);
tools_snprintf(elem_bytes, 3, DEFAULT_COUNTER);
zcu_str_snprintf(elem_pkts, 3, DEFAULT_COUNTER);
zcu_str_snprintf(elem_bytes, 3, DEFAULT_COUNTER);
fin_ptr = ini_ptr;
}
@ -146,13 +147,13 @@ void element_s_print(struct policy *p)
struct element *e;
list_for_each_entry(e, &p->elements, list) {
tools_printlog(LOG_DEBUG," [element] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_DATA, e->data);
zcu_log_print(LOG_DEBUG," [element] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_DATA, e->data);
if (p->timeout && e->time && strcmp(e->time, "") != 0)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_TIME, e->time);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_COUNTER_PACKETS, e->counter_pkts);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_COUNTER_BYTES, e->counter_bytes);
tools_printlog(LOG_DEBUG," *[action] %d", e->action);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_TIME, e->time);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_COUNTER_PACKETS, e->counter_pkts);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_COUNTER_BYTES, e->counter_bytes);
zcu_log_print(LOG_DEBUG," *[action] %d", e->action);
}
}
@ -170,7 +171,7 @@ struct element * element_lookup_by_name(struct policy *p, const char *data)
int element_set_action(struct element *e, int action)
{
tools_printlog(LOG_DEBUG, "%s():%d: element %s action is %d - new action %d", __FUNCTION__, __LINE__, e->data, e->action, action);
zcu_log_print(LOG_DEBUG, "%s():%d: element %s action is %d - new action %d", __FUNCTION__, __LINE__, e->data, e->action, action);
if (action == ACTION_DELETE) {
element_delete(e);
@ -250,7 +251,7 @@ int element_pos_actionable(struct config_pair *c, int apply_action)
if (!p || !e)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable element %s of policy %s with param %d", __FUNCTION__, __LINE__, e->data, p->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable element %s of policy %s with param %d", __FUNCTION__, __LINE__, e->data, p->name, c->key);
switch (c->key) {
case KEY_DATA:
@ -272,7 +273,7 @@ int element_get_list(struct policy *p)
const char *buf;
struct nftst *n = nftst_create_from_policy(p);
tools_printlog(LOG_DEBUG, "%s():%d: policy %s", __FUNCTION__, __LINE__, p->name);
zcu_log_print(LOG_DEBUG, "%s():%d: policy %s", __FUNCTION__, __LINE__, p->name);
nft_get_rules_buffer(&buf, KEY_POLICIES, n);
p->total_elem = 0;

View File

@ -28,14 +28,13 @@
#include "farms.h"
#include "objects.h"
#include "network.h"
#include "tools.h"
#include "zcu_log.h"
static struct farmaddress * farmaddress_create(struct farm *f, struct address *a)
{
struct farmaddress *fa = (struct farmaddress *)malloc(sizeof(struct farmaddress));
if (!fa) {
tools_printlog(LOG_ERR, "Farm address memory allocation error");
zcu_log_print(LOG_ERR, "Farm address memory allocation error");
return NULL;
}
@ -82,27 +81,27 @@ void farmaddress_s_print(struct farm *f)
list_for_each_entry(fa, &f->addresses, list) {
a = fa->address;
tools_printlog(LOG_DEBUG," [address] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, fa->address->name);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, fa->action);
zcu_log_print(LOG_DEBUG," [address] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, fa->address->name);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, fa->action);
if (a->iface)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
if (a->iethaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
tools_printlog(LOG_DEBUG," *[ifidx] %d", a->ifidx);
zcu_log_print(LOG_DEBUG," *[ifidx] %d", a->ifidx);
if (a->ipaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, a->ipaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IPADDR, a->ipaddr);
if (a->ports)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORTS, a->ports);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PORTS, a->ports);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
tools_printlog(LOG_DEBUG," *[policies_action] %d", a->policies_action);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
zcu_log_print(LOG_DEBUG," *[policies_action] %d", a->policies_action);
}
}
@ -121,7 +120,7 @@ struct farmaddress * farmaddress_lookup_by_name(struct farm *f, const char *name
int farmaddress_set_action(struct farmaddress *fa, int action)
{
struct farm *f = fa->farm;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s address %s action %d", __FUNCTION__, __LINE__, fa->farm->name, fa->address->ipaddr, action);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s address %s action %d", __FUNCTION__, __LINE__, fa->farm->name, fa->address->ipaddr, action);
if (action == ACTION_DELETE) {
farmaddress_delete(fa);
@ -146,7 +145,7 @@ int farmaddress_s_set_action(struct farm *f, int action)
{
struct farmaddress *fa, *next;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
list_for_each_entry_safe(fa, next, &f->addresses, list)
if (fa->action > action)
@ -210,7 +209,7 @@ int farmaddress_create_default(struct config_pair *c)
if (!f)
return 1;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
fa = farmaddress_get_first(f);
if (fa) {
@ -239,7 +238,7 @@ int farmaddress_set_attribute(struct config_pair *c)
struct address *a;
if (!f) {
tools_printlog(LOG_INFO, "%s():%d: farm UNKNOWN", __FUNCTION__, __LINE__);
zcu_log_print(LOG_INFO, "%s():%d: farm UNKNOWN", __FUNCTION__, __LINE__);
return PARSER_OBJ_UNKNOWN;
}
@ -273,7 +272,7 @@ int farmaddress_pre_actionable(struct config_pair *c)
if (!f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable farm address for farm %s action %d", __FUNCTION__, __LINE__, f->name, f->action);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable farm address for farm %s action %d", __FUNCTION__, __LINE__, f->name, f->action);
return farm_set_action(f, ACTION_RELOAD);
}
@ -286,7 +285,7 @@ int farmaddress_pos_actionable(struct config_pair *c)
if (!fa || !f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable farm address %s for farm %s with param %d", __FUNCTION__, __LINE__, fa->address->name, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable farm address %s for farm %s with param %d", __FUNCTION__, __LINE__, fa->address->name, f->name, c->key);
return farm_set_action(f, ACTION_RELOAD);
}
@ -296,7 +295,7 @@ int farmaddress_s_validate_iface(struct farm *f)
struct farmaddress *fa;
int anyvalid = 0;
tools_printlog(LOG_DEBUG, "%s():%d: validating input farm addresses interface of %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating input farm addresses interface of %s", __FUNCTION__, __LINE__, f->name);
list_for_each_entry(fa, &f->addresses, list) {
if (address_validate_iface(fa->address) || address_validate_iether(fa->address)) {
@ -313,7 +312,7 @@ int farmaddress_s_validate_helper(struct farm *f, int new_value)
{
struct farmaddress *fa;
tools_printlog(LOG_DEBUG, "%s():%d: validating input farm address proto for new helper of %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating input farm address proto for new helper of %s", __FUNCTION__, __LINE__, f->name);
if (new_value == VALUE_HELPER_NONE)
return PARSER_OK;

View File

@ -28,14 +28,14 @@
#include "farmaddress.h"
#include "objects.h"
#include "network.h"
#include "tools.h"
#include "zcu_log.h"
static struct farmpolicy * farmpolicy_create(struct farm *f, struct policy *p)
{
struct farmpolicy *fp = (struct farmpolicy *)malloc(sizeof(struct farmpolicy));
if (!fp) {
tools_printlog(LOG_ERR, "Farm Policy memory allocation error");
zcu_log_print(LOG_ERR, "Farm Policy memory allocation error");
return NULL;
}
@ -78,9 +78,9 @@ void farmpolicy_s_print(struct farm *f)
struct farmpolicy *fp;
list_for_each_entry(fp, &f->policies, list) {
tools_printlog(LOG_DEBUG," [policy] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, fp->policy->name);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, fp->action);
zcu_log_print(LOG_DEBUG," [policy] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, fp->policy->name);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, fp->action);
}
}
@ -100,7 +100,7 @@ int farmpolicy_set_action(struct farmpolicy *fp, int action)
{
struct farm *f = fp->farm;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s action %d", __FUNCTION__, __LINE__, fp->farm->name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s action %d", __FUNCTION__, __LINE__, fp->farm->name, action);
if (action == ACTION_DELETE) {
farmpolicy_delete(fp);
@ -127,7 +127,7 @@ int farmpolicy_s_set_action(struct farm *f, int action)
{
struct farmpolicy *fp, *next;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s action %d", __FUNCTION__, __LINE__, f->name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s action %d", __FUNCTION__, __LINE__, f->name, action);
list_for_each_entry_safe(fp, next, &f->policies, list)
farmpolicy_set_action(fp, action);
@ -152,7 +152,7 @@ int farmpolicy_s_lookup_policy_action(struct farm *f, char *name, int action)
struct farmpolicy *fp;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: looking for policy %s in farm %s", __FUNCTION__, __LINE__, name, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: looking for policy %s in farm %s", __FUNCTION__, __LINE__, name, f->name);
fp = farmpolicy_lookup_by_name(f, name);
if (fp)
@ -202,7 +202,7 @@ int farmpolicy_pre_actionable(struct config_pair *c)
if (!f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable farm policy for farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable farm policy for farm %s", __FUNCTION__, __LINE__, f->name);
farm_set_action(f, ACTION_RELOAD);
farmaddress_s_set_action(f, ACTION_RELOAD);
@ -219,7 +219,7 @@ int farmpolicy_pos_actionable(struct config_pair *c)
if (!fp || !f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable farm policy %s for farm %s with param %d", __FUNCTION__, __LINE__, fp->policy->name, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable farm policy %s for farm %s with param %d", __FUNCTION__, __LINE__, fp->policy->name, f->name, c->key);
farm_set_action(f, ACTION_RELOAD);
farmaddress_s_set_action(f, ACTION_RELOAD);

View File

@ -33,9 +33,8 @@
#include "config.h"
#include "nft.h"
#include "network.h"
#include "tools.h"
#include "nftst.h"
#include "zcu_log.h"
static struct farm * farm_create(char *name)
{
@ -43,7 +42,7 @@ static struct farm * farm_create(char *name)
struct farm *pfarm = (struct farm *)malloc(sizeof(struct farm));
if (!pfarm) {
tools_printlog(LOG_ERR, "Farm memory allocation error");
zcu_log_print(LOG_ERR, "Farm memory allocation error");
return NULL;
}
@ -122,7 +121,7 @@ static int farm_delete(struct farm *pfarm)
if (!pfarm)
return 0;
tools_printlog(LOG_DEBUG, "%s():%d: deleting farm %s", __FUNCTION__, __LINE__, pfarm->name);
zcu_log_print(LOG_DEBUG, "%s():%d: deleting farm %s", __FUNCTION__, __LINE__, pfarm->name);
backend_s_delete(pfarm);
farmpolicy_s_delete(pfarm);
@ -156,7 +155,7 @@ static int farm_delete(struct farm *pfarm)
static int farm_validate_oface(struct farm *f)
{
tools_printlog(LOG_DEBUG, "%s():%d: validating output farm interface of %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating output farm interface of %s", __FUNCTION__, __LINE__, f->name);
if (!f->oface || obj_equ_attribute_string(f->oface, "") ||
!f->oethaddr || obj_equ_attribute_string(f->oethaddr, ""))
@ -194,23 +193,23 @@ static int farm_validate_helper_protocol(struct farm *f)
static int farm_validate(struct farm *f)
{
tools_printlog(LOG_DEBUG, "%s():%d: validating farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: validating farm %s", __FUNCTION__, __LINE__, f->name);
if (!farm_validate_helper_protocol(f)) {
tools_printlog(LOG_WARNING, "Farm %s doesn't validate helper protocol", f->name);
zcu_log_print(LOG_WARNING, "Farm %s doesn't validate helper protocol", f->name);
config_set_output(". Farm '%s' doesn't validate helper protocol", f->name);
return 0;
}
if (farm_needs_policies(f) && !farmaddress_s_validate_iface(f)) {
tools_printlog(LOG_WARNING, "Farm %s doesn't validate policy and input interface", f->name);
zcu_log_print(LOG_WARNING, "Farm %s doesn't validate policy and input interface", f->name);
return 0;
}
if ((farm_is_ingress_mode(f) || farm_needs_flowtable(f)) &&
(!farmaddress_s_validate_iface(f) ||
!farm_validate_oface(f))) {
tools_printlog(LOG_WARNING, "Farm %s doesn't validate ingress mode or flowtable and interfaces", f->name);
zcu_log_print(LOG_WARNING, "Farm %s doesn't validate ingress mode or flowtable and interfaces", f->name);
return 0;
}
@ -219,7 +218,7 @@ static int farm_validate(struct farm *f)
int farm_is_available(struct farm *f)
{
tools_printlog(LOG_DEBUG, "%s():%d: farm %s state is %s",
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s state is %s",
__FUNCTION__, __LINE__, f->name, obj_print_state(f->state));
return (f->state == VALUE_STATE_UP) && farm_validate(f);
@ -232,7 +231,7 @@ static int farm_s_update_dsr_counter(void)
int dsrcount = 0;
int curcount = obj_get_dsr_counter();
tools_printlog(LOG_DEBUG, "%s():%d: updating dsr counter", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: updating dsr counter", __FUNCTION__, __LINE__);
list_for_each_entry(f, farms, list) {
if (farm_is_ingress_mode(f) && (f->state == VALUE_STATE_UP || f->state == VALUE_STATE_CONFERR))
@ -240,7 +239,7 @@ static int farm_s_update_dsr_counter(void)
}
if (dsrcount != curcount)
tools_printlog(LOG_DEBUG, "%s():%d: farm dsr counter becomes %d", __FUNCTION__, __LINE__, dsrcount);
zcu_log_print(LOG_DEBUG, "%s():%d: farm dsr counter becomes %d", __FUNCTION__, __LINE__, dsrcount);
obj_set_dsr_counter(dsrcount);
@ -278,10 +277,10 @@ int farm_needs_intraconnect(struct farm *f)
static int farm_set_netinfo(struct farm *f)
{
tools_printlog(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
if (f->state != VALUE_STATE_UP) {
tools_printlog(LOG_INFO, "%s():%d: farm %s doesn't require low level network info", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_INFO, "%s():%d: farm %s doesn't require low level network info", __FUNCTION__, __LINE__, f->name);
return -1;
}
@ -306,15 +305,15 @@ static int farm_set_mark(struct farm *f, int new_value)
{
int old_value = f->mark;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old mark %d new mark %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old mark %d new mark %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
if (f->mode != VALUE_MODE_DNAT && f->mode != VALUE_MODE_SNAT && f->mode != VALUE_MODE_LOCAL) {
tools_printlog(LOG_INFO, "%s():%d: mark for farm %s not available for the current mode %d", __FUNCTION__, __LINE__, f->name, f->mode);
zcu_log_print(LOG_INFO, "%s():%d: mark for farm %s not available for the current mode %d", __FUNCTION__, __LINE__, f->name, f->mode);
return 0;
}
if (new_value & masquerade_mark) {
tools_printlog(LOG_ERR, "%s():%d: mark 0x%x for farm %s conflicts with the POSTROUTING mark 0x%x", __FUNCTION__, __LINE__, f->mark, f->name, masquerade_mark);
zcu_log_print(LOG_ERR, "%s():%d: mark 0x%x for farm %s conflicts with the POSTROUTING mark 0x%x", __FUNCTION__, __LINE__, f->mark, f->name, masquerade_mark);
return 0;
}
@ -327,7 +326,7 @@ static int farm_set_state(struct farm *f, int new_value)
{
int old_value = f->state;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old state %d new state %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old state %d new state %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
// farm doesn't allow 'available' state
if (new_value == VALUE_STATE_AVAIL)
@ -362,7 +361,7 @@ static int farm_set_mode(struct farm *f, int new_value)
{
int old_value = f->mode;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old mode %d new mode %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old mode %d new mode %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
if (old_value != new_value) {
f->mode = new_value;
@ -377,7 +376,7 @@ static int farm_set_sched(struct farm *f, int new_value)
{
int old_value = f->scheduler;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old scheduler %d new scheduler %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old scheduler %d new scheduler %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
f->scheduler = new_value;
@ -396,7 +395,7 @@ static int farm_set_persistence(struct farm *f, int new_value)
{
int old_value = f->persistence;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old persistence %d new persistence %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old persistence %d new persistence %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
session_s_delete(f, SESSION_TYPE_STATIC);
@ -409,7 +408,7 @@ static int farm_set_verdict(struct farm *f, int new_value)
{
int old_value = f->verdict;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s old verdict %d new verdict %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s old verdict %d new verdict %d", __FUNCTION__, __LINE__, f->name, old_value, new_value);
if (new_value == VALUE_VERDICT_NONE)
return 1;
@ -430,114 +429,114 @@ static void farm_print(struct farm *f)
if (fa)
a = fa->address;
tools_printlog(LOG_DEBUG," [farm] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, f->name);
zcu_log_print(LOG_DEBUG," [farm] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, f->name);
if (f->fqdn)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, f->fqdn);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FQDN, f->fqdn);
if (f->oface)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_OFACE, f->oface);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_OFACE, f->oface);
if (f->oethaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_OETHADDR, f->oethaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_OETHADDR, f->oethaddr);
tools_printlog(LOG_DEBUG," *[ofidx] %d", f->ofidx);
zcu_log_print(LOG_DEBUG," *[ofidx] %d", f->ofidx);
if (a) {
if (a->iface)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IFACE, a->iface);
if (a->iethaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_IETHADDR, a->iethaddr);
tools_printlog(LOG_DEBUG," *[ifidx] %d", a->ifidx);
zcu_log_print(LOG_DEBUG," *[ifidx] %d", a->ifidx);
if (a->ipaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_VIRTADDR, a->ipaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_VIRTADDR, a->ipaddr);
if (a->ports)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_VIRTPORTS, a->ports);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_VIRTPORTS, a->ports);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(a->family));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PROTO, obj_print_proto(a->protocol));
}
if (f->srcaddr)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_SRCADDR, f->srcaddr);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_SRCADDR, f->srcaddr);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_MODE, obj_print_mode(f->mode));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_MODE, obj_print_mode(f->mode));
if (f->mode == VALUE_MODE_STLSDNAT)
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_RESPONSETTL, f->responsettl);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_RESPONSETTL, f->responsettl);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_SCHED, obj_print_sched(f->scheduler));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_SCHED, obj_print_sched(f->scheduler));
obj_print_meta(f->schedparam, (char *)buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_SCHEDPARAM, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_SCHEDPARAM, buf);
obj_print_meta(f->persistence, (char *)buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_PERSIST, buf);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_PERSISTTM, f->persistttl);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_PERSIST, buf);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_PERSISTTM, f->persistttl);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_HELPER, obj_print_helper(f->helper));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_HELPER, obj_print_helper(f->helper));
obj_print_log(f->log, (char *)buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG, buf);
if (f->logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, f->logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, f->logprefix);
obj_print_rtlimit(buf, f->logrtlimit, f->logrtlimit_unit);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG_RTLIMIT, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOG_RTLIMIT, buf);
tools_printlog(LOG_DEBUG," [%s] 0x%x", CONFIG_KEY_MARK, f->mark);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_STATE, obj_print_state(f->state));
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_PRIORITY, f->priority);
zcu_log_print(LOG_DEBUG," [%s] 0x%x", CONFIG_KEY_MARK, f->mark);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_STATE, obj_print_state(f->state));
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_PRIORITY, f->priority);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_LIMITSTTL, f->limitsttl);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_LIMITSTTL, f->limitsttl);
obj_print_rtlimit(buf, f->newrtlimit, f->newrtlimit_unit);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NEWRTLIMIT, buf);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_NEWRTLIMITBURST, f->newrtlimitbst);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NEWRTLIMIT, buf);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_NEWRTLIMITBURST, f->newrtlimitbst);
if (f->newrtlimit_logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NEWRTLIMIT_LOGPREFIX, f->newrtlimit_logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NEWRTLIMIT_LOGPREFIX, f->newrtlimit_logprefix);
obj_print_rtlimit(buf, f->rstrtlimit, f->rstrtlimit_unit);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_RSTRTLIMIT, buf);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_RSTRTLIMITBURST, f->rstrtlimitbst);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_RSTRTLIMIT, buf);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_RSTRTLIMITBURST, f->rstrtlimitbst);
if (f->rstrtlimit_logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_RSTRTLIMIT_LOGPREFIX, f->rstrtlimit_logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_RSTRTLIMIT_LOGPREFIX, f->rstrtlimit_logprefix);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_ESTCONNLIMIT, f->estconnlimit);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_ESTCONNLIMIT, f->estconnlimit);
if (f->estconnlimit_logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_ESTCONNLIMIT_LOGPREFIX, f->estconnlimit_logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_ESTCONNLIMIT_LOGPREFIX, f->estconnlimit_logprefix);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_TCPSTRICT, obj_print_switch(f->tcpstrict));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_TCPSTRICT, obj_print_switch(f->tcpstrict));
if (f->tcpstrict_logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_TCPSTRICT_LOGPREFIX, f->tcpstrict_logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_TCPSTRICT_LOGPREFIX, f->tcpstrict_logprefix);
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_QUEUE, f->queue);
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_QUEUE, f->queue);
obj_print_verdict(f->verdict, (char *)buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_VERDICT, buf);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_VERDICT, buf);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FLOWOFFLOAD, obj_print_switch(f->flow_offload));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_INTRACONNECT, obj_print_switch(f->intra_connect));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FLOWOFFLOAD, obj_print_switch(f->flow_offload));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_INTRACONNECT, obj_print_switch(f->intra_connect));
tools_printlog(LOG_DEBUG," *[total_weight] %d", f->total_weight);
tools_printlog(LOG_DEBUG," *[total_bcks] %d", f->total_bcks);
tools_printlog(LOG_DEBUG," *[bcks_available] %d", f->bcks_available);
tools_printlog(LOG_DEBUG," *[bcks_usable] %d", f->bcks_usable);
tools_printlog(LOG_DEBUG," *[bcks_have_port] %d", f->bcks_have_port);
tools_printlog(LOG_DEBUG," *[bcks_have_srcaddr] %d", f->bcks_have_srcaddr);
tools_printlog(LOG_DEBUG," *[bcks_have_if] %d", f->bcks_have_if);
tools_printlog(LOG_DEBUG," *[policies_action] %d", f->policies_action);
tools_printlog(LOG_DEBUG," *[policies_used] %d", f->policies_used);
tools_printlog(LOG_DEBUG," *[total_static_sessions] %d", f->total_static_sessions);
tools_printlog(LOG_DEBUG," *[total_timed_sessions] %d", f->total_timed_sessions);
tools_printlog(LOG_DEBUG," *[nft_chains] %x", f->nft_chains);
tools_printlog(LOG_DEBUG," *[addresses_used] %d", f->addresses_used);
tools_printlog(LOG_DEBUG," *[reload_action] %x", f->reload_action);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, f->action);
zcu_log_print(LOG_DEBUG," *[total_weight] %d", f->total_weight);
zcu_log_print(LOG_DEBUG," *[total_bcks] %d", f->total_bcks);
zcu_log_print(LOG_DEBUG," *[bcks_available] %d", f->bcks_available);
zcu_log_print(LOG_DEBUG," *[bcks_usable] %d", f->bcks_usable);
zcu_log_print(LOG_DEBUG," *[bcks_have_port] %d", f->bcks_have_port);
zcu_log_print(LOG_DEBUG," *[bcks_have_srcaddr] %d", f->bcks_have_srcaddr);
zcu_log_print(LOG_DEBUG," *[bcks_have_if] %d", f->bcks_have_if);
zcu_log_print(LOG_DEBUG," *[policies_action] %d", f->policies_action);
zcu_log_print(LOG_DEBUG," *[policies_used] %d", f->policies_used);
zcu_log_print(LOG_DEBUG," *[total_static_sessions] %d", f->total_static_sessions);
zcu_log_print(LOG_DEBUG," *[total_timed_sessions] %d", f->total_timed_sessions);
zcu_log_print(LOG_DEBUG," *[nft_chains] %x", f->nft_chains);
zcu_log_print(LOG_DEBUG," *[addresses_used] %d", f->addresses_used);
zcu_log_print(LOG_DEBUG," *[reload_action] %x", f->reload_action);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, f->action);
if (f->addresses_used > 0)
farmaddress_s_print(f);
@ -671,7 +670,7 @@ int farm_changed(struct config_pair *c)
if (!fa)
fa = farmaddress_get_first(f);
tools_printlog(LOG_DEBUG, "%s():%d: farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
switch (c->key) {
case KEY_NAME:
@ -820,7 +819,7 @@ int farm_actionable(struct config_pair *c)
if (!f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
switch (c->key) {
case KEY_NEWRTLIMIT:
@ -849,7 +848,7 @@ int farm_set_priority(struct farm *f, int new_value)
{
int old_value = f->priority;
tools_printlog(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
zcu_log_print(LOG_DEBUG, "%s():%d: current value is %d, but new value will be %d",
__FUNCTION__, __LINE__, old_value, new_value);
if (new_value <= 0)
@ -911,16 +910,16 @@ int farm_set_oface_info(struct farm *f)
int if_index;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s set interface info for interface", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s set interface info for interface", __FUNCTION__, __LINE__, f->name);
if (!(farm_is_ingress_mode(f) ||
farm_needs_flowtable(f))) {
tools_printlog(LOG_DEBUG, "%s():%d: farm %s doesn't require netinfo", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s doesn't require netinfo", __FUNCTION__, __LINE__, f->name);
return 0;
}
if (f->oface && strcmp(f->oface, IFACE_LOOPBACK) == 0) {
tools_printlog(LOG_DEBUG, "%s():%d: farm %s doesn't require output netinfo, loopback interface", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s doesn't require output netinfo, loopback interface", __FUNCTION__, __LINE__, f->name);
f->ofidx = 0;
return 0;
}
@ -929,20 +928,20 @@ int farm_set_oface_info(struct farm *f)
b = backend_get_first(f);
if (!b || b->ipaddr == DEFAULT_IPADDR) {
tools_printlog(LOG_DEBUG, "%s():%d: there is no backend yet in the farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: there is no backend yet in the farm %s", __FUNCTION__, __LINE__, f->name);
return 0;
}
ret = net_get_local_ifidx_per_remote_host(b->ipaddr, &if_index);
if (ret == -1) {
tools_printlog(LOG_ERR, "%s():%d: unable to get the outbound interface to %s for the farm %s", __FUNCTION__, __LINE__, b->ipaddr, f->name);
zcu_log_print(LOG_ERR, "%s():%d: unable to get the outbound interface to %s for the farm %s", __FUNCTION__, __LINE__, b->ipaddr, f->name);
return -1;
}
f->ofidx = if_index;
if (if_indextoname(if_index, if_str) == NULL) {
tools_printlog(LOG_ERR, "%s():%d: unable to get the outbound interface name with index %d required by the farm %s", __FUNCTION__, __LINE__, if_index, f->name);
zcu_log_print(LOG_ERR, "%s():%d: unable to get the outbound interface name with index %d required by the farm %s", __FUNCTION__, __LINE__, if_index, f->name);
return -1;
}
@ -969,7 +968,7 @@ int farm_pre_actionable(struct config_pair *c)
if (!f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
switch (c->key) {
case KEY_NAME:
@ -1006,7 +1005,7 @@ int farm_pos_actionable(struct config_pair *c)
if (!f)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable farm %s with param %d", __FUNCTION__, __LINE__, f->name, c->key);
switch (c->key) {
case KEY_NAME:
@ -1280,7 +1279,7 @@ int farm_set_attribute(struct config_pair *c)
int farm_set_action(struct farm *f, int action)
{
tools_printlog(LOG_DEBUG, "%s():%d: farm %s action is %d - new action %d state %d", __FUNCTION__, __LINE__, f->name, f->action, action, f->state);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s action is %d - new action %d state %d", __FUNCTION__, __LINE__, f->name, f->action, action, f->state);
int force = 0;
if (action == ACTION_STOP && f->state == VALUE_STATE_CONFERR) {
@ -1360,7 +1359,7 @@ int farm_get_masquerade(struct farm *f)
{
int masq = ((f->mode == VALUE_MODE_SNAT || f->mode == VALUE_MODE_LOCAL) && (f->srcaddr == DEFAULT_SRCADDR || strcmp(f->srcaddr, "") == 0));
tools_printlog(LOG_DEBUG, "%s():%d: farm %s masquerade %d", __FUNCTION__, __LINE__, f->name, masq);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s masquerade %d", __FUNCTION__, __LINE__, f->name, masq);
return masq;
}
@ -1370,14 +1369,14 @@ void farm_s_set_backend_ether_by_oifidx(int interface_idx, const char * ip_bck,
struct list_head *farms = obj_get_farms();
struct farm *f;
tools_printlog(LOG_DEBUG, "%s():%d: updating farms with backends ip address %s and ether address %s", __FUNCTION__, __LINE__, ip_bck, ether_bck);
zcu_log_print(LOG_DEBUG, "%s():%d: updating farms with backends ip address %s and ether address %s", __FUNCTION__, __LINE__, ip_bck, ether_bck);
list_for_each_entry(f, farms, list) {
tools_printlog(LOG_DEBUG, "%s():%d: farm with oifidx %d found", __FUNCTION__, __LINE__, interface_idx);
zcu_log_print(LOG_DEBUG, "%s():%d: farm with oifidx %d found", __FUNCTION__, __LINE__, interface_idx);
if (!farm_validate(f)) {
tools_printlog(LOG_INFO, "%s():%d: farm %s doesn't validate", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_INFO, "%s():%d: farm %s doesn't validate", __FUNCTION__, __LINE__, f->name);
farm_set_state(f, VALUE_STATE_CONFERR);
continue;
}
@ -1395,7 +1394,7 @@ int farm_s_lookup_policy_action(char *name, int action)
struct list_head *farms = obj_get_farms();
struct farm *f, *next;
tools_printlog(LOG_DEBUG, "%s():%d: policy %s action %d", __FUNCTION__, __LINE__, name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: policy %s action %d", __FUNCTION__, __LINE__, name, action);
list_for_each_entry_safe(f, next, farms, list)
farmpolicy_s_lookup_policy_action(f, name, action);
@ -1409,7 +1408,7 @@ int farm_s_lookup_address_action(char *name, int action)
struct farm *f, *next;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: address %s action %d", __FUNCTION__, __LINE__, name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: address %s action %d", __FUNCTION__, __LINE__, name, action);
list_for_each_entry_safe(f, next, farms, list)
ret |= farmaddress_s_lookup_address_action(f, name, action);
@ -1419,7 +1418,7 @@ int farm_s_lookup_address_action(char *name, int action)
int farm_rulerize(struct farm *f)
{
tools_printlog(LOG_DEBUG, "%s():%d: rulerize farm %s action %d", __FUNCTION__, __LINE__, f->name, f->action);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize farm %s action %d", __FUNCTION__, __LINE__, f->name, f->action);
farm_print(f);
@ -1431,7 +1430,7 @@ int farm_rulerize(struct farm *f)
if (((f->action == ACTION_START || f->action == ACTION_RELOAD) && !farm_is_available(f)) ||
(f->state == VALUE_STATE_CONFERR)) {
tools_printlog(LOG_INFO, "%s():%d: farm %s won't be rulerized", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_INFO, "%s():%d: farm %s won't be rulerized", __FUNCTION__, __LINE__, f->name);
if (f->state == VALUE_STATE_UP)
farm_set_state(f, VALUE_STATE_CONFERR);
f->action = ACTION_NONE;
@ -1448,7 +1447,7 @@ int farm_s_rulerize(void)
int ret = 0;
int output = 0;
tools_printlog(LOG_DEBUG, "%s():%d: rulerize everything", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize everything", __FUNCTION__, __LINE__);
list_for_each_entry_safe(f, next, farms, list) {
ret = farm_rulerize(f);

View File

@ -22,10 +22,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <execinfo.h>
#include "config.h"
#include "objects.h"
@ -33,7 +31,8 @@
#include "events.h"
#include "network.h"
#include "nft.h"
#include "tools.h"
#include "zcu_backtrace.h"
#include "zcu_log.h"
#define NFTLB_SERVER_MODE 0
#define NFTLB_FG_MODE 0
@ -84,34 +83,20 @@ static const struct option options[] = {
static void nftlb_sighandler(int signo)
{
tools_printlog(LOG_INFO, "shutting down %s, bye", PACKAGE);
zcu_log_print(LOG_INFO, "shutting down %s, bye", PACKAGE);
server_fini();
exit(EXIT_SUCCESS);
}
static void nftlb_trace() {
void *buffer[255];
char **str;
int i, level;
const int calls = backtrace(buffer, sizeof(buffer) / sizeof(void *));
int level;
tools_printlog(LOG_ERR, "SIGSEGV/SIGABRT received!");
backtrace_symbols_fd(buffer, calls, 1);
zcu_bt_print_symbols();
str = backtrace_symbols(buffer, calls);
if (!str) {
tools_printlog(LOG_ERR, "No backtrace strings found!");
exit(EXIT_FAILURE);
}
for (i = 0; i < calls; i++)
tools_printlog(LOG_ERR, "%s", str[i]);
free(str);
level = tools_log_get_level();
tools_log_set_level(LOG_DEBUG);
level = zcu_log_get_level();
zcu_log_set_level(LOG_DEBUG);
obj_print();
tools_log_set_level(level);
zcu_log_set_level(level);
if (!obj_recovery())
exit(EXIT_FAILURE);
}
@ -128,7 +113,7 @@ static int main_process(const char *config, int mode)
if (config && config_file(config) != 0)
return EXIT_FAILURE;
if (tools_log_get_level() > NFTLB_LOG_LEVEL_DEFAULT)
if (zcu_log_get_level() > ZCUTILS_LOG_LEVEL_DEFAULT)
obj_print();
obj_rulerize(OBJ_START);
@ -137,7 +122,7 @@ static int main_process(const char *config, int mode)
return EXIT_SUCCESS;
if (server_init() != 0) {
tools_printlog(LOG_ERR, "Cannot start server-ev: %s\n", strerror(errno));
zcu_log_print(LOG_ERR, "Cannot start server-ev: %s\n", strerror(errno));
return EXIT_FAILURE;
}
@ -151,8 +136,8 @@ int main(int argc, char *argv[])
int c;
int mode = NFTLB_SERVER_MODE;
int run_mode = NFTLB_FG_MODE;
int loglevel = NFTLB_LOG_LEVEL_DEFAULT;
int logoutput = NFTLB_LOG_OUTPUT_DEFAULT;
int loglevel = ZCUTILS_LOG_LEVEL_DEFAULT;
int logoutput = ZCUTILS_LOG_OUTPUT_DEFAULT;
const char *config = NULL;
pid_t pid;
char *_server_key;
@ -197,7 +182,7 @@ int main(int argc, char *argv[])
masquerade_mark = (int)strtol(optarg, NULL, 16);
break;
default:
tools_printlog(LOG_ERR, "Unknown option -%c", optopt);
zcu_log_print(LOG_ERR, "Unknown option -%c", optopt);
return EXIT_FAILURE;
}
}
@ -207,20 +192,20 @@ int main(int argc, char *argv[])
signal(SIGPIPE, SIG_IGN) == SIG_ERR ||
signal(SIGABRT, nftlb_trace) == SIG_ERR ||
signal(SIGSEGV, nftlb_trace) == SIG_ERR) {
tools_printlog(LOG_ERR, "Error assigning signals");
zcu_log_print(LOG_ERR, "Error assigning signals");
return EXIT_FAILURE;
}
if ((_server_key = getenv(NFTLB_SERVER_KEY_VAR)) != NULL && strlen(_server_key) > 0)
server_set_key(_server_key);
tools_log_set_level(loglevel);
tools_log_set_output(logoutput);
zcu_log_set_level(loglevel);
zcu_log_set_output(logoutput);
if (run_mode) {
pid = fork();
if (pid == -1) {
tools_printlog(LOG_ERR, "Daemon mode aborted: %s", strerror(errno));
zcu_log_print(LOG_ERR, "Daemon mode aborted: %s", strerror(errno));
return EXIT_FAILURE;
} else if (pid == 0) {
main_process(config, mode);

View File

@ -38,7 +38,7 @@
#include "events.h"
#include "farms.h"
#include "checksum.h"
#include "tools.h"
#include "zcu_log.h"
#define ARP_TABLE_RETRY_SLEEP 1000
#define ICMP_PROTO 1
@ -129,7 +129,7 @@ static int send_ping(void *data)
int *frame_len;
uint8_t *frame;
tools_printlog(LOG_DEBUG, "%s():%d: sending ping", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: sending ping", __FUNCTION__, __LINE__);
if (sdata->family == AF_INET6) {
frame_len = &frame_len_v6;
@ -204,19 +204,19 @@ static int send_ping(void *data)
}
if (sock < 0) {
tools_printlog(LOG_ERR, "%s():%d: open socket error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: open socket error", __FUNCTION__, __LINE__);
ret = -1;
goto out;
}
if (sendto(sock, frame, *frame_len, 0, pdevice, sizeof(device)) <= 0) {
tools_printlog(LOG_ERR, "%s():%d: sendto error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: sendto error", __FUNCTION__, __LINE__);
ret = -1;
}
out:
if (ret && sock > 0) {
tools_printlog(LOG_DEBUG, "%s():%d: cleanup socket", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: cleanup socket", __FUNCTION__, __LINE__);
close(sock);
}
@ -228,7 +228,7 @@ static int data_attr_neigh_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = data;
int type = mnl_attr_get_type(attr);
tools_printlog(LOG_DEBUG, "%s():%d: launched cb neighbour", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: launched cb neighbour", __FUNCTION__, __LINE__);
if (mnl_attr_type_valid(attr, NDA_MAX) < 0)
return MNL_CB_OK;
@ -237,7 +237,7 @@ static int data_attr_neigh_cb(const struct nlattr *attr, void *data)
case NDA_DST:
case NDA_LLADDR:
if (mnl_attr_validate(attr, MNL_TYPE_BINARY) < 0) {
tools_printlog(LOG_ERR, "%s():%d: mnl_attr_validate error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_attr_validate error", __FUNCTION__, __LINE__);
return MNL_CB_ERROR;
}
break;
@ -260,7 +260,7 @@ static int data_getdst_neigh_cb(const struct nlmsghdr *nlh, void *data)
struct ntl_data *sdata = data;
int matches = 0;
tools_printlog(LOG_DEBUG, "%s():%d: getting ethernet address destination", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: getting ethernet address destination", __FUNCTION__, __LINE__);
mnl_attr_parse(nlh, sizeof(*ndm), data_attr_neigh_cb, tb);
@ -279,7 +279,7 @@ static int data_getdst_neigh_cb(const struct nlmsghdr *nlh, void *data)
ethaddr = mnl_attr_get_payload(tb[NDA_LLADDR]);
memcpy(&sdata->dst_ethaddr, ethaddr, 6);
tools_printlog(LOG_INFO, "%s():%d: get ether address index=%d family=%d dst=%s eth=%02x:%02x:%02x:%02x:%02x:%02x sts=%d",
zcu_log_print(LOG_INFO, "%s():%d: get ether address index=%d family=%d dst=%s eth=%02x:%02x:%02x:%02x:%02x:%02x sts=%d",
__FUNCTION__, __LINE__,
ndm->ndm_ifindex, ndm->ndm_family, out, sdata->dst_ethaddr[0],
sdata->dst_ethaddr[1], sdata->dst_ethaddr[2], sdata->dst_ethaddr[3],
@ -297,7 +297,7 @@ static int data_route_attr_cb(const struct nlattr *attr, void *data)
const struct nlattr **tb = data;
int type = mnl_attr_get_type(attr);
tools_printlog(LOG_DEBUG, "%s():%d: route netlink attr", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: route netlink attr", __FUNCTION__, __LINE__);
if (mnl_attr_type_valid(attr, RTA_MAX) < 0)
return MNL_CB_OK;
@ -312,13 +312,13 @@ static int data_getdst_route_cb(const struct nlmsghdr *nlh, void *data)
struct rtmsg *rm = mnl_nlmsg_get_payload(nlh);
struct ntl_data *sdata = data;
tools_printlog(LOG_DEBUG, "%s():%d: getting interface route destination", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: getting interface route destination", __FUNCTION__, __LINE__);
mnl_attr_parse(nlh, sizeof(*rm), data_route_attr_cb, tb);
if (tb[RTA_OIF]) {
sdata->oifidx = mnl_attr_get_u32(tb[RTA_OIF]);
tools_printlog(LOG_INFO, "%s():%d: get routing interface to destination is %u", __FUNCTION__, __LINE__, sdata->oifidx);
zcu_log_print(LOG_INFO, "%s():%d: get routing interface to destination is %u", __FUNCTION__, __LINE__, sdata->oifidx);
return MNL_CB_STOP;
}
@ -329,22 +329,22 @@ static int ntl_request(struct ntl_request *ntl)
{
int ret, out = 0;
tools_printlog(LOG_DEBUG, "%s():%d: launch netlink request", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: launch netlink request", __FUNCTION__, __LINE__);
ntl->nl = mnl_socket_open(NETLINK_ROUTE);
if (ntl->nl == NULL) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_open error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_open error", __FUNCTION__, __LINE__);
return -1;
}
if (mnl_socket_bind(ntl->nl, 0, MNL_SOCKET_AUTOPID) < 0) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_bind error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_bind error", __FUNCTION__, __LINE__);
return -1;
}
ntl->portid = mnl_socket_get_portid(ntl->nl);
if (mnl_socket_sendto(ntl->nl, ntl->nlh, ntl->nlh->nlmsg_len) < 0) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_sendto error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_sendto error", __FUNCTION__, __LINE__);
return -1;
}
@ -362,7 +362,7 @@ static int ntl_request(struct ntl_request *ntl)
}
if (ret == -1) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_recvfrom error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_recvfrom error", __FUNCTION__, __LINE__);
ret = -1;
}
@ -378,7 +378,7 @@ int net_get_neigh_ether(unsigned char **dst_ethaddr, unsigned char *src_ethaddr,
struct ntl_data *data;
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: source mac address %s source ip address %s destination ip address %s iface %d", __FUNCTION__, __LINE__, src_ethaddr, src_ipaddr, dst_ipaddr, outdev);
zcu_log_print(LOG_DEBUG, "%s():%d: source mac address %s source ip address %s destination ip address %s iface %d", __FUNCTION__, __LINE__, src_ethaddr, src_ipaddr, dst_ipaddr, outdev);
ntl.buf = (char *) malloc(MNL_SOCKET_BUFFER_SIZE);
@ -391,13 +391,13 @@ int net_get_neigh_ether(unsigned char **dst_ethaddr, unsigned char *src_ethaddr,
ntl.rt->rtgen_family = GET_AF_INET(family);
ntl.cb = data_getdst_neigh_cb;
tools_printlog(LOG_DEBUG, "%s():%d: source ether is %02x:%02x:%02x:%02x:%02x:%02x",
zcu_log_print(LOG_DEBUG, "%s():%d: source ether is %02x:%02x:%02x:%02x:%02x:%02x",
__FUNCTION__, __LINE__, src_ethaddr[0], src_ethaddr[1], src_ethaddr[2],
src_ethaddr[3], src_ethaddr[4], src_ethaddr[5]);
data = (struct ntl_data *)calloc(1, sizeof(struct ntl_data));
if (!data) {
tools_printlog(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
return -1;
}
@ -405,14 +405,14 @@ int net_get_neigh_ether(unsigned char **dst_ethaddr, unsigned char *src_ethaddr,
data->dst_ipaddr = (struct in6_addr *)calloc(1, sizeof(struct in6_addr));
if (!data->dst_ipaddr){
tools_printlog(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
return -1;
}
data->family = GET_AF_INET(family);
if (inet_pton(data->family, dst_ipaddr, data->dst_ipaddr) <= 0) {
tools_printlog(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, dst_ipaddr);
zcu_log_print(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, dst_ipaddr);
return -1;
}
@ -422,16 +422,16 @@ int net_get_neigh_ether(unsigned char **dst_ethaddr, unsigned char *src_ethaddr,
if (ret != 0) {
ret = -1;
tools_printlog(LOG_DEBUG, "%s():%d: not found, send ping to %s", __FUNCTION__, __LINE__, dst_ipaddr);
zcu_log_print(LOG_DEBUG, "%s():%d: not found, send ping to %s", __FUNCTION__, __LINE__, dst_ipaddr);
data->src_ipaddr = (struct in6_addr *)calloc(1, sizeof(struct in6_addr));
if (!data->src_ipaddr){
tools_printlog(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
return ret;
}
if (inet_pton(data->family, src_ipaddr, data->src_ipaddr) <= 0) {
tools_printlog(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, src_ipaddr);
zcu_log_print(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, src_ipaddr);
return ret;
}
@ -456,7 +456,7 @@ int net_get_local_ifidx_per_remote_host(char *dst_ipaddr, int *outdev)
int ipv = net_get_addr_family(dst_ipaddr);
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: dst ip address is %s", __FUNCTION__, __LINE__, dst_ipaddr);
zcu_log_print(LOG_DEBUG, "%s():%d: dst ip address is %s", __FUNCTION__, __LINE__, dst_ipaddr);
ntl.buf = (char *) malloc(MNL_SOCKET_BUFFER_SIZE);
@ -478,13 +478,13 @@ int net_get_local_ifidx_per_remote_host(char *dst_ipaddr, int *outdev)
data = (struct ntl_data *)calloc(1, sizeof(struct ntl_data));
if (!data) {
tools_printlog(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
return -1;
}
data->dst_ipaddr = (struct in6_addr *)calloc(1, sizeof(struct in6_addr));
if (!data->dst_ipaddr){
tools_printlog(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: memory allocation error", __FUNCTION__, __LINE__);
return -1;
}
@ -493,7 +493,7 @@ int net_get_local_ifidx_per_remote_host(char *dst_ipaddr, int *outdev)
data->family = ipv;
if (!inet_pton(ipv, dst_ipaddr, &(addr.sin6_addr.s6_addr))) {
tools_printlog(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, dst_ipaddr);
zcu_log_print(LOG_ERR, "%s():%d: network translation error for %s", __FUNCTION__, __LINE__, dst_ipaddr);
return -1;
}
@ -502,11 +502,11 @@ int net_get_local_ifidx_per_remote_host(char *dst_ipaddr, int *outdev)
ret = ntl_request(&ntl);
if (ret != 0) {
tools_printlog(LOG_ERR, "%s():%d: not found route to %s", __FUNCTION__, __LINE__, dst_ipaddr);
zcu_log_print(LOG_ERR, "%s():%d: not found route to %s", __FUNCTION__, __LINE__, dst_ipaddr);
return -1;
}
tools_printlog(LOG_DEBUG, "%s():%d: found route to %s via %d", __FUNCTION__, __LINE__, dst_ipaddr, data->oifidx);
zcu_log_print(LOG_DEBUG, "%s():%d: found route to %s via %d", __FUNCTION__, __LINE__, dst_ipaddr, data->oifidx);
*outdev = data->oifidx;
@ -523,19 +523,19 @@ int net_get_local_ifinfo(unsigned char **ether, const char *indev)
struct ifreq ifr;
int sd;
tools_printlog(LOG_DEBUG, "%s():%d: netlink get local interface info for %s", __FUNCTION__, __LINE__, indev);
zcu_log_print(LOG_DEBUG, "%s():%d: netlink get local interface info for %s", __FUNCTION__, __LINE__, indev);
sd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
if (sd <= 0) {
tools_printlog(LOG_ERR, "%s():%d: open socket error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: open socket error", __FUNCTION__, __LINE__);
goto out;
}
strcpy(ifr.ifr_name, indev);
if (ioctl(sd, SIOCGIFHWADDR, &ifr) == -1) {
tools_printlog(LOG_ERR, "%s():%d: ioctl SIOCGIFHWADDR error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: ioctl SIOCGIFHWADDR error", __FUNCTION__, __LINE__);
goto out;
}
@ -558,17 +558,17 @@ int net_get_local_ifname_per_vip(char *strvip, char *outdev)
struct sockaddr_in6 *ipaddr6;
struct ifaddrs *ifaddrs, *ifaddr;
tools_printlog(LOG_DEBUG, "%s():%d: netlink get local interface name for %s", __FUNCTION__, __LINE__, strvip);
zcu_log_print(LOG_DEBUG, "%s():%d: netlink get local interface name for %s", __FUNCTION__, __LINE__, strvip);
if (!strvip || strcmp(strvip, "") == 0) {
tools_printlog(LOG_ERR, "%s():%d: vip is not set yet", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: vip is not set yet", __FUNCTION__, __LINE__);
return -1;
}
ipv = net_get_addr_family(strvip);
if (getifaddrs(&ifaddrs) == -1) {
tools_printlog(LOG_ERR, "%s():%d: cannot get interfaces list", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: cannot get interfaces list", __FUNCTION__, __LINE__);
return -1;
}
@ -601,7 +601,7 @@ int net_get_local_ifname_per_vip(char *strvip, char *outdev)
freeifaddrs(ifaddrs);
tools_printlog(LOG_DEBUG, "%s():%d: netlink get local interface name is %s", __FUNCTION__, __LINE__, outdev);
zcu_log_print(LOG_DEBUG, "%s():%d: netlink get local interface name is %s", __FUNCTION__, __LINE__, outdev);
return !found;
}
@ -616,7 +616,7 @@ static int data_getev_cb(const struct nlmsghdr *nlh, void *data)
unsigned char dst_ethaddr[ETH_HW_ADDR_LEN];
char streth[ETH_HW_STR_LEN] = {};
tools_printlog(LOG_DEBUG, "%s():%d: netlink read new info", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: netlink read new info", __FUNCTION__, __LINE__);
if (nlh->nlmsg_type != RTM_NEWNEIGH)
return MNL_CB_STOP;
@ -638,7 +638,7 @@ static int data_getev_cb(const struct nlmsghdr *nlh, void *data)
if ((ndm->ndm_state & NUD_REACHABLE) || (ndm->ndm_state & NUD_PERMANENT) || (ndm->ndm_state & NUD_STALE))
farm_s_set_backend_ether_by_oifidx(ndm->ndm_ifindex, str_ipaddr, streth);
tools_printlog(LOG_DEBUG, "%s():%d: [NEW NEIGH] family=%u ifindex=%u state=%u dstaddr=%s macaddr=%s",
zcu_log_print(LOG_DEBUG, "%s():%d: [NEW NEIGH] family=%u ifindex=%u state=%u dstaddr=%s macaddr=%s",
__FUNCTION__, __LINE__, ndm->ndm_family, ndm->ndm_ifindex, ndm->ndm_state, str_ipaddr,
streth);
}
@ -651,7 +651,7 @@ static void ntlk_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
char buf[MNL_SOCKET_BUFFER_SIZE];
int ret, out;
tools_printlog(LOG_DEBUG, "%s():%d: netlink callback executed", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: netlink callback executed", __FUNCTION__, __LINE__);
ret = mnl_socket_recvfrom(nl, buf, sizeof(buf));
while (ret > 0) {
@ -666,7 +666,7 @@ static void ntlk_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
}
if (ret == -1) {
tools_printlog(LOG_ERR, "%s():%d: netlink error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: netlink error", __FUNCTION__, __LINE__);
ret = -1;
}
}
@ -677,7 +677,7 @@ int net_eventd_init(void)
int sock;
struct ev_loop *st_ev_loop = get_loop();
tools_printlog(LOG_DEBUG, "%s():%d: net eventd launched", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: net eventd launched", __FUNCTION__, __LINE__);
io_handle.io = events_create_ntlnk();
@ -691,14 +691,14 @@ int net_eventd_init(void)
nl = mnl_socket_open(NETLINK_ROUTE);
if (nl == NULL) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_open error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_open error", __FUNCTION__, __LINE__);
return -1;
}
sock = mnl_socket_get_fd(nl);
if (mnl_socket_bind(nl, RTM_GETNEIGH, MNL_SOCKET_AUTOPID) < 0) {
tools_printlog(LOG_ERR, "%s():%d: mnl_socket_bind error", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: mnl_socket_bind error", __FUNCTION__, __LINE__);
return -1;
}
@ -714,7 +714,7 @@ int net_eventd_stop(void)
{
struct ev_loop *st_ev_loop = get_loop();
tools_printlog(LOG_DEBUG, "%s():%d: net eventd stopped", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: net eventd stopped", __FUNCTION__, __LINE__);
ev_io_stop(st_ev_loop, io_handle.io);
mnl_socket_close(nl);
@ -729,7 +729,7 @@ int net_eventd_stop(void)
int net_get_event_enabled(void)
{
tools_printlog(LOG_DEBUG, "%s():%d: net eventd is %d", __FUNCTION__, __LINE__, net_event_enabled);
zcu_log_print(LOG_DEBUG, "%s():%d: net eventd is %d", __FUNCTION__, __LINE__, net_event_enabled);
return net_event_enabled;
}

466
src/nft.c

File diff suppressed because it is too large Load Diff

View File

@ -23,14 +23,14 @@
#include "nftst.h"
#include "backends.h"
#include "tools.h"
#include "list.h"
#include "zcu_log.h"
static struct nftst *nftst_create(void)
{
struct nftst *n = (struct nftst *)malloc(sizeof(struct nftst));
if (!n) {
tools_printlog(LOG_ERR, "nft struct memory allocation error");
zcu_log_print(LOG_ERR, "nft struct memory allocation error");
return NULL;
}
return n;

View File

@ -31,8 +31,9 @@
#include "addresses.h"
#include "farmaddress.h"
#include "addresspolicy.h"
#include "tools.h"
#include "nft.h"
#include "zcu_string.h"
#include "zcu_log.h"
#include <stdio.h>
#include <stdlib.h>
@ -109,13 +110,13 @@ void obj_set_total_addresses(int new_value)
int obj_get_dsr_counter(void)
{
tools_printlog(LOG_DEBUG, "%s():%d: current dsr counter is %d", __FUNCTION__, __LINE__, dsr_counter);
zcu_log_print(LOG_DEBUG, "%s():%d: current dsr counter is %d", __FUNCTION__, __LINE__, dsr_counter);
return dsr_counter;
}
void obj_set_dsr_counter(int new_value)
{
tools_printlog(LOG_DEBUG, "%s():%d: new dsr counter is %d", __FUNCTION__, __LINE__, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: new dsr counter is %d", __FUNCTION__, __LINE__, new_value);
if (new_value >= 0)
dsr_counter = new_value;
@ -556,7 +557,7 @@ int obj_set_attribute(struct config_pair *c, int actionable, int apply_action)
{
int ret = 0;
int action = ACTION_NONE;
tools_printlog(LOG_DEBUG, "%s():%d: actionable is %d", __FUNCTION__, __LINE__, actionable);
zcu_log_print(LOG_DEBUG, "%s():%d: actionable is %d", __FUNCTION__, __LINE__, actionable);
switch (c->level) {
case LEVEL_FARMS:
@ -652,7 +653,7 @@ int obj_set_attribute(struct config_pair *c, int actionable, int apply_action)
addresspolicy_pos_actionable(c);
break;
default:
tools_printlog(LOG_ERR, "%s():%d: unknown level %d", __FUNCTION__, __LINE__, c->level);
zcu_log_print(LOG_ERR, "%s():%d: unknown level %d", __FUNCTION__, __LINE__, c->level);
return PARSER_STRUCT_FAILED;
}
@ -666,11 +667,11 @@ int obj_set_attribute_string(char *src, char **dst)
*dst = (char *)malloc(size);
if (!*dst) {
tools_printlog(LOG_ERR, "Attribute memory allocation error");
zcu_log_print(LOG_ERR, "Attribute memory allocation error");
return -1;
}
tools_snprintf(*dst, size-1, src);
zcu_str_snprintf(*dst, size-1, src);
return 0;
}
@ -770,17 +771,17 @@ int obj_recovery(void)
return 0;
cmdtry++;
tools_printlog(LOG_ERR, "recovery in progress...");
zcu_log_print(LOG_ERR, "recovery in progress...");
nft_reset();
policy_s_set_action(ACTION_START);
farm_s_set_reload_start(ACTION_START);
reload_err = obj_rulerize(OBJ_START);
if (!reload_err) {
tools_printlog(LOG_ERR, "nft recovered...");
zcu_log_print(LOG_ERR, "nft recovered...");
cmdtry = 0;
return 1;
} else
tools_printlog(LOG_ERR, "recovery not successful...");
zcu_log_print(LOG_ERR, "recovery not successful...");
return 0;
}

View File

@ -28,7 +28,7 @@
#include "objects.h"
#include "config.h"
#include "nft.h"
#include "tools.h"
#include "zcu_log.h"
static struct policy * policy_create(char *name)
{
@ -36,7 +36,7 @@ static struct policy * policy_create(char *name)
struct policy *p = (struct policy *)malloc(sizeof(struct policy));
if (!p) {
tools_printlog(LOG_ERR, "Policy memory allocation error");
zcu_log_print(LOG_ERR, "Policy memory allocation error");
return NULL;
}
@ -82,15 +82,15 @@ static int policy_set_family(struct policy *p, int new_value)
{
int old_value = p->family;
tools_printlog(LOG_DEBUG, "%s():%d: policy %s old family %d new family %d", __FUNCTION__, __LINE__, p->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: policy %s old family %d new family %d", __FUNCTION__, __LINE__, p->name, old_value, new_value);
if (new_value != VALUE_FAMILY_IPV4 && new_value != VALUE_FAMILY_IPV6) {
tools_printlog(LOG_INFO, "%s():%d: family %d not supported for policies", __FUNCTION__, __LINE__, new_value);
zcu_log_print(LOG_INFO, "%s():%d: family %d not supported for policies", __FUNCTION__, __LINE__, new_value);
return 0;
}
if (old_value == new_value) {
tools_printlog(LOG_DEBUG, "%s():%d: family %d without change for policy %s", __FUNCTION__, __LINE__, p->family, p->name);
zcu_log_print(LOG_DEBUG, "%s():%d: family %d without change for policy %s", __FUNCTION__, __LINE__, p->family, p->name);
return 0;
}
@ -103,7 +103,7 @@ static int policy_set_type(struct policy *p, int new_value)
{
int old_value = p->type;
tools_printlog(LOG_DEBUG, "%s():%d: policy %s old type %d new type %d", __FUNCTION__, __LINE__, p->name, old_value, new_value);
zcu_log_print(LOG_DEBUG, "%s():%d: policy %s old type %d new type %d", __FUNCTION__, __LINE__, p->name, old_value, new_value);
p->type = new_value;
@ -112,19 +112,19 @@ static int policy_set_type(struct policy *p, int new_value)
void policy_print(struct policy *p)
{
tools_printlog(LOG_DEBUG," [policy] ");
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, p->name);
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_TYPE, obj_print_policy_type(p->type));
zcu_log_print(LOG_DEBUG," [policy] ");
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_NAME, p->name);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_TYPE, obj_print_policy_type(p->type));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_ROUTE, obj_print_policy_route(p->route));
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(p->family));
tools_printlog(LOG_DEBUG," [%s] %d", CONFIG_KEY_TIMEOUT, p->timeout);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_ROUTE, obj_print_policy_route(p->route));
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_FAMILY, obj_print_family(p->family));
zcu_log_print(LOG_DEBUG," [%s] %d", CONFIG_KEY_TIMEOUT, p->timeout);
if (p->logprefix)
tools_printlog(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, p->logprefix);
zcu_log_print(LOG_DEBUG," [%s] %s", CONFIG_KEY_LOGPREFIX, p->logprefix);
tools_printlog(LOG_DEBUG," *[used] %d", p->used);
tools_printlog(LOG_DEBUG," *[total_elem] %d", p->total_elem);
tools_printlog(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, p->action);
zcu_log_print(LOG_DEBUG," *[used] %d", p->used);
zcu_log_print(LOG_DEBUG," *[total_elem] %d", p->total_elem);
zcu_log_print(LOG_DEBUG," *[%s] %d", CONFIG_KEY_ACTION, p->action);
if (p->total_elem != 0)
element_s_print(p);
@ -239,7 +239,7 @@ int policy_set_attribute(struct config_pair *c)
int policy_set_action(struct policy *p, int action)
{
tools_printlog(LOG_DEBUG, "%s():%d: policy %s set action %d", __FUNCTION__, __LINE__, p->name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: policy %s set action %d", __FUNCTION__, __LINE__, p->name, action);
if (p->action == action || (p->action == ACTION_START && action == ACTION_RELOAD))
return 0;
@ -278,7 +278,7 @@ int policy_pre_actionable(struct config_pair *c)
if (!p)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable policy %s with param %d action is %d", __FUNCTION__, __LINE__, p->name, c->key, p->action);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable policy %s with param %d action is %d", __FUNCTION__, __LINE__, p->name, c->key, p->action);
switch (c->key) {
case KEY_NAME:
@ -305,7 +305,7 @@ int policy_pos_actionable(struct config_pair *c)
if (!p)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable policy %s with param %d action is %d", __FUNCTION__, __LINE__, p->name, c->key, p->action);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable policy %s with param %d action is %d", __FUNCTION__, __LINE__, p->name, c->key, p->action);
switch (c->key) {
case KEY_NAME:
@ -328,12 +328,12 @@ int policy_pos_actionable(struct config_pair *c)
int policy_rulerize(struct policy *p)
{
int ret = 0;
tools_printlog(LOG_DEBUG, "%s():%d: rulerize policy %s", __FUNCTION__, __LINE__, p->name);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize policy %s", __FUNCTION__, __LINE__, p->name);
policy_print(p);
if (p->action == ACTION_NONE) {
tools_printlog(LOG_INFO, "%s():%d: policy %s won't be rulerized", __FUNCTION__, __LINE__, p->name);
zcu_log_print(LOG_INFO, "%s():%d: policy %s won't be rulerized", __FUNCTION__, __LINE__, p->name);
return 0;
}
@ -348,7 +348,7 @@ int policy_s_rulerize(void)
int ret = 0;
int output = 0;
tools_printlog(LOG_DEBUG, "%s():%d: rulerize all policies", __FUNCTION__, __LINE__);
zcu_log_print(LOG_DEBUG, "%s():%d: rulerize all policies", __FUNCTION__, __LINE__);
struct list_head *policies = obj_get_policies();

View File

@ -34,8 +34,8 @@
#include "config.h"
#include "nft.h"
#include "events.h"
#include "sbuffer.h"
#include "tools.h"
#include "zcu_sbuffer.h"
#include "zcu_log.h"
#define SRV_MAX_BUF 1024
#define SRV_MAX_HEADER 300
@ -125,7 +125,7 @@ static int auth_key(const char *recvkey)
return (strcmp(nftserver.key, recvkey) == 0);
}
static int get_request(int fd, struct sbuffer *buf, struct nftlb_http_state *state)
static int get_request(int fd, struct zcu_buffer *buf, struct nftlb_http_state *state)
{
char method[SRV_MAX_IDENT] = {0};
char strkey[SRV_MAX_IDENT] = {0};
@ -138,7 +138,7 @@ static int get_request(int fd, struct sbuffer *buf, struct nftlb_http_state *sta
int bytes_left;
int cont_100 = 0;
if ((ptr = strstr(get_buf_data(buf), "Key: ")) == NULL) {
if ((ptr = strstr(zcu_buf_get_data(buf), "Key: ")) == NULL) {
state->status_code = WS_HTTP_401;
return -1;
}
@ -150,9 +150,9 @@ static int get_request(int fd, struct sbuffer *buf, struct nftlb_http_state *sta
return -1;
}
sscanf(get_buf_data(buf), "%199[^ ] %199[^ ] ", method, state->uri);
sscanf(zcu_buf_get_data(buf), "%199[^ ] %199[^ ] ", method, state->uri);
tools_printlog(LOG_NOTICE, "%s():%d: request: %s %s", __FUNCTION__, __LINE__, method, state->uri);
zcu_log_print(LOG_NOTICE, "%s():%d: request: %s %s", __FUNCTION__, __LINE__, method, state->uri);
if (strncmp(method, STR_GET_ACTION, 4) == 0) {
state->method = WS_GET_ACTION;
@ -172,38 +172,38 @@ static int get_request(int fd, struct sbuffer *buf, struct nftlb_http_state *sta
if (state->method == WS_GET_ACTION)
return 0;
state->body = strstr(get_buf_data(buf), "\r\n\r\n");
state->body = strstr(zcu_buf_get_data(buf), "\r\n\r\n");
if (!state->body) {
tools_printlog(LOG_ERR, "Not found body section in the request");
zcu_log_print(LOG_ERR, "Not found body section in the request");
state->status_code = parse_to_http_status(PARSER_STRUCT_FAILED);
return -1;
}
state->body += 4;
head = state->body - get_buf_data(buf);
head = state->body - zcu_buf_get_data(buf);
if ((ptr = strstr(get_buf_data(buf), "Expect: 100-continue")) != NULL) {
if ((ptr = strstr(zcu_buf_get_data(buf), "Expect: 100-continue")) != NULL) {
cont_100 = 1;
send(fd, "HTTP/1.1 100 Continue\r\n\r\n", 25, 0);
}
if ((ptr = strstr(get_buf_data(buf), "Content-Length: ")) != NULL) {
if ((ptr = strstr(zcu_buf_get_data(buf), "Content-Length: ")) != NULL) {
sscanf(ptr, "Content-Length: %i[^\r\n]", &contlength);
if (head + contlength >= get_buf_size(buf))
times = ((head + contlength - get_buf_size(buf)) / EXTRA_SIZE) + 1;
if (head + contlength >= zcu_buf_get_size(buf))
times = ((head + contlength - zcu_buf_get_size(buf)) / EXTRA_SIZE) + 1;
if (times == 0)
goto receive;
if (resize_buf(buf, times)) {
tools_printlog(LOG_ERR, "Error resizing the buffer %d times from a size of %d!", times, get_buf_size(buf));
if (zcu_buf_resize(buf, times)) {
zcu_log_print(LOG_ERR, "Error resizing the buffer %d times from a size of %d!", times, zcu_buf_get_size(buf));
state->status_code = WS_HTTP_500;
return -1;
}
}
receive:
state->body = get_buf_data(buf) + head;
total_read_size = get_buf_next(buf) - state->body;
state->body = zcu_buf_get_data(buf) + head;
total_read_size = zcu_buf_get_next(buf) - state->body;
while ((total_read_size < contlength) || cont_100) {
cont_100 = 0;
bytes_left = EXTRA_SIZE;
@ -211,7 +211,7 @@ receive:
bytes_left = contlength - total_read_size;
if (bytes_left <= 0)
goto final;
size = recv(fd, get_buf_next(buf), bytes_left, 0);
size = recv(fd, zcu_buf_get_next(buf), bytes_left, 0);
if (size <= 0)
goto final;
buf->next += size;
@ -219,7 +219,7 @@ receive:
}
final:
concat_buf(buf, "\0");
zcu_buf_concat(buf, "\0");
return 0;
}
@ -651,27 +651,27 @@ static void nftlb_http_send_response(struct ev_io *io,
static void nftlb_read_cb(struct ev_loop *loop, struct ev_io *io, int revents)
{
struct sbuffer buf;
struct zcu_buffer buf;
struct nftlb_http_state state;
struct nftlb_client *cli;
ssize_t size;
char cli_address[INET6_ADDRSTRLEN + 6]; //max address length + port length
if (EV_ERROR & revents) {
tools_printlog(LOG_ERR, "Server got invalid event from client read");
zcu_log_print(LOG_ERR, "Server got invalid event from client read");
return;
}
cli = container_of(io, struct nftlb_client, io);
create_buf(&buf);
size = recv(io->fd, get_buf_data(&buf), DEFAULT_BUFFER_SIZE - 1, 0);
zcu_buf_create(&buf);
size = recv(io->fd, zcu_buf_get_data(&buf), ZCU_DEF_BUFFER_SIZE - 1, 0);
if (size < 0)
return;
buf.next = size;
if (size == 0) {
tools_printlog(LOG_DEBUG, "connection closed by client %s\n",
zcu_log_print(LOG_DEBUG, "connection closed by client %s\n",
nftlb_client_address(&cli->addr, cli_address));
goto end_no_state;
}
@ -692,12 +692,12 @@ static void nftlb_read_cb(struct ev_loop *loop, struct ev_io *io, int revents)
nftlb_http_send_response(io, &state, strlen(state.body_response));
send(io->fd, state.body_response, strlen(state.body_response), 0);
tools_printlog(LOG_DEBUG, "connection closed by server %s\n",
zcu_log_print(LOG_DEBUG, "connection closed by server %s\n",
nftlb_client_address(&cli->addr, cli_address));
end:
fin_http_state(&state);
end_no_state:
clean_buf(&buf);
zcu_buf_clean(&buf);
ev_timer_stop(loop, &cli->timer);
nftlb_client_release(loop, cli);
@ -712,7 +712,7 @@ static void nftlb_timer_cb(struct ev_loop *loop, ev_timer *timer, int events)
cli = container_of(timer, struct nftlb_client, timer);
tools_printlog(LOG_ERR, "timeout for client %s\n",
zcu_log_print(LOG_ERR, "timeout for client %s\n",
nftlb_client_address(&cli->addr, cli_address));
nftlb_client_release(loop, cli);
@ -726,19 +726,19 @@ static void accept_cb(struct ev_loop *loop, struct ev_io *io, int revents)
int client_sd;
if (EV_ERROR & revents) {
tools_printlog(LOG_ERR, "Server got an invalid event from client");
zcu_log_print(LOG_ERR, "Server got an invalid event from client");
return;
}
client_sd = accept(io->fd, (struct sockaddr *)&client_addr, &addrlen);
if (client_sd < 0) {
tools_printlog(LOG_ERR, "Server accept error");
zcu_log_print(LOG_ERR, "Server accept error");
return;
}
cli = malloc(sizeof(struct nftlb_client));
if (!cli) {
tools_printlog(LOG_ERR, "No memory available to allocate new client");
zcu_log_print(LOG_ERR, "No memory available to allocate new client");
return;
}
memcpy(&cli->addr, &client_addr, sizeof(cli->addr));
@ -790,26 +790,26 @@ int server_init(void)
s = getaddrinfo(host, port, &hints, &result);
if (s != 0) {
tools_printlog(LOG_ERR, "getaddrinfo: %s\n", gai_strerror(s));
zcu_log_print(LOG_ERR, "getaddrinfo: %s\n", gai_strerror(s));
return -1;
}
server_sd = socket(result->ai_family, SOCK_STREAM, 0);
if (server_sd < 0) {
tools_printlog(LOG_ERR, "Server socket error");
zcu_log_print(LOG_ERR, "Server socket error");
return -1;
}
setsockopt(server_sd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
if (bind(server_sd, result->ai_addr, result->ai_addrlen) != 0) {
tools_printlog(LOG_ERR, "Server bind error");
zcu_log_print(LOG_ERR, "Server bind error");
freeaddrinfo(result);
return -1;
}
freeaddrinfo(result);
if (listen(server_sd, 2) < 0) {
tools_printlog(LOG_ERR, "Server listen error");
zcu_log_print(LOG_ERR, "Server listen error");
return -1;
}
nftserver.sd = server_sd;
@ -831,7 +831,7 @@ void server_set_host(const char *host)
nftserver.host = malloc(strlen(host)+1);
if (!nftserver.host) {
tools_printlog(LOG_ERR, "No memory available to allocate the server host");
zcu_log_print(LOG_ERR, "No memory available to allocate the server host");
return;
}
@ -842,7 +842,7 @@ void server_set_port(const char *port)
{
nftserver.port = malloc(strlen(port)+1);
if (!nftserver.port) {
tools_printlog(LOG_ERR, "No memory available to allocate the server port");
zcu_log_print(LOG_ERR, "No memory available to allocate the server port");
return;
}
@ -856,7 +856,7 @@ void server_set_key(char *key)
if (!nftserver.key) {
nftserver.key = (char *)malloc(SRV_MAX_IDENT);
if (!nftserver.key) {
tools_printlog(LOG_ERR, "No memory available to allocate the server key");
zcu_log_print(LOG_ERR, "No memory available to allocate the server key");
return;
}
}

View File

@ -27,24 +27,25 @@
#include "farms.h"
#include "farmaddress.h"
#include "objects.h"
#include "tools.h"
#include "nft.h"
#include "zcu_string.h"
#include "zcu_log.h"
static struct session * session_create(struct farm *f, int type, char *client, char *bck, char *expiration)
{
struct session *s;
struct backend *b;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s type %d client %s bck %s expiration %s", __FUNCTION__, __LINE__, f->name, type, client, bck, expiration);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s type %d client %s bck %s expiration %s", __FUNCTION__, __LINE__, f->name, type, client, bck, expiration);
if (!client || strcmp(client, "") == 0) {
tools_printlog(LOG_ERR, "%s():%d: missing data", __FUNCTION__, __LINE__);
zcu_log_print(LOG_ERR, "%s():%d: missing data", __FUNCTION__, __LINE__);
return NULL;
}
s = (struct session *)malloc(sizeof(struct session));
if (!s) {
tools_printlog(LOG_ERR, "Session memory allocation error");
zcu_log_print(LOG_ERR, "Session memory allocation error");
return NULL;
}
@ -110,20 +111,20 @@ new_session:
to_found = 0;
if ((fin_ptr = strstr(ini_ptr, " timeout ")) != NULL) {
tools_snprintf(elem_client, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_client, fin_ptr - ini_ptr, ini_ptr);
to_found = 1;
}
if ((fin_ptr = strstr(ini_ptr, " expires ")) != NULL) {
if (!to_found)
tools_snprintf(elem_client, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_client, fin_ptr - ini_ptr, ini_ptr);
fin_ptr += 9;
ini_ptr = fin_ptr;
} else
return 0;
if ((fin_ptr = strstr(ini_ptr, " : ")) != NULL) {
tools_snprintf(elem_exp, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_exp, fin_ptr - ini_ptr, ini_ptr);
fin_ptr += 3;
ini_ptr = fin_ptr;
} else
@ -136,7 +137,7 @@ new_session:
return 0;
}
tools_snprintf(elem_bck, fin_ptr - ini_ptr, ini_ptr);
zcu_str_snprintf(elem_bck, fin_ptr - ini_ptr, ini_ptr);
fin_ptr += 1;
ini_ptr = fin_ptr;
@ -156,7 +157,7 @@ new_session:
static int session_delete_node(struct session *s, int type)
{
tools_printlog(LOG_DEBUG, "%s():%d: client %s", __FUNCTION__, __LINE__, s->client);
zcu_log_print(LOG_DEBUG, "%s():%d: client %s", __FUNCTION__, __LINE__, s->client);
list_del(&s->list);
@ -177,7 +178,7 @@ static int session_delete_node(struct session *s, int type)
int session_set_action(struct session *s, int type, int action)
{
tools_printlog(LOG_DEBUG, "%s():%d: session %s action is %d - new action %d", __FUNCTION__, __LINE__, s->client, s->action, action);
zcu_log_print(LOG_DEBUG, "%s():%d: session %s action is %d - new action %d", __FUNCTION__, __LINE__, s->client, s->action, action);
if (s->action == action)
return 0;
@ -236,7 +237,7 @@ int session_s_delete(struct farm *f, int type)
struct session *s;
struct session *next;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s type %d", __FUNCTION__, __LINE__, f->name, type);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s type %d", __FUNCTION__, __LINE__, f->name, type);
if (type == SESSION_TYPE_TIMED)
sessions = &f->timed_sessions;
@ -271,30 +272,30 @@ void session_s_print(struct farm *f)
struct session *s;
list_for_each_entry(s, &f->static_sessions, list) {
tools_printlog(LOG_DEBUG," [session] ");
tools_printlog(LOG_DEBUG," [client] %s", s->client);
zcu_log_print(LOG_DEBUG," [session] ");
zcu_log_print(LOG_DEBUG," [client] %s", s->client);
if (!s->bck)
tools_printlog(LOG_DEBUG," [backend] %s", UNDEFINED_VALUE);
zcu_log_print(LOG_DEBUG," [backend] %s", UNDEFINED_VALUE);
else
tools_printlog(LOG_DEBUG," [backend] %s", s->bck->name);
zcu_log_print(LOG_DEBUG," [backend] %s", s->bck->name);
tools_printlog(LOG_DEBUG," *[state] %s", obj_print_state(s->state));
tools_printlog(LOG_DEBUG," *[action] %d", s->action);
zcu_log_print(LOG_DEBUG," *[state] %s", obj_print_state(s->state));
zcu_log_print(LOG_DEBUG," *[action] %d", s->action);
}
list_for_each_entry(s, &f->timed_sessions, list) {
tools_printlog(LOG_DEBUG," [session] ");
tools_printlog(LOG_DEBUG," [client] %s", s->client);
zcu_log_print(LOG_DEBUG," [session] ");
zcu_log_print(LOG_DEBUG," [client] %s", s->client);
if (!s->bck)
tools_printlog(LOG_DEBUG," [backend] %s", UNDEFINED_VALUE);
zcu_log_print(LOG_DEBUG," [backend] %s", UNDEFINED_VALUE);
else
tools_printlog(LOG_DEBUG," [backend] %s", s->bck->name);
zcu_log_print(LOG_DEBUG," [backend] %s", s->bck->name);
tools_printlog(LOG_DEBUG," [expiration] %s", s->expiration);
tools_printlog(LOG_DEBUG," *[state] %s", obj_print_state(s->state));
tools_printlog(LOG_DEBUG," *[action] %d", s->action);
zcu_log_print(LOG_DEBUG," [expiration] %s", s->expiration);
zcu_log_print(LOG_DEBUG," *[state] %s", obj_print_state(s->state));
zcu_log_print(LOG_DEBUG," *[action] %d", s->action);
}
}
@ -304,7 +305,7 @@ int session_get_timed(struct farm *f)
struct nftst *n = nftst_create_from_farm(f);
const char *buf;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s", __FUNCTION__, __LINE__, f->name);
f->total_timed_sessions = 0;
list_for_each_entry(fa, &f->addresses, list) {
@ -331,7 +332,7 @@ int session_backend_action(struct farm *f, struct backend *b, int action)
struct session *s, *next;
int hastimed = f->total_timed_sessions;
tools_printlog(LOG_DEBUG, "%s():%d: farm %s backend %s action %d", __FUNCTION__, __LINE__, f->name, b->name, action);
zcu_log_print(LOG_DEBUG, "%s():%d: farm %s backend %s action %d", __FUNCTION__, __LINE__, f->name, b->name, action);
if (f->total_static_sessions != 0) {
list_for_each_entry_safe(s, next, &f->static_sessions, list) {
@ -403,7 +404,7 @@ int session_pre_actionable(struct config_pair *c)
if (!f || !s)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pre actionable session farm %s", __FUNCTION__, __LINE__, f->name);
zcu_log_print(LOG_DEBUG, "%s():%d: pre actionable session farm %s", __FUNCTION__, __LINE__, f->name);
switch (c->key) {
case KEY_CLIENT:
@ -429,7 +430,7 @@ int session_pos_actionable(struct config_pair *c)
if (!f || !s)
return -1;
tools_printlog(LOG_DEBUG, "%s():%d: pos actionable session %s of farm %s with param %d", __FUNCTION__, __LINE__, s->client, f->name, c->key);
zcu_log_print(LOG_DEBUG, "%s():%d: pos actionable session %s of farm %s with param %d", __FUNCTION__, __LINE__, s->client, f->name, c->key);
switch (c->key) {
case KEY_CLIENT:

View File

@ -1,96 +0,0 @@
/*
* This file is part of nftlb, nftables load balancer.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdarg.h>
#include "tools.h"
int log_output;
int log_level;
void tools_snprintf(char *strdst, int size, char *strsrc)
{
for (int i = 0; i < size; i++) {
strdst[i] = *(strsrc + i);
}
strdst[size] = '\0';
}
void tools_log_set_level(int loglevel)
{
log_level = loglevel;
setlogmask(LOG_UPTO(loglevel));
}
int tools_log_get_level(void)
{
return log_level;
}
void tools_log_set_output(int output)
{
switch (output) {
case VALUE_LOG_OUTPUT_STDOUT:
log_output = NFTLB_LOG_OUTPUT_STDOUT;
break;
case VALUE_LOG_OUTPUT_STDERR:
log_output = NFTLB_LOG_OUTPUT_STDERR;
break;
case VALUE_LOG_OUTPUT_SYSOUT:
log_output = NFTLB_LOG_OUTPUT_SYSLOG | NFTLB_LOG_OUTPUT_STDOUT;
break;
case VALUE_LOG_OUTPUT_SYSERR:
log_output = NFTLB_LOG_OUTPUT_SYSLOG | NFTLB_LOG_OUTPUT_STDERR;
break;
case VALUE_LOG_OUTPUT_SYSLOG:
default:
log_output = NFTLB_LOG_OUTPUT_SYSLOG;
}
return;
}
int tools_printlog(int loglevel, char *fmt, ...)
{
va_list args;
if (log_output & NFTLB_LOG_OUTPUT_STDOUT && loglevel <= log_level) {
va_start(args, fmt);
vfprintf(stdout, fmt, args);
fprintf(stdout, "\n");
va_end(args);
}
if (log_output & NFTLB_LOG_OUTPUT_STDERR && loglevel <= log_level) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
}
if (log_output & NFTLB_LOG_OUTPUT_SYSLOG) {
va_start(args, fmt);
vsyslog(loglevel, fmt, args);
va_end(args);
}
return 0;
}

87
zcutils/CMakeLists.txt Normal file
View File

@ -0,0 +1,87 @@
###############################################################################
#
# Zevenet zproxy Load Balancer Software License
# This file is part of the Zevenet zproxy Load Balancer software package.
#
# Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 17)
if(EXISTS CMakeLists.txt)
message(FATAL_ERROR"Please create a cmake build directory, running cmake form source tree root is not allowed\n")
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()
set (CMAKE_ENABLE_EXPORTS TRUE)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(MAINFOLDER ${PROJECT_SOURCE_DIR})
set(PROJECT_VERSION "0.0.1")
set(PROJECT_DESCRIPTION "Zevenet core utils library")
set(PROJECT_CODENAME "zcutils")
# get current git info
if (EXISTS "${PROJECT_SOURCE_DIR}/.git/HEAD")
file(READ "${PROJECT_SOURCE_DIR}/.git/HEAD"
PROJECT_SOURCE_VERSION)
if ("${PROJECT_SOURCE_VERSION}" MATCHES "^ref:")
string(REGEX REPLACE "^ref: *([^ \n\r]*).*" "\\1"
PROJECT_GIT_REF "${PROJECT_SOURCE_VERSION}")
file(READ "${PROJECT_SOURCE_DIR}/.git/${PROJECT_GIT_REF}"
PROJECT_SOURCE_VERSION)
endif ()
string(STRIP "${PROJECT_SOURCE_VERSION}"
PROJECT_SOURCE_VERSION)
endif ()
add_definitions(-DPROJECT_NAME="zcutils")
add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}")
if (UNIQUE_BUILD_DIRECTORY)
set(EXECUTABLE_OUTPUT_PATH "${MAINFOLDER}/build/bin")
endif ()
set(sources
## sources
src/zcu_log.c
src/zcu_network.c
src/zcu_backtrace.c
src/zcu_sbuffer.c
src/zcu_string.c
## libs
include/zcu_log.h
include/zcu_common.h
include/zcu_backtrace.h
include/zcu_environment.h
include/zcu_time.h
include/zcu_network.h
include/zcu_sbuffer.h
include/zcu_string.h
)
include_directories(${PROJECT_SOURCE_DIR}/zcutils/include)
add_library(zcutils ${sources})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -pipe -g -Wno-unused-function -Wall")
include_directories(${PROJECT_SOURCE_DIR}/include)

View File

@ -0,0 +1,35 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_BACKTRACE_H_
#define _ZCU_BACKTRACE_H_
#ifdef __cplusplus
extern "C" {
#endif
void zcu_bt_print_symbols(void);
#ifdef __cplusplus
}
#endif
#endif /* _ZCU_BACKTRACE_H_ */

View File

@ -0,0 +1,41 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_COMMON_H_
#define _ZCU_COMMON_H_
#define ZCU_DEF_BUFFER_SIZE 4096
#define MAXBUF 4096
#define LIKELY(x) __builtin_expect((x), 1)
#define UNLIKELY(x) __builtin_expect((x), 0)
#define UNIQUE_NAME_0(a, b) UNIQUE_NAME_I(a, b)
#define UNIQUE_NAME_I(a, b) UNIQUE_NAME_II(~, a##b)
#define UNIQUE_NAME_II(p, res) res
#define UNIQUE_NAME(base) UNIQUE_NAME_0(base, __COUNTER__)
// Maximum buffer data. The requet or response headers can't be bigger
// than this value
#ifndef MAX_DATA_SIZE
#define MAX_DATA_SIZE (1024 * 64)
#endif
#endif /* _ZCU_COMMON_H_ */

View File

@ -0,0 +1,28 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_DEFINES_H_
#define _ZCU_DEFINES_H_
#define ZCU_DEF_BUFFER_SIZE 4096
#define MAXBUF 4096
#endif

View File

@ -0,0 +1,81 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_ENVIRONMENT_H_
#define _ZCU_ENVIRONMENT_H_
#include <csignal>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <string>
#include <sys/resource.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iostream>
#ifdef __cplusplus
extern "C" {
#endif
/*
If a second paratemer is passed, it is added in the pid file in a new line
*/
static bool createPidFile(const std::string & pid_file_name,
int pid = -1, int child_pid = -1)
{
auto pid_file_hl = ::fopen(pid_file_name.c_str(), "wt");
if (pid_file_hl != nullptr) {
fprintf(pid_file_hl, "%d\n",
pid != -1 ? pid : getpid());
if (child_pid != -1)
fprintf(pid_file_hl, "%d\n", child_pid);
fclose(pid_file_hl);
return true;
} else
zcu_log_print(LOG_ERR, "Create \"%s\": %s",
__func__, __LINE__,
pid_file_name.c_str(), strerror(errno));
return false;
}
static bool removePidFile(const std::string & pid_file_name)
{
struct stat info;
if (lstat(pid_file_name.data(), &info) != 0)
return false;
if (!S_ISREG(info.st_mode))
return false;
if (info.st_uid != getuid())
return false;
if (info.st_size > static_cast < int > (sizeof("65535\r\n")))
return false;
unlink(pid_file_name.data());
return true;
}
#ifdef __cplusplus
}
#endif
#endif /* _ZCU_ENVIRONMENT_H_ */

72
zcutils/include/zcu_log.h Normal file
View File

@ -0,0 +1,72 @@
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_LOG_H_
#define _ZCU_LOG_H_
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <pthread.h>
#include <stdarg.h>
#include <string.h>
#define LOG_PREFIX_BUFSIZE 100
#define ZCUTILS_LOG_OUTPUT_SYSLOG (1 << 0)
#define ZCUTILS_LOG_OUTPUT_STDOUT (1 << 1)
#define ZCUTILS_LOG_OUTPUT_STDERR (1 << 2)
enum zcu_log_output {
VALUE_LOG_OUTPUT_SYSLOG,
VALUE_LOG_OUTPUT_STDOUT,
VALUE_LOG_OUTPUT_STDERR,
VALUE_LOG_OUTPUT_SYSOUT,
VALUE_LOG_OUTPUT_SYSERR,
};
#define ZCUTILS_LOG_LEVEL_DEFAULT LOG_NOTICE
#define ZCUTILS_LOG_OUTPUT_DEFAULT ZCUTILS_LOG_OUTPUT_SYSLOG
extern char zcu_log_prefix[LOG_PREFIX_BUFSIZE];
extern int zcu_log_level;
extern int zcu_log_output;
#ifdef __cplusplus
extern "C" {
#endif
void zcu_log_set_prefix(const char *string);
void zcu_log_set_level(int loglevel);
int zcu_log_get_level(void);
void zcu_log_set_output(int output);
int _zcu_log_print(int loglevel, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#define zcu_log_print(loglevel, fmt, ...) \
_zcu_log_print(loglevel, "[f:%s][th:%lx] " fmt, zcu_log_prefix, \
(unsigned int) (pthread_self()), \
##__VA_ARGS__)
#endif /* _ZCU_LOG_H_ */

View File

@ -1,5 +1,5 @@
/*
* This file is part of nftlb, nftables load balancer.
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
@ -19,29 +19,28 @@
*
*/
#ifndef _SBUFFER_H_
#define _SBUFFER_H_
#ifndef _ZCU_NETWORK_H_
#define _ZCU_NETWORK_H_
#include <stdarg.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#define DEFAULT_BUFFER_SIZE 4096
#define EXTRA_SIZE 1024
#ifdef __cplusplus
extern "C" {
#endif
struct sbuffer {
int size;
int next;
char *data;
};
int zcu_soc_equal_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2,
int compare_port);
int get_buf_size(struct sbuffer *buf);
char * get_buf_next(struct sbuffer *buf);
char * get_buf_data(struct sbuffer *buf);
int resize_buf(struct sbuffer *buf, int times);
int create_buf(struct sbuffer *buf);
int clean_buf(struct sbuffer *buf);
int reset_buf(struct sbuffer *buf);
int isempty_buf(struct sbuffer *buf);
int concat_buf_va(struct sbuffer *buf, int len, char *fmt, va_list args);
int concat_buf(struct sbuffer *buf, char *fmt, ...);
int zcu_net_get_host(const char *name, struct addrinfo *res, int ai_family,
int port);
#endif /* _SBUFFER_H_ */
struct addrinfo *zcu_net_get_address(const char *address, int port);
#ifdef __cplusplus
}
#endif
#endif /* _ZCU_NETWORK_H_ */

View File

@ -0,0 +1,55 @@
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_SBUFFER_H_
#define _ZCU_SBUFFER_H_
#include <stdarg.h>
#define ZCU_DEF_BUFFER_SIZE 4096
#define EXTRA_SIZE 1024
struct zcu_buffer {
int size;
int next;
char *data;
};
#ifdef __cplusplus
extern "C" {
#endif
int zcu_buf_get_size(struct zcu_buffer *buf);
char *zcu_buf_get_next(struct zcu_buffer *buf);
int zcu_buf_resize(struct zcu_buffer *buf, int times);
int zcu_buf_create(struct zcu_buffer *buf);
int zcu_buf_isempty(struct zcu_buffer *buf);
char *zcu_buf_get_data(struct zcu_buffer *buf);
int zcu_buf_clean(struct zcu_buffer *buf);
int zcu_buf_reset(struct zcu_buffer *buf);
int zcu_buf_concat_va(struct zcu_buffer *buf, int len, char *fmt, va_list args);
int zcu_buf_concat(struct zcu_buffer *buf, char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif /* _ZCU_SBUFFER_H_ */

View File

@ -1,5 +1,5 @@
/*
* This file is part of nftlb, nftables load balancer.
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
@ -19,30 +19,17 @@
*
*/
#ifndef _TOOLS_H_
#define _TOOLS_H_
#ifndef _ZCU_STRING_H_
#define _ZCU_STRING_H_
#include <syslog.h>
#ifdef __cplusplus
extern "C" {
#endif
#define NFTLB_LOG_LEVEL_DEFAULT LOG_NOTICE
#define NFTLB_LOG_OUTPUT_DEFAULT VALUE_LOG_OUTPUT_SYSLOG
void zcu_str_snprintf(char *strdst, int size, char *strsrc);
#define NFTLB_LOG_OUTPUT_SYSLOG (1 << 0)
#define NFTLB_LOG_OUTPUT_STDOUT (1 << 1)
#define NFTLB_LOG_OUTPUT_STDERR (1 << 2)
#ifdef __cplusplus
}
#endif
enum log_output {
VALUE_LOG_OUTPUT_SYSLOG,
VALUE_LOG_OUTPUT_STDOUT,
VALUE_LOG_OUTPUT_STDERR,
VALUE_LOG_OUTPUT_SYSOUT,
VALUE_LOG_OUTPUT_SYSERR,
};
void tools_snprintf(char *strdst, int size, char *strsrc);
void tools_log_set_level(int loglevel);
void tools_log_set_output(int output);
int tools_printlog(int loglevel, char *fmt, ...);
int tools_log_get_level(void);
#endif /* _TOOLS_H_ */
#endif /* _ZCU_STRING_H_ */

View File

@ -0,0 +1,76 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _ZCU_TIME_H_
#define _ZCU_TIME_H_
#include <sys/time.h>
#include <cstdio>
#include <ctime>
#define TV_TO_MS(x) (x.tv_sec * 1000.0 + x.tv_usec / 1000.0)
#define TV_TO_S(x) (x.tv_sec + x.tv_usec / 1000000.0)
struct Time {
inline static thread_local timeval current_time;
static void updateTime(void)
{
::gettimeofday(&Time::current_time, nullptr);
milliseconds = TV_TO_MS(current_time);
}
static void getTime(timeval &time_val)
{
time_val.tv_sec = current_time.tv_sec;
time_val.tv_usec = current_time.tv_usec;
}
static time_t getTimeSec(void)
{
return TV_TO_S(current_time);
}
static double getTimeMs(void)
{
return milliseconds;
}
static double getDiff(const timeval &start_point)
{
return (milliseconds - TV_TO_MS(start_point)) / 1000.0;
}
static double getElapsed(const timeval &start_point)
{
timeval result{};
result.tv_sec = current_time.tv_sec - start_point.tv_sec;
result.tv_usec = current_time.tv_usec - start_point.tv_usec;
/* Return 1 if result is negative. */
return TV_TO_S(result);
}
private:
inline static thread_local double milliseconds;
};
#endif /* _ZCU_TIME_H_ */

View File

View File

@ -0,0 +1,201 @@
../zcutils/src/zcu_backtrace.o: ../zcutils/src/zcu_backtrace.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_backtrace.h \
/usr/include/execinfo.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
../zcutils/include/zcu_common.h ../zcutils/include/zcu_log.h \
/usr/include/stdio.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/bits/floatn.h \
/usr/include/x86_64-linux-gnu/bits/floatn-common.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
/usr/include/x86_64-linux-gnu/bits/types/time_t.h \
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
/usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h /usr/include/syslog.h \
/usr/include/x86_64-linux-gnu/sys/syslog.h \
/usr/include/x86_64-linux-gnu/bits/syslog-path.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h \
/usr/include/x86_64-linux-gnu/bits/cpu-set.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h /usr/include/string.h \
/usr/include/strings.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_backtrace.h:
/usr/include/execinfo.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/bits/long-double.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
../zcutils/include/zcu_common.h:
../zcutils/include/zcu_log.h:
/usr/include/stdio.h:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/stdlib.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/bits/floatn.h:
/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
/usr/include/syslog.h:
/usr/include/x86_64-linux-gnu/sys/syslog.h:
/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:
/usr/include/string.h:
/usr/include/strings.h:

View File

@ -0,0 +1,193 @@
../zcutils/src/zcu_log.o: ../zcutils/src/zcu_log.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_log.h \
/usr/include/stdio.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/bits/floatn.h \
/usr/include/x86_64-linux-gnu/bits/floatn-common.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
/usr/include/x86_64-linux-gnu/bits/types/time_t.h \
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
/usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h /usr/include/syslog.h \
/usr/include/x86_64-linux-gnu/sys/syslog.h \
/usr/include/x86_64-linux-gnu/bits/syslog-path.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h \
/usr/include/x86_64-linux-gnu/bits/cpu-set.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h /usr/include/string.h \
/usr/include/strings.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_log.h:
/usr/include/stdio.h:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/bits/long-double.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/stdlib.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/bits/floatn.h:
/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
/usr/include/syslog.h:
/usr/include/x86_64-linux-gnu/sys/syslog.h:
/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:
/usr/include/string.h:
/usr/include/strings.h:

View File

@ -0,0 +1,242 @@
../zcutils/src/zcu_network.o: ../zcutils/src/zcu_network.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_network.h \
/usr/include/netdb.h /usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h /usr/include/netinet/in.h \
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/sys/socket.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/socket.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
/usr/include/x86_64-linux-gnu/bits/types/time_t.h \
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
/usr/include/x86_64-linux-gnu/bits/socket_type.h \
/usr/include/x86_64-linux-gnu/bits/sockaddr.h \
/usr/include/x86_64-linux-gnu/asm/socket.h \
/usr/include/asm-generic/socket.h \
/usr/include/x86_64-linux-gnu/asm/sockios.h \
/usr/include/asm-generic/sockios.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_osockaddr.h \
/usr/include/x86_64-linux-gnu/bits/in.h /usr/include/rpc/netdb.h \
/usr/include/x86_64-linux-gnu/bits/netdb.h \
/usr/include/x86_64-linux-gnu/sys/un.h /usr/include/string.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
/usr/include/strings.h ../zcutils/include/zcu_log.h /usr/include/stdio.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/bits/floatn.h \
/usr/include/x86_64-linux-gnu/bits/floatn-common.h /usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h /usr/include/syslog.h \
/usr/include/x86_64-linux-gnu/sys/syslog.h \
/usr/include/x86_64-linux-gnu/bits/syslog-path.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h \
/usr/include/x86_64-linux-gnu/bits/cpu-set.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_network.h:
/usr/include/netdb.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/bits/long-double.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/include/netinet/in.h:
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/sys/socket.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/socket.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
/usr/include/x86_64-linux-gnu/bits/socket_type.h:
/usr/include/x86_64-linux-gnu/bits/sockaddr.h:
/usr/include/x86_64-linux-gnu/asm/socket.h:
/usr/include/asm-generic/socket.h:
/usr/include/x86_64-linux-gnu/asm/sockios.h:
/usr/include/asm-generic/sockios.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_osockaddr.h:
/usr/include/x86_64-linux-gnu/bits/in.h:
/usr/include/rpc/netdb.h:
/usr/include/x86_64-linux-gnu/bits/netdb.h:
/usr/include/x86_64-linux-gnu/sys/un.h:
/usr/include/string.h:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
/usr/include/strings.h:
../zcutils/include/zcu_log.h:
/usr/include/stdio.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/stdlib.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/bits/floatn.h:
/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
/usr/include/syslog.h:
/usr/include/x86_64-linux-gnu/sys/syslog.h:
/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:

View File

@ -0,0 +1,195 @@
../zcutils/src/zcu_sbuffer.o: ../zcutils/src/zcu_sbuffer.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_sbuffer.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
../zcutils/include/zcu_log.h /usr/include/stdio.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/bits/floatn.h \
/usr/include/x86_64-linux-gnu/bits/floatn-common.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
/usr/include/x86_64-linux-gnu/bits/types/time_t.h \
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
/usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h /usr/include/syslog.h \
/usr/include/x86_64-linux-gnu/sys/syslog.h \
/usr/include/x86_64-linux-gnu/bits/syslog-path.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h \
/usr/include/x86_64-linux-gnu/bits/cpu-set.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h /usr/include/string.h \
/usr/include/strings.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_sbuffer.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h:
../zcutils/include/zcu_log.h:
/usr/include/stdio.h:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/bits/long-double.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/stdlib.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/bits/floatn.h:
/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
/usr/include/syslog.h:
/usr/include/x86_64-linux-gnu/sys/syslog.h:
/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:
/usr/include/string.h:
/usr/include/strings.h:

View File

@ -0,0 +1,6 @@
../zcutils/src/zcu_string.o: ../zcutils/src/zcu_string.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_string.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_string.h:

View File

@ -0,0 +1,214 @@
../zcutils/src/zcu_utils.o: ../zcutils/src/zcu_utils.c \
/usr/include/stdc-predef.h ../zcutils/include/zcu_utils.h \
/usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/bits/long-double.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/x86_64-linux-gnu/bits/floatn.h \
/usr/include/x86_64-linux-gnu/bits/floatn-common.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h \
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h \
/usr/include/x86_64-linux-gnu/bits/types/time_t.h \
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h \
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h \
/usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h /usr/include/stdio.h \
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/FILE.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h /usr/include/syslog.h \
/usr/include/x86_64-linux-gnu/sys/syslog.h \
/usr/include/x86_64-linux-gnu/bits/syslog-path.h /usr/include/execinfo.h \
/usr/include/x86_64-linux-gnu/sys/resource.h \
/usr/include/x86_64-linux-gnu/bits/resource.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_rusage.h \
/usr/include/pcreposix.h /usr/include/ctype.h \
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h \
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h \
/usr/include/string.h /usr/include/strings.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h \
/usr/include/x86_64-linux-gnu/bits/cpu-set.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h \
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h \
../zcutils/include/zcu_defines.h ../zcutils/include/zcu_log.h
/usr/include/stdc-predef.h:
../zcutils/include/zcu_utils.h:
/usr/include/stdlib.h:
/usr/include/x86_64-linux-gnu/bits/libc-header-start.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/bits/long-double.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stddef.h:
/usr/include/x86_64-linux-gnu/bits/waitflags.h:
/usr/include/x86_64-linux-gnu/bits/waitstatus.h:
/usr/include/x86_64-linux-gnu/bits/floatn.h:
/usr/include/x86_64-linux-gnu/bits/floatn-common.h:
/usr/include/x86_64-linux-gnu/sys/types.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/x86_64-linux-gnu/bits/types/clock_t.h:
/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h:
/usr/include/x86_64-linux-gnu/bits/types/time_t.h:
/usr/include/x86_64-linux-gnu/bits/types/timer_t.h:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/uintn-identity.h:
/usr/include/x86_64-linux-gnu/sys/select.h:
/usr/include/x86_64-linux-gnu/bits/select.h:
/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h:
/usr/include/alloca.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:
/usr/include/stdio.h:
/usr/lib/gcc/x86_64-linux-gnu/8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__fpos64_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/FILE.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_FILE.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/syslog.h:
/usr/include/x86_64-linux-gnu/sys/syslog.h:
/usr/include/x86_64-linux-gnu/bits/syslog-path.h:
/usr/include/execinfo.h:
/usr/include/x86_64-linux-gnu/sys/resource.h:
/usr/include/x86_64-linux-gnu/bits/resource.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_rusage.h:
/usr/include/pcreposix.h:
/usr/include/ctype.h:
/usr/include/x86_64-linux-gnu/bits/types/locale_t.h:
/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h:
/usr/include/string.h:
/usr/include/strings.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_sched_param.h:
/usr/include/x86_64-linux-gnu/bits/cpu-set.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:
/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:
../zcutils/include/zcu_defines.h:
../zcutils/include/zcu_log.h:

0
zcutils/src/.dirstamp Normal file
View File

View File

@ -0,0 +1,46 @@
/*
* Zevenet zproxy Load Balancer Software License
* This file is part of the Zevenet zproxy Load Balancer software package.
*
* Copyright (C) 2019-today ZEVENET SL, Sevilla (Spain)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "zcu_backtrace.h"
#include <execinfo.h>
#include "zcu_common.h"
#include "zcu_log.h"
void zcu_bt_print_symbols()
{
void *buffer[255];
char **str;
int i;
const int calls = backtrace(buffer, sizeof(buffer) / sizeof(void *));
backtrace_symbols_fd(buffer, calls, 1);
str = backtrace_symbols(buffer, calls);
if (!str) {
zcu_log_print(LOG_ERR, "No backtrace strings found!");
exit(EXIT_FAILURE);
}
for (i = 0; i < calls; i++)
zcu_log_print(LOG_ERR, "Backtrace_symbol: %s", str[i]);
free(str);
}

BIN
zcutils/src/zcu_backtrace.o Normal file

Binary file not shown.

103
zcutils/src/zcu_log.c Normal file
View File

@ -0,0 +1,103 @@
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "zcu_log.h"
char zcu_log_prefix[LOG_PREFIX_BUFSIZE] = "";
int zcu_log_level = ZCUTILS_LOG_LEVEL_DEFAULT;
int zcu_log_output = ZCUTILS_LOG_OUTPUT_DEFAULT;
void zcu_log_set_prefix(const char *string)
{
if (strlen(string) >= LOG_PREFIX_BUFSIZE)
zcu_log_print(
LOG_ERR,
"The farm name is greater than the prefix log: %d >= %d",
strlen(string), LOG_PREFIX_BUFSIZE);
else
memcpy(zcu_log_prefix, string, strlen(string) + 1);
}
void zcu_log_set_level(int loglevel)
{
zcu_log_level = loglevel;
setlogmask(LOG_UPTO(loglevel));
}
int zcu_log_get_level(void)
{
return zcu_log_level;
}
void zcu_log_set_output(int output)
{
switch (output) {
case VALUE_LOG_OUTPUT_STDOUT:
zcu_log_output = ZCUTILS_LOG_OUTPUT_STDOUT;
break;
case VALUE_LOG_OUTPUT_STDERR:
zcu_log_output = ZCUTILS_LOG_OUTPUT_STDERR;
break;
case VALUE_LOG_OUTPUT_SYSOUT:
zcu_log_output =
ZCUTILS_LOG_OUTPUT_SYSLOG | ZCUTILS_LOG_OUTPUT_STDOUT;
break;
case VALUE_LOG_OUTPUT_SYSERR:
zcu_log_output =
ZCUTILS_LOG_OUTPUT_SYSLOG | ZCUTILS_LOG_OUTPUT_STDERR;
break;
case VALUE_LOG_OUTPUT_SYSLOG:
default:
zcu_log_output = ZCUTILS_LOG_OUTPUT_SYSLOG;
}
return;
}
int _zcu_log_print(int loglevel, const char *fmt, ...)
{
va_list args;
if (loglevel > zcu_log_level)
return 0;
if (zcu_log_output & ZCUTILS_LOG_OUTPUT_STDOUT) {
va_start(args, fmt);
vfprintf(stdout, fmt, args);
fprintf(stdout, "\n");
va_end(args);
}
if (zcu_log_output & ZCUTILS_LOG_OUTPUT_STDERR) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
}
if (zcu_log_output & ZCUTILS_LOG_OUTPUT_SYSLOG) {
va_start(args, fmt);
vsyslog(loglevel, fmt, args);
va_end(args);
}
return 0;
}

BIN
zcutils/src/zcu_log.o Normal file

Binary file not shown.

133
zcutils/src/zcu_network.c Normal file
View File

@ -0,0 +1,133 @@
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "zcu_network.h"
#include "zcu_log.h"
#include <stdlib.h>
#include <stdio.h>
#define ZCU_MAX_IDENT 100
int zcu_soc_equal_sockaddr(struct sockaddr *addr1, struct sockaddr *addr2, int compare_port)
{
if (addr1->sa_family != addr2->sa_family)
return 0;
if (addr1->sa_family == AF_UNIX) {
struct sockaddr_un *a1_un = (struct sockaddr_un *)addr1;
struct sockaddr_un *a2_un = (struct sockaddr_un *)addr2;
int r = strcmp(a1_un->sun_path, a2_un->sun_path);
if (r != 0)
return 1;
} else if (addr1->sa_family == AF_INET) {
struct sockaddr_in *a1_in = (struct sockaddr_in *)addr1;
struct sockaddr_in *a2_in = (struct sockaddr_in *)addr2;
if (ntohl(a1_in->sin_addr.s_addr) !=
ntohl(a2_in->sin_addr.s_addr))
return 0;
if (compare_port &&
ntohs(a1_in->sin_port) != ntohs(a2_in->sin_port))
return 0;
} else if (addr1->sa_family == AF_INET6) {
struct sockaddr_in6 *a1_in6 = (struct sockaddr_in6 *)addr1;
struct sockaddr_in6 *a2_in6 = (struct sockaddr_in6 *)addr2;
int r = memcmp(a1_in6->sin6_addr.s6_addr,
a2_in6->sin6_addr.s6_addr,
sizeof(a1_in6->sin6_addr.s6_addr));
if (r != 0)
return r;
if (compare_port &&
ntohs(a1_in6->sin6_port) != ntohs(a2_in6->sin6_port))
return 0;
if (a1_in6->sin6_flowinfo != a2_in6->sin6_flowinfo)
return 0;
if (a1_in6->sin6_scope_id != a2_in6->sin6_scope_id)
return 0;
} else {
return 0;
}
return 1;
}
/*
* Search for a host name, return the addrinfo for it
*/
int zcu_net_get_host(const char *name, struct addrinfo *res, int ai_family, int port)
{
struct addrinfo *chain, *ap;
struct addrinfo hints;
int ret_val;
char port_str[ZCU_MAX_IDENT] = { 0 };
memset(&hints, 0, sizeof(hints));
hints.ai_family = ai_family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
if (port > 0)
snprintf(port_str, ZCU_MAX_IDENT, "%d", port);
if ((ret_val = getaddrinfo(name, port_str, &hints, &chain)) == 0) {
for (ap = chain; ap != NULL; ap = ap->ai_next)
if (ap->ai_socktype == SOCK_STREAM)
break;
if (ap == NULL) {
freeaddrinfo(chain);
return EAI_NONAME;
}
*res = *ap;
if (((res->ai_addr = (struct sockaddr *)malloc(ap->ai_addrlen))) == NULL) {
freeaddrinfo(chain);
return EAI_MEMORY;
}
memcpy(res->ai_addr, ap->ai_addr, ap->ai_addrlen);
freeaddrinfo(chain);
}
return ret_val;
}
struct addrinfo *zcu_net_get_address(const char *address, int port)
{
struct addrinfo hints;
struct addrinfo *result = NULL;
int sfd;
char port_str[ZCU_MAX_IDENT] = { 0 };
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_STREAM; /* Datagram socket */
hints.ai_flags = AI_CANONNAME;
hints.ai_protocol = 0; /* Any protocol */
hints.ai_canonname = NULL;
hints.ai_addr = NULL;
hints.ai_next = NULL;
if (port > 0)
snprintf(port_str, ZCU_MAX_IDENT, "%d", port);
sfd = getaddrinfo(address, port_str, &hints, &result);
if (sfd != 0) {
zcu_log_print(LOG_NOTICE, "%s():%d: getaddrinfo: %s",
__FUNCTION__, __LINE__, gai_strerror(sfd));
return NULL;
}
return result;
}

BIN
zcutils/src/zcu_network.o Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
/*
* This file is part of nftlb, nftables load balancer.
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
@ -19,24 +19,20 @@
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zcu_sbuffer.h"
#include "zcu_log.h"
#include "sbuffer.h"
#include "tools.h"
int get_buf_size(struct sbuffer *buf)
int zcu_buf_get_size(struct zcu_buffer *buf)
{
return buf->size;
}
char * get_buf_next(struct sbuffer *buf)
char *zcu_buf_get_next(struct zcu_buffer *buf)
{
return buf->data + buf->next;
}
int resize_buf(struct sbuffer *buf, int times)
int zcu_buf_resize(struct zcu_buffer *buf, int times)
{
char *pbuf;
int newsize;
@ -49,7 +45,7 @@ int resize_buf(struct sbuffer *buf, int times)
if (!buf->data)
return 1;
pbuf = (char *) realloc(buf->data, newsize);
pbuf = (char *)realloc(buf->data, newsize);
if (!pbuf)
return 1;
@ -58,32 +54,32 @@ int resize_buf(struct sbuffer *buf, int times)
return 0;
}
int create_buf(struct sbuffer *buf)
int zcu_buf_create(struct zcu_buffer *buf)
{
buf->size = 0;
buf->next = 0;
buf->data = (char *) calloc(1, DEFAULT_BUFFER_SIZE);
buf->data = (char *)calloc(1, ZCU_DEF_BUFFER_SIZE);
if (!buf->data) {
return 1;
}
*buf->data = '\0';
buf->size = DEFAULT_BUFFER_SIZE;
buf->size = ZCU_DEF_BUFFER_SIZE;
return 0;
}
int isempty_buf(struct sbuffer *buf)
int zcu_buf_isempty(struct zcu_buffer *buf)
{
return (buf->data[0] == 0);
}
char *get_buf_data(struct sbuffer *buf)
char *zcu_buf_get_data(struct zcu_buffer *buf)
{
return buf->data;
}
int clean_buf(struct sbuffer *buf)
int zcu_buf_clean(struct zcu_buffer *buf)
{
if (buf->data)
free(buf->data);
@ -92,14 +88,14 @@ int clean_buf(struct sbuffer *buf)
return 0;
}
int reset_buf(struct sbuffer *buf)
int zcu_buf_reset(struct zcu_buffer *buf)
{
buf->data[0] = 0;
buf->next = 0;
return 0;
}
int concat_buf_va(struct sbuffer *buf, int len, char *fmt, va_list args)
int zcu_buf_concat_va(struct zcu_buffer *buf, int len, char *fmt, va_list args)
{
int times = 0;
char *pnext;
@ -107,19 +103,22 @@ int concat_buf_va(struct sbuffer *buf, int len, char *fmt, va_list args)
if (buf->next + len >= buf->size)
times = ((buf->next + len - buf->size) / EXTRA_SIZE) + 1;
if (resize_buf(buf, times)) {
tools_printlog(LOG_ERR, "Error resizing the buffer %d times from a size of %d!", times, buf->size);
if (zcu_buf_resize(buf, times)) {
zcu_log_print(
LOG_ERR,
"Error resizing the buffer %d times from a size of %d!",
times, buf->size);
return 1;
}
pnext = get_buf_next(buf);
pnext = zcu_buf_get_next(buf);
vsnprintf(pnext, len + 1, fmt, args);
buf->next += len;
return 0;
}
int concat_buf(struct sbuffer *buf, char *fmt, ...)
int zcu_buf_concat(struct zcu_buffer *buf, char *fmt, ...)
{
int len;
va_list args;
@ -129,7 +128,7 @@ int concat_buf(struct sbuffer *buf, char *fmt, ...)
va_end(args);
va_start(args, fmt);
concat_buf_va(buf, len, fmt, args);
zcu_buf_concat_va(buf, len, fmt, args);
va_end(args);
return 0;

BIN
zcutils/src/zcu_sbuffer.o Normal file

Binary file not shown.

30
zcutils/src/zcu_string.c Normal file
View File

@ -0,0 +1,30 @@
/*
* This file is part of zcutils, ZEVENET Core Utils.
*
* Copyright (C) ZEVENET SL.
* Author: Laura Garcia <laura.garcia@zevenet.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "zcu_string.h"
void zcu_str_snprintf(char *strdst, int size, char *strsrc)
{
for (int i = 0; i < size; i++) {
strdst[i] = *(strsrc + i);
}
strdst[size] = '\0';
}

BIN
zcutils/src/zcu_string.o Normal file

Binary file not shown.