aos/include/aos/nameserver.h
Daniel Schwyn 6d444bf552 Main handout
Signed-off-by: Daniel Schwyn <daniel.schwyn@inf.ethz.ch>
2022-03-03 14:57:51 +01:00

82 lines
2.2 KiB
C

/**
* \file nameservice.h
* \brief
*/
#ifndef INCLUDE_NAMESERVICE_H_
#define INCLUDE_NAMESERVICE_H_
#include <aos/aos.h>
typedef void* nameservice_chan_t;
///< handler which is called when a message is received over the registered channel
typedef void(nameservice_receive_handler_t)(void *st,
void *message, size_t bytes,
void **response, size_t *response_bytes,
struct capref tx_cap, struct capref *rx_cap);
/**
* @brief sends a message back to the client who sent us a message
*
* @param chan opaque handle of the channel
* @oaram message pointer to the message
* @param bytes size of the message in bytes
* @param response the response message
* @param response_byts the size of the response
*
* @return error value
*/
errval_t nameservice_rpc(nameservice_chan_t chan, void *message, size_t bytes,
void **response, size_t *response_bytes,
struct capref tx_cap, struct capref rx_cap);
/**
* @brief registers our selves as 'name'
*
* @param name our name
* @param recv_handler the message handler for messages received over this service
* @param st state passed to the receive handler
*
* @return SYS_ERR_OK
*/
errval_t nameservice_register(const char *name,
nameservice_receive_handler_t recv_handler,
void *st);
/**
* @brief deregisters the service 'name'
*
* @param the name to deregister
*
* @return error value
*/
errval_t nameservice_deregister(const char *name);
/**
* @brief lookup an endpoint and obtain an RPC channel to that
*
* @param name name to lookup
* @param chan pointer to the chan representation to send messages to the service
*
* @return SYS_ERR_OK on success, errval on failure
*/
errval_t nameservice_lookup(const char *name, nameservice_chan_t *chan);
/**
* @brief enumerates all entries that match an query (prefix match)
*
* @param query the query
* @param num number of entries in the result array
* @param result an array of entries
*/
errval_t nameservice_enumerate(char *query, size_t *num, char **result );
#endif /* INCLUDE_AOS_AOS_NAMESERVICE_H_ */