Commit 7a8aaf28 authored by Niuhaiwen's avatar Niuhaiwen

support register to nrf and heart-beat

parent 4a5d1491
......@@ -45,7 +45,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
int rv = RETURNok;
if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) {
Logger::system().error("socket raw/NETLINK_ROUTE failed");
Logger::udr_app().error("socket raw/NETLINK_ROUTE failed");
return EXIT_FAILURE;
}
......@@ -72,7 +72,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
sizeof(struct timeval));
/* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) {
Logger::system().error("send socket raw/NETLINK_ROUTE failed");
Logger::udr_app().error("send socket raw/NETLINK_ROUTE failed");
return EXIT_FAILURE;
}
......@@ -80,7 +80,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
do {
received_bytes = recv(sock, ptr, sizeof(buffer) - msg_len, 0);
if (received_bytes < 0) {
Logger::system().error("recv socket raw/NETLINK_ROUTE failed");
Logger::udr_app().error("recv socket raw/NETLINK_ROUTE failed");
return EXIT_FAILURE;
}
......@@ -89,7 +89,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
/* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) ||
(nlmsg->nlmsg_type == NLMSG_ERROR)) {
Logger::system().error("recv msg raw/NETLINK_ROUTE failed");
Logger::udr_app().error("recv msg raw/NETLINK_ROUTE failed");
return EXIT_FAILURE;
}
......@@ -161,7 +161,7 @@ int get_inet_addr_from_iface(const std::string &if_name,
strcpy(ifr.ifr_name, (const char *)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n",
Logger::udr_app().error("Failed to probe %s inet addr: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror;
}
......@@ -185,7 +185,7 @@ int get_mtu_from_iface(const std::string &if_name, uint32_t &mtu) {
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFMTU, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s MTU: error %s\n",
Logger::udr_app().error("Failed to probe %s MTU: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror;
}
......@@ -213,7 +213,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name,
strcpy(ifr.ifr_name, (const char *)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n",
Logger::udr_app().error("Failed to probe %s inet addr: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror;
}
......@@ -231,7 +231,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name,
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFNETMASK, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet netmask: error %s\n",
Logger::udr_app().error("Failed to probe %s inet netmask: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror;
}
......@@ -248,7 +248,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name,
ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFMTU, &ifr)) {
Logger::system().error("Failed to probe %s MTU: error %s\n",
Logger::udr_app().error("Failed to probe %s MTU: error %s\n",
if_name.c_str(), strerror(errno));
} else {
mtu = ifr.ifr_mtu;
......
#include "udr_config.hpp"
#include <arpa/inet.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <iostream>
#include <libconfig.h++>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
......@@ -7,21 +16,9 @@
#include <net/if.h>
#include <net/if_arp.h>
#include <arpa/inet.h>
#include <iostream>
#include <libconfig.h++>
#include <stdio.h>
#include <errno.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <iostream>
#include <libconfig.h++>
#include <arpa/inet.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string>
#include "if.hpp"
#include "string.hpp"
#include "logger.hpp"
#include "common_defs.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment