Added configuration parameters

Added configuration parameters and feedback_setup_info creation
This commit is contained in:
MassimilianoPinto
2015-03-03 10:25:44 +01:00
parent efda82cbf3
commit 7427afeb65
2 changed files with 96 additions and 9 deletions

View File

@ -58,6 +58,8 @@
#include <skygw_utils.h>
#include <log_manager.h>
#include <mysql.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <notification.h>
/** Defined in log_manager.cc */
@ -1277,10 +1279,22 @@ int i;
{
feedback.feedback_enable = atoi(value);
}
else if (strcmp(name, "feedback_user_info") == 0)
{
feedback.feedback_user_info = strdup(value);
}
else if (strcmp(name, "feedback_url") == 0)
{
feedback.feedback_enable = atoi(value);
feedback.feedback_url = strdup(value);
}
if (strcmp(name, "feedback_timeout") == 0)
{
feedback.feedback_timeout = atoi(value);
}
if (strcmp(name, "feedback_connect_timeout") == 0)
{
feedback.feedback_connect_timeout = atoi(value);
}
return 1;
}
@ -1308,6 +1322,11 @@ feedback_defaults()
{
feedback.feedback_enable = 0;
feedback.feedback_last_action = 0;
feedback.feedback_timeout = 30;
feedback.feedback_connect_timeout = 30;
feedback.feedback_url = NULL;
feedback.feedback_setup_info = strdup("10000-eee-AAA-444");
feedback.feedback_user_info = NULL;
}
/**
@ -1928,3 +1947,38 @@ int i;
}
return 0;
}
int config_get_ifaddr(unsigned char *output)
{
struct ifreq ifr;
struct ifconf ifc;
char buf[1024];
int success = 0;
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sock == -1) { /* handle error*/ };
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl(sock, SIOCGIFCONF, &ifc) == -1) { /* handle error */ }
struct ifreq* it = ifc.ifc_req;
const struct ifreq* const end = it + (ifc.ifc_len / sizeof(struct ifreq));
for (; it != end; ++it) {
strcpy(ifr.ifr_name, it->ifr_name);
if (ioctl(sock, SIOCGIFFLAGS, &ifr) == 0) {
if (! (ifr.ifr_flags & IFF_LOOPBACK)) { // don't count loopback
if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0) {
success = 1;
break;
}
}
}
else { /* handle error */ }
}
if (success) memcpy(output, ifr.ifr_hwaddr.sa_data, 6);
return success;
}