Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
cm-projects
RIOT
Commits
59f62e53
Commit
59f62e53
authored
9 years ago
by
Martine Lenders
Browse files
Options
Downloads
Patches
Plain Diff
ng_netapi: centralize packet dispatchment for RCV and SND
parent
3b814fdf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/include/net/ng_netapi.h
+27
-0
27 additions, 0 deletions
sys/include/net/ng_netapi.h
sys/net/crosslayer/ng_netapi/ng_netapi.c
+33
-0
33 additions, 0 deletions
sys/net/crosslayer/ng_netapi/ng_netapi.c
with
60 additions
and
0 deletions
sys/include/net/ng_netapi.h
+
27
−
0
View file @
59f62e53
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include
"kernel.h"
#include
"kernel.h"
#include
"thread.h"
#include
"thread.h"
#include
"net/ng_netconf.h"
#include
"net/ng_netconf.h"
#include
"net/ng_nettype.h"
#include
"net/ng_pkt.h"
#include
"net/ng_pkt.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -83,6 +84,19 @@ typedef struct {
...
@@ -83,6 +84,19 @@ typedef struct {
*/
*/
int
ng_netapi_send
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
);
int
ng_netapi_send
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
);
/**
* @brief Sends a @ref NG_NETAPI_MSG_TYPE_SND command to all subscribers to
* (@p type, @p demux_ctx).
*
* @param[in] type type of the targeted network module.
* @param[in] demux_ctx demultiplexing context for @p type.
* @param[in] pkt pointer into the packet buffer holding the data to send
*
* @return Number of subscribers to (@p type, @p demux_ctx).
*/
int
ng_netapi_dispatch_send
(
ng_nettype_t
type
,
uint32_t
demux_ctx
,
ng_pktsnip_t
*
pkt
);
/**
/**
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_RCV messages
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_RCV messages
*
*
...
@@ -94,6 +108,19 @@ int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt);
...
@@ -94,6 +108,19 @@ int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt);
*/
*/
int
ng_netapi_receive
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
);
int
ng_netapi_receive
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
);
/**
* @brief Sends a @ref NG_NETAPI_MSG_TYPE_RCV command to all subscribers to
* (@p type, @p demux_ctx).
*
* @param[in] type type of the targeted network module.
* @param[in] demux_ctx demultiplexing context for @p type.
* @param[in] pkt pointer into the packet buffer holding the data to send
*
* @return Number of subscribers to (@p type, @p demux_ctx).
*/
int
ng_netapi_dispatch_receive
(
ng_nettype_t
type
,
uint32_t
demux_ctx
,
ng_pktsnip_t
*
pkt
);
/**
/**
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_GET messages and
* @brief Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_GET messages and
* parsing the returned @ref NG_NETAPI_MSG_TYPE_ACK message
* parsing the returned @ref NG_NETAPI_MSG_TYPE_ACK message
...
...
This diff is collapsed.
Click to expand it.
sys/net/crosslayer/ng_netapi/ng_netapi.c
+
33
−
0
View file @
59f62e53
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#include
"kernel.h"
#include
"kernel.h"
#include
"msg.h"
#include
"msg.h"
#include
"net/ng_netreg.h"
#include
"net/ng_pktbuf.h"
#include
"net/ng_netapi.h"
#include
"net/ng_netapi.h"
/**
/**
...
@@ -64,16 +66,47 @@ static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, ng_pktsnip_t *pkt)
...
@@ -64,16 +66,47 @@ static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, ng_pktsnip_t *pkt)
return
msg_send
(
&
msg
,
pid
);
return
msg_send
(
&
msg
,
pid
);
}
}
static
inline
int
_snd_rcv_dispatch
(
ng_nettype_t
type
,
uint32_t
demux_ctx
,
uint16_t
cmd
,
ng_pktsnip_t
*
pkt
)
{
int
numof
=
ng_netreg_num
(
type
,
demux_ctx
);
ng_netreg_entry_t
*
sendto
;
if
(
numof
!=
0
)
{
sendto
=
ng_netreg_lookup
(
type
,
demux_ctx
);
ng_pktbuf_hold
(
pkt
,
numof
-
1
);
while
(
sendto
)
{
_snd_rcv
(
sendto
->
pid
,
cmd
,
pkt
);
sendto
=
ng_netreg_getnext
(
sendto
);
}
}
return
numof
;
}
int
ng_netapi_send
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
)
int
ng_netapi_send
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
)
{
{
return
_snd_rcv
(
pid
,
NG_NETAPI_MSG_TYPE_SND
,
pkt
);
return
_snd_rcv
(
pid
,
NG_NETAPI_MSG_TYPE_SND
,
pkt
);
}
}
int
ng_netapi_dispatch_send
(
ng_nettype_t
type
,
uint32_t
demux_ctx
,
ng_pktsnip_t
*
pkt
)
{
return
_snd_rcv_dispatch
(
type
,
demux_ctx
,
NG_NETAPI_MSG_TYPE_SND
,
pkt
);
}
int
ng_netapi_receive
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
)
int
ng_netapi_receive
(
kernel_pid_t
pid
,
ng_pktsnip_t
*
pkt
)
{
{
return
_snd_rcv
(
pid
,
NG_NETAPI_MSG_TYPE_RCV
,
pkt
);
return
_snd_rcv
(
pid
,
NG_NETAPI_MSG_TYPE_RCV
,
pkt
);
}
}
int
ng_netapi_dispatch_receive
(
ng_nettype_t
type
,
uint32_t
demux_ctx
,
ng_pktsnip_t
*
pkt
)
{
return
_snd_rcv_dispatch
(
type
,
demux_ctx
,
NG_NETAPI_MSG_TYPE_RCV
,
pkt
);
}
int
ng_netapi_get
(
kernel_pid_t
pid
,
ng_netconf_opt_t
opt
,
uint16_t
context
,
int
ng_netapi_get
(
kernel_pid_t
pid
,
ng_netconf_opt_t
opt
,
uint16_t
context
,
void
*
data
,
size_t
data_len
)
void
*
data
,
size_t
data_len
)
{
{
...
...
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