ng_netapi: introduce ng_netapi_receive()
This commit is contained in:
parent
6a31fa80a7
commit
326a402148
@ -83,6 +83,17 @@ 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 Shortcut function for sending @ref NG_NETAPI_MSG_TYPE_RCV messages
|
||||||
|
*
|
||||||
|
* @param[in] pid PID of the targeted network module
|
||||||
|
* @param[in] pkt pointer into the packet buffer holding the received data
|
||||||
|
*
|
||||||
|
* @return 1 if packet was successfully delivered
|
||||||
|
* @return -1 on error (invalid PID or no space in queue)
|
||||||
|
*/
|
||||||
|
int ng_netapi_receive(kernel_pid_t pid, 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
|
||||||
|
|||||||
@ -54,16 +54,26 @@ static inline int _get_set(kernel_pid_t pid, uint16_t type,
|
|||||||
return (int)ack.content.value;
|
return (int)ack.content.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt)
|
static inline int _snd_rcv(kernel_pid_t pid, uint16_t type, ng_pktsnip_t *pkt)
|
||||||
{
|
{
|
||||||
msg_t msg;
|
msg_t msg;
|
||||||
/* set the outgoing message's fields */
|
/* set the outgoing message's fields */
|
||||||
msg.type = NG_NETAPI_MSG_TYPE_SND;
|
msg.type = type;
|
||||||
msg.content.ptr = (void *)pkt;
|
msg.content.ptr = (void *)pkt;
|
||||||
/* send data using netapi */
|
/* send message */
|
||||||
return msg_send(&msg, pid);
|
return msg_send(&msg, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ng_netapi_send(kernel_pid_t pid, ng_pktsnip_t *pkt)
|
||||||
|
{
|
||||||
|
return _snd_rcv(pid, NG_NETAPI_MSG_TYPE_SND, pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ng_netapi_receive(kernel_pid_t pid, ng_pktsnip_t *pkt)
|
||||||
|
{
|
||||||
|
return _snd_rcv(pid, 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)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user