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) { ...@@ -45,7 +45,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
int rv = RETURNok; int rv = RETURNok;
if ((sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) < 0) { 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; return EXIT_FAILURE;
} }
...@@ -72,7 +72,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) { ...@@ -72,7 +72,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
sizeof(struct timeval)); sizeof(struct timeval));
/* send msg */ /* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) { 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; return EXIT_FAILURE;
} }
...@@ -80,7 +80,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) { ...@@ -80,7 +80,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
do { do {
received_bytes = recv(sock, ptr, sizeof(buffer) - msg_len, 0); received_bytes = recv(sock, ptr, sizeof(buffer) - msg_len, 0);
if (received_bytes < 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; return EXIT_FAILURE;
} }
...@@ -89,7 +89,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) { ...@@ -89,7 +89,7 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
/* Check if the header is valid */ /* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) || if ((NLMSG_OK(nlmsg, received_bytes) == 0) ||
(nlmsg->nlmsg_type == NLMSG_ERROR)) { (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; return EXIT_FAILURE;
} }
...@@ -161,7 +161,7 @@ int get_inet_addr_from_iface(const std::string &if_name, ...@@ -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()); strcpy(ifr.ifr_name, (const char *)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) { if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd); 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)); if_name.c_str(), strerror(errno));
return RETURNerror; return RETURNerror;
} }
...@@ -185,7 +185,7 @@ int get_mtu_from_iface(const std::string &if_name, uint32_t &mtu) { ...@@ -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); strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFMTU, &ifr)) { if (ioctl(fd, SIOCGIFMTU, &ifr)) {
close(fd); 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)); if_name.c_str(), strerror(errno));
return RETURNerror; return RETURNerror;
} }
...@@ -213,7 +213,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, ...@@ -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()); strcpy(ifr.ifr_name, (const char *)if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) { if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd); 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)); if_name.c_str(), strerror(errno));
return RETURNerror; return RETURNerror;
} }
...@@ -231,7 +231,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, ...@@ -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); strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFNETMASK, &ifr)) { if (ioctl(fd, SIOCGIFNETMASK, &ifr)) {
close(fd); 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)); if_name.c_str(), strerror(errno));
return RETURNerror; return RETURNerror;
} }
...@@ -248,7 +248,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, ...@@ -248,7 +248,7 @@ int get_inet_addr_infos_from_iface(const std::string &if_name,
ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_addr.sa_family = AF_INET;
strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1); strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ - 1);
if (ioctl(fd, SIOCGIFMTU, &ifr)) { 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)); if_name.c_str(), strerror(errno));
} else { } else {
mtu = ifr.ifr_mtu; mtu = ifr.ifr_mtu;
......
#include "udr_config.hpp" #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/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -7,21 +16,9 @@ ...@@ -7,21 +16,9 @@
#include <net/if.h> #include <net/if.h>
#include <net/if_arp.h> #include <net/if_arp.h>
#include <arpa/inet.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 "string.hpp"
#include "logger.hpp" #include "logger.hpp"
#include "common_defs.h" #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