ng_netapi: introduce ng_netapi_receive()

This commit is contained in:
Martine Lenders 2015-03-20 19:21:44 +01:00 committed by Martine Lenders
parent 6a31fa80a7
commit 326a402148
2 changed files with 24 additions and 3 deletions

View File

@ -83,6 +83,17 @@ typedef struct {
*/
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
* parsing the returned @ref NG_NETAPI_MSG_TYPE_ACK message

View File

@ -54,16 +54,26 @@ static inline int _get_set(kernel_pid_t pid, uint16_t type,
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;
/* set the outgoing message's fields */
msg.type = NG_NETAPI_MSG_TYPE_SND;
msg.type = type;
msg.content.ptr = (void *)pkt;
/* send data using netapi */
/* send message */
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,
void *data, size_t data_len)
{