Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-UDR
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-UDR
Commits
7a8aaf28
Commit
7a8aaf28
authored
Jul 16, 2021
by
Niuhaiwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support register to nrf and heart-beat
parent
4a5d1491
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
23 deletions
+20
-23
src/common/if.cpp
src/common/if.cpp
+9
-9
src/udr_app/udr_config.cpp
src/udr_app/udr_config.cpp
+11
-14
No files found.
src/common/if.cpp
View file @
7a8aaf28
...
...
@@ -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
;
...
...
src/udr_app/udr_config.cpp
View file @
7a8aaf28
#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"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment