#ifndef TRANSPORT_INTERNAL_H
#define TRANSPORT_INTERNAL_H
/**
* @file
*
* The internal interface for transport implementations.
*/
#include "transport.h"
/**
* Method table for implementation stuff
*/
struct transport_methods {
/** For transport_read() */
err_t (*read) (transport_t *transport, void *buf, size_t *len, error_t *err);
/** For transport_write() */
err_t (*write) (transport_t *transport, const void *buf, size_t *len, error_t *err);
/** Release the transport's state, but not the transport itself */
void (*destroy) (transport_t *transport);
};
/**
* The definition of a transport type
*/
struct transport_type {
/** Method table */
struct transport_methods methods;
};
/**
* The base transport type
*/
struct transport {
/** The type info, or NULL if not yet bound */
const struct transport_type *type;
/** User info */
struct transport_info info;
};
/**
* Bind the given transport to the given type with the given user info.
*
* It is a bug to call this with a transport that is already bound.
*/
void transport_bind (transport_t *transport, const struct transport_type *type, const struct transport_info *info);
/**
* Check the type of the transport, and return the transport as a void* suitable for casting to the appropriate struct
* for the type.
*
* It is a bug to call this with a transport of a different type.
*/
void* transport_check (transport_t *transport, const struct transport_type *type);
#endif /* TRANSPORT_INTERNAL_H */