Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
76b4da08
Commit
76b4da08
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
c wrapper: add dht_runner_get_public_address
parent
2a722771
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
c/opendht.cpp
+19
-0
19 additions, 0 deletions
c/opendht.cpp
c/opendht_c.h
+3
-0
3 additions, 0 deletions
c/opendht_c.h
with
22 additions
and
0 deletions
c/opendht.cpp
+
19
−
0
View file @
76b4da08
...
@@ -294,6 +294,25 @@ dht_infohash dht_runner_get_id(const dht_runner* r) {
...
@@ -294,6 +294,25 @@ dht_infohash dht_runner_get_id(const dht_runner* r) {
return
ret
;
return
ret
;
}
}
const
struct
sockaddr
**
dht_runner_get_public_address
(
const
dht_runner
*
r
)
{
auto
runner
=
reinterpret_cast
<
const
dht
::
DhtRunner
*>
(
r
);
auto
addrs
=
const_cast
<
dht
::
DhtRunner
*>
(
runner
)
->
getPublicAddress
();
if
(
addrs
.
empty
())
return
nullptr
;
auto
ret
=
(
const
struct
sockaddr
**
)
malloc
(
sizeof
(
struct
sockaddr
*
)
*
(
addrs
.
size
()
+
1
));
for
(
size_t
i
=
0
;
i
<
addrs
.
size
();
i
++
)
{
if
(
auto
len
=
addrs
[
i
].
getLength
())
{
ret
[
i
]
=
(
const
struct
sockaddr
*
)
malloc
(
len
);
memcpy
((
struct
sockaddr
*
)
ret
[
i
],
addrs
[
i
].
get
(),
len
);
}
else
{
ret
[
i
]
=
nullptr
;
}
}
ret
[
addrs
.
size
()]
=
nullptr
;
return
ret
;
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
This diff is collapsed.
Click to expand it.
c/opendht_c.h
+
3
−
0
View file @
76b4da08
...
@@ -11,6 +11,8 @@ extern "C" {
...
@@ -11,6 +11,8 @@ extern "C" {
#include
<stdint.h>
#include
<stdint.h>
#include
<stddef.h>
#include
<stddef.h>
struct
sockaddr
;
// Non-owning data view
// Non-owning data view
struct
OPENDHT_C_PUBLIC
dht_data_view
{
struct
OPENDHT_C_PUBLIC
dht_data_view
{
const
uint8_t
*
data
;
const
uint8_t
*
data
;
...
@@ -137,6 +139,7 @@ OPENDHT_C_PUBLIC void dht_runner_cancel_put(dht_runner* runner, const dht_infoha
...
@@ -137,6 +139,7 @@ OPENDHT_C_PUBLIC void dht_runner_cancel_put(dht_runner* runner, const dht_infoha
OPENDHT_C_PUBLIC
void
dht_runner_shutdown
(
dht_runner
*
runner
,
dht_shutdown_cb
done_cb
,
void
*
cb_user_data
);
OPENDHT_C_PUBLIC
void
dht_runner_shutdown
(
dht_runner
*
runner
,
dht_shutdown_cb
done_cb
,
void
*
cb_user_data
);
OPENDHT_C_PUBLIC
dht_infohash
dht_runner_get_node_id
(
const
dht_runner
*
runner
);
OPENDHT_C_PUBLIC
dht_infohash
dht_runner_get_node_id
(
const
dht_runner
*
runner
);
OPENDHT_C_PUBLIC
dht_infohash
dht_runner_get_id
(
const
dht_runner
*
runner
);
OPENDHT_C_PUBLIC
dht_infohash
dht_runner_get_id
(
const
dht_runner
*
runner
);
OPENDHT_C_PUBLIC
const
struct
sockaddr
**
dht_runner_get_public_address
(
const
dht_runner
*
runner
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment