working commit
This commit is contained in:
+3
-4
@@ -21,7 +21,7 @@ extern "C" {
|
||||
|
||||
#include <iprouter.hpp>
|
||||
|
||||
std::expected<void, std::string> Router::AddRoute(std::string address, uint64_t prefix, std::string gateway) {
|
||||
std::expected<void, std::string> Router::AddRoute(std::string address, uint64_t prefix, std::string gateway, std::string dev) {
|
||||
struct sockaddr_in sa;
|
||||
if (inet_pton(AF_INET, address.data(), &(sa.sin_addr)) == 1) {
|
||||
} else {
|
||||
@@ -49,8 +49,7 @@ std::expected<void, std::string> Router::AddRoute(std::string address, uint64_t
|
||||
};
|
||||
|
||||
char buffer[INET_ADDRSTRLEN];
|
||||
uint32_t mask = (prefix == 0) ? 0 : htonl(~((1U << (32 - prefix)) - 1));
|
||||
//uint32_t mask = (prefix == 0) ? 0 : (~0U << (32 - prefix));
|
||||
uint32_t mask = (prefix == 0) ? 0 : (~0U << (32 - prefix));
|
||||
|
||||
struct in_addr addr;
|
||||
addr.s_addr = mask;
|
||||
@@ -71,7 +70,7 @@ std::expected<void, std::string> Router::AddRoute(std::string address, uint64_t
|
||||
};
|
||||
|
||||
rt.rt_flags = RTF_UP | RTF_GATEWAY;
|
||||
//rt.rt_dev = std::string("eth0").data();
|
||||
//rt.rt_dev = dev.data();
|
||||
|
||||
int sockfd = 0;
|
||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
|
||||
Reference in New Issue
Block a user