mirror of https://github.com/ARMmbed/mbed-os.git
commit
d84bf7fc43
|
@ -112,7 +112,8 @@ public:
|
|||
*/
|
||||
virtual const char *get_gateway() = 0;
|
||||
|
||||
virtual CellularBase *cellularBase() {
|
||||
virtual CellularBase *cellularBase()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t gethostbyname(const char *host,
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
||||
|
||||
/** Hostname translation callback (asynchronous)
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
* and can be passed to cancel
|
||||
*/
|
||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
|
||||
nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
||||
nsapi_version_t version = NSAPI_UNSPEC) = 0;
|
||||
|
||||
/** Cancels asynchronous hostname translation
|
||||
*
|
||||
|
|
|
@ -61,11 +61,11 @@ nsapi_error_t EMACInterface::connect()
|
|||
}
|
||||
|
||||
return _interface->bringup(_dhcp,
|
||||
_ip_address[0] ? _ip_address : 0,
|
||||
_netmask[0] ? _netmask : 0,
|
||||
_gateway[0] ? _gateway : 0,
|
||||
DEFAULT_STACK,
|
||||
_blocking);
|
||||
_ip_address[0] ? _ip_address : 0,
|
||||
_netmask[0] ? _netmask : 0,
|
||||
_gateway[0] ? _gateway : 0,
|
||||
DEFAULT_STACK,
|
||||
_blocking);
|
||||
}
|
||||
|
||||
nsapi_error_t EMACInterface::disconnect()
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
* the credentials have been set. This is necessary to support specialised
|
||||
* applications such as 6LoWPAN mesh border routers.
|
||||
*/
|
||||
class EMACInterface : public virtual NetworkInterface
|
||||
{
|
||||
class EMACInterface : public virtual NetworkInterface {
|
||||
public:
|
||||
/** Create an EMAC-based network interface.
|
||||
*
|
||||
|
@ -52,9 +51,8 @@ public:
|
|||
* @param emac Reference to EMAC to use
|
||||
* @param stack Reference to onboard-network stack to use
|
||||
*/
|
||||
EMACInterface(
|
||||
EMAC &emac = EMAC::get_default_instance(),
|
||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
||||
EMACInterface(EMAC &emac = EMAC::get_default_instance(),
|
||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
||||
|
||||
/** Set a static IP address
|
||||
*
|
||||
|
@ -67,8 +65,7 @@ public:
|
|||
* @param gateway Null-terminated representation of the local gateway
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t set_network(
|
||||
const char *ip_address, const char *netmask, const char *gateway);
|
||||
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
|
||||
|
||||
/** Enable or disable DHCP on the network
|
||||
*
|
||||
|
@ -94,7 +91,7 @@ public:
|
|||
* Provided MAC address is intended for info or debug purposes and
|
||||
* may not be provided if the underlying network interface does not
|
||||
* provide a MAC address
|
||||
*
|
||||
*
|
||||
* @return Null-terminated representation of the local MAC address
|
||||
* or null if no MAC address is available
|
||||
*/
|
||||
|
@ -109,7 +106,7 @@ public:
|
|||
|
||||
/** Get the local network mask
|
||||
*
|
||||
* @return Null-terminated representation of the local network mask
|
||||
* @return Null-terminated representation of the local network mask
|
||||
* or null if no network mask has been recieved
|
||||
*/
|
||||
virtual const char *get_netmask();
|
||||
|
@ -148,16 +145,20 @@ public:
|
|||
*
|
||||
* @return Reference to the EMAC in use
|
||||
*/
|
||||
EMAC &get_emac() const { return _emac; }
|
||||
EMAC &get_emac() const
|
||||
{
|
||||
return _emac;
|
||||
}
|
||||
|
||||
virtual EMACInterface *emacInterface() {
|
||||
virtual EMACInterface *emacInterface()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Provide access to the underlying stack
|
||||
*
|
||||
* @return The underlying network stack
|
||||
* @return The underlying network stack
|
||||
*/
|
||||
virtual NetworkStack *get_stack();
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
*
|
||||
* Common interface that is shared between ethernet hardware.
|
||||
*/
|
||||
class EthInterface : public virtual NetworkInterface
|
||||
{
|
||||
class EthInterface : public virtual NetworkInterface {
|
||||
public:
|
||||
|
||||
virtual EthInterface *ethInterface() {
|
||||
virtual EthInterface *ethInterface()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
/** EthernetInterface class
|
||||
* Implementation of the NetworkStack for an EMAC-based Ethernet driver
|
||||
*/
|
||||
class EthernetInterface : public EMACInterface, public EthInterface
|
||||
{
|
||||
class EthernetInterface : public EMACInterface, public EthInterface {
|
||||
public:
|
||||
/** Create an EMAC-based ethernet interface.
|
||||
*
|
||||
|
@ -41,9 +40,8 @@ public:
|
|||
* @param emac Reference to EMAC to use
|
||||
* @param stack Reference to onboard-network stack to use
|
||||
*/
|
||||
EthernetInterface(
|
||||
EMAC &emac = EMAC::get_default_instance(),
|
||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
|
||||
EthernetInterface(EMAC &emac = EMAC::get_default_instance(),
|
||||
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance()) : EMACInterface(emac, stack) { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -186,7 +186,7 @@ nsapi_error_t InternetSocket::getsockopt(int level, int optname, void *optval, u
|
|||
}
|
||||
void InternetSocket::event()
|
||||
{
|
||||
_event_flag.set(READ_FLAG|WRITE_FLAG);
|
||||
_event_flag.set(READ_FLAG | WRITE_FLAG);
|
||||
|
||||
_pending += 1;
|
||||
if (_callback && _pending == 1) {
|
||||
|
|
|
@ -50,7 +50,8 @@ public:
|
|||
nsapi_error_t open(NetworkStack *stack);
|
||||
|
||||
template <typename S>
|
||||
nsapi_error_t open(S *stack) {
|
||||
nsapi_error_t open(S *stack)
|
||||
{
|
||||
return open(nsapi_create_stack(stack));
|
||||
}
|
||||
|
||||
|
@ -196,8 +197,8 @@ public:
|
|||
* mbed OS and has been known to cause confusion. Replaced by Socket::sigio.
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.4",
|
||||
"The behaviour of Socket::attach differs from other attach functions in "
|
||||
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
|
||||
"The behaviour of Socket::attach differs from other attach functions in "
|
||||
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
|
||||
void attach(mbed::Callback<void()> func);
|
||||
|
||||
/** Register a callback on state change of the socket
|
||||
|
@ -209,9 +210,10 @@ public:
|
|||
*/
|
||||
template <typename T, typename M>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1",
|
||||
"The attach function does not support cv-qualifiers. Replaced by "
|
||||
"attach(callback(obj, method)).")
|
||||
void attach(T *obj, M method) {
|
||||
"The attach function does not support cv-qualifiers. Replaced by "
|
||||
"attach(callback(obj, method)).")
|
||||
void attach(T *obj, M method)
|
||||
{
|
||||
attach(mbed::callback(obj, method));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
*
|
||||
* Common interface that is shared between mesh hardware
|
||||
*/
|
||||
class MeshInterface : public virtual NetworkInterface
|
||||
{
|
||||
class MeshInterface : public virtual NetworkInterface {
|
||||
public:
|
||||
|
||||
virtual MeshInterface *meshInterface() {
|
||||
virtual MeshInterface *meshInterface()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,8 +122,7 @@ public:
|
|||
* @param gateway Null-terminated representation of the local gateway
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t set_network(
|
||||
const char *ip_address, const char *netmask, const char *gateway);
|
||||
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
|
||||
|
||||
/** Enable or disable DHCP on the network
|
||||
*
|
||||
|
@ -163,7 +162,7 @@ public:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t gethostbyname(const char *host,
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
||||
|
||||
/** Hostname translation callback (asynchronous)
|
||||
*
|
||||
|
@ -203,7 +202,7 @@ public:
|
|||
* and can be passed to cancel
|
||||
*/
|
||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
|
||||
nsapi_version_t version = NSAPI_UNSPEC);
|
||||
nsapi_version_t version = NSAPI_UNSPEC);
|
||||
|
||||
/** Cancels asynchronous hostname translation
|
||||
*
|
||||
|
@ -245,27 +244,32 @@ public:
|
|||
virtual nsapi_error_t set_blocking(bool blocking);
|
||||
|
||||
/** Dynamic downcast to an EthInterface */
|
||||
virtual EthInterface *ethInterface() {
|
||||
virtual EthInterface *ethInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Dynamic downcast to a WiFiInterface */
|
||||
virtual WiFiInterface *wifiInterface() {
|
||||
virtual WiFiInterface *wifiInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Dynamic downcast to a MeshInterface */
|
||||
virtual MeshInterface *meshInterface() {
|
||||
virtual MeshInterface *meshInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Dynamic downcast to a CellularBase */
|
||||
virtual CellularBase *cellularBase() {
|
||||
virtual CellularBase *cellularBase()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Dynamic downcast to an EMACInterface */
|
||||
virtual EMACInterface *emacInterface() {
|
||||
virtual EMACInterface *emacInterface()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,14 +148,13 @@ call_in_callback_cb_t NetworkStack::get_call_in_callback()
|
|||
}
|
||||
|
||||
// NetworkStackWrapper class for encapsulating the raw nsapi_stack structure
|
||||
class NetworkStackWrapper : public NetworkStack
|
||||
{
|
||||
class NetworkStackWrapper : public NetworkStack {
|
||||
private:
|
||||
inline nsapi_stack_t *_stack()
|
||||
{
|
||||
return reinterpret_cast<nsapi_stack_t *>(
|
||||
reinterpret_cast<uint8_t *>(this)
|
||||
- offsetof(nsapi_stack_t, _stack_buffer));
|
||||
reinterpret_cast<uint8_t *>(this)
|
||||
- offsetof(nsapi_stack_t, _stack_buffer));
|
||||
}
|
||||
|
||||
inline const nsapi_stack_api_t *_stack_api()
|
||||
|
@ -358,7 +357,7 @@ protected:
|
|||
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
|
||||
{
|
||||
MBED_STATIC_ASSERT(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
|
||||
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
|
||||
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
|
||||
return new (stack->_stack_buffer) NetworkStackWrapper;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ class OnboardNetworkStack;
|
|||
* for instantiating network sockets.
|
||||
* @addtogroup netsocket
|
||||
*/
|
||||
class NetworkStack: public DNS
|
||||
{
|
||||
class NetworkStack: public DNS {
|
||||
public:
|
||||
virtual ~NetworkStack() {};
|
||||
|
||||
|
@ -61,7 +60,7 @@ public:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t gethostbyname(const char *host,
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
||||
|
||||
/** Hostname translation callback (asynchronous)
|
||||
*
|
||||
|
@ -101,7 +100,7 @@ public:
|
|||
* and can be passed to cancel
|
||||
*/
|
||||
virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
|
||||
nsapi_version_t version = NSAPI_UNSPEC);
|
||||
nsapi_version_t version = NSAPI_UNSPEC);
|
||||
|
||||
/** Cancels asynchronous hostname translation
|
||||
*
|
||||
|
@ -162,7 +161,10 @@ public:
|
|||
virtual nsapi_error_t getstackopt(int level, int optname, void *optval, unsigned *optlen);
|
||||
|
||||
/** Dynamic downcast to a OnboardNetworkStack */
|
||||
virtual OnboardNetworkStack *onboardNetworkStack() { return 0; }
|
||||
virtual OnboardNetworkStack *onboardNetworkStack()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class InternetSocket;
|
||||
|
@ -247,7 +249,7 @@ protected:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t socket_accept(nsapi_socket_t server,
|
||||
nsapi_socket_t *handle, SocketAddress *address=0) = 0;
|
||||
nsapi_socket_t *handle, SocketAddress *address = 0) = 0;
|
||||
|
||||
/** Send data over a TCP socket
|
||||
*
|
||||
|
@ -264,7 +266,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/** Receive data over a TCP socket
|
||||
*
|
||||
|
@ -281,7 +283,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
|
||||
void *data, nsapi_size_t size) = 0;
|
||||
void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/** Send a packet over a UDP socket
|
||||
*
|
||||
|
@ -299,7 +301,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/** Receive a packet over a UDP socket
|
||||
*
|
||||
|
@ -317,7 +319,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size) = 0;
|
||||
void *buffer, nsapi_size_t size) = 0;
|
||||
|
||||
/** Register a callback on state change of the socket
|
||||
*
|
||||
|
@ -348,7 +350,7 @@ protected:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level,
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
|
||||
/* Get stack-specific socket options
|
||||
*
|
||||
|
@ -364,7 +366,7 @@ protected:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t getsockopt(nsapi_socket_t handle, int level,
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ public:
|
|||
* @return NSAPI_ERROR_OK on success, or error code
|
||||
*/
|
||||
virtual nsapi_error_t bringup(bool dhcp, const char *ip,
|
||||
const char *netmask, const char *gw,
|
||||
nsapi_ip_stack_t stack = DEFAULT_STACK,
|
||||
bool blocking = true) = 0;
|
||||
const char *netmask, const char *gw,
|
||||
nsapi_ip_stack_t stack = DEFAULT_STACK,
|
||||
bool blocking = true) = 0;
|
||||
|
||||
/** Disconnect interface from the network
|
||||
*
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t sendto(const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/** Receive a data from a socket
|
||||
*
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t recvfrom(SocketAddress *address,
|
||||
void *data, nsapi_size_t size) = 0;
|
||||
void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/** Bind a specific address to a socket.
|
||||
*
|
||||
|
|
|
@ -35,7 +35,7 @@ static bool ipv4_is_valid(const char *addr)
|
|||
}
|
||||
|
||||
// Ending with '.' garuntees host
|
||||
if (i > 0 && addr[i-1] == '.') {
|
||||
if (i > 0 && addr[i - 1] == '.') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ static bool ipv6_is_valid(const char *addr)
|
|||
int colons = 0;
|
||||
for (int i = 0; addr[i]; i++) {
|
||||
if (!(addr[i] >= '0' && addr[i] <= '9') &&
|
||||
!(addr[i] >= 'a' && addr[i] <= 'f') &&
|
||||
!(addr[i] >= 'A' && addr[i] <= 'F') &&
|
||||
addr[i] != ':') {
|
||||
!(addr[i] >= 'a' && addr[i] <= 'f') &&
|
||||
!(addr[i] >= 'A' && addr[i] <= 'F') &&
|
||||
addr[i] != ':') {
|
||||
return false;
|
||||
}
|
||||
if (addr[i] == ':') {
|
||||
|
|
|
@ -49,8 +49,8 @@ public:
|
|||
*/
|
||||
template <typename S>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.1.3",
|
||||
"Constructors hide possible errors. Replaced by "
|
||||
"NetworkInterface::gethostbyname.")
|
||||
"Constructors hide possible errors. Replaced by "
|
||||
"NetworkInterface::gethostbyname.")
|
||||
SocketAddress(S *stack, const char *host, uint16_t port = 0)
|
||||
{
|
||||
_SocketAddress(nsapi_create_stack(stack), host, port);
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
* Must call open to initialize the socket on a network stack.
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.10",
|
||||
"TCPServer is deprecated, use TCPSocket")
|
||||
"TCPServer is deprecated, use TCPSocket")
|
||||
TCPServer();
|
||||
|
||||
/** Create a socket on a network interface
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
*/
|
||||
template <typename S>
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.10",
|
||||
"TCPServer is deprecated, use TCPSocket")
|
||||
"TCPServer is deprecated, use TCPSocket")
|
||||
TCPServer(S *stack)
|
||||
{
|
||||
open(stack);
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.10",
|
||||
"TCPServer::accept() is deprecated, use Socket *Socket::accept() instead")
|
||||
"TCPServer::accept() is deprecated, use Socket *Socket::accept() instead")
|
||||
nsapi_error_t accept(TCPSocket *connection, SocketAddress *address = NULL);
|
||||
};
|
||||
|
||||
|
|
|
@ -55,10 +55,13 @@ public:
|
|||
*/
|
||||
virtual ~TCPSocket();
|
||||
|
||||
/** Override multicast functions to return error for TCP
|
||||
*
|
||||
*/
|
||||
virtual int join_multicast_group(const SocketAddress &address) { return NSAPI_ERROR_UNSUPPORTED; }
|
||||
/** Override multicast functions to return error for TCP
|
||||
*
|
||||
*/
|
||||
virtual int join_multicast_group(const SocketAddress &address)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/** Connects TCP socket to a remote host
|
||||
*
|
||||
|
@ -130,7 +133,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t sendto(const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
/** Receive a data from a socket
|
||||
*
|
||||
|
@ -148,7 +151,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t recvfrom(SocketAddress *address,
|
||||
void *data, nsapi_size_t size);
|
||||
void *data, nsapi_size_t size);
|
||||
|
||||
/** Accepts a connection on a socket.
|
||||
*
|
||||
|
|
|
@ -89,7 +89,7 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
|
|||
|
||||
_writers--;
|
||||
if (!_socket || !_writers) {
|
||||
_event_flag.set(FINISHED_FLAG);
|
||||
_event_flag.set(FINISHED_FLAG);
|
||||
}
|
||||
_lock.unlock();
|
||||
return ret;
|
||||
|
@ -97,8 +97,9 @@ nsapi_size_or_error_t UDPSocket::sendto(const SocketAddress &address, const void
|
|||
|
||||
nsapi_size_or_error_t UDPSocket::send(const void *data, nsapi_size_t size)
|
||||
{
|
||||
if (!_remote_peer)
|
||||
if (!_remote_peer) {
|
||||
return NSAPI_ERROR_NO_ADDRESS;
|
||||
}
|
||||
return sendto(_remote_peer, data, size);
|
||||
}
|
||||
|
||||
|
@ -151,7 +152,7 @@ nsapi_size_or_error_t UDPSocket::recvfrom(SocketAddress *address, void *buffer,
|
|||
|
||||
_readers--;
|
||||
if (!_socket || !_readers) {
|
||||
_event_flag.set(FINISHED_FLAG);
|
||||
_event_flag.set(FINISHED_FLAG);
|
||||
}
|
||||
|
||||
_lock.unlock();
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t sendto(const char *host, uint16_t port,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
/** Send a packet over a UDP socket
|
||||
*
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t sendto(const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
/** Receive a datagram over a UDP socket
|
||||
*
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t recvfrom(SocketAddress *address,
|
||||
void *data, nsapi_size_t size);
|
||||
void *data, nsapi_size_t size);
|
||||
|
||||
/** Set remote peer address
|
||||
*
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
* Class that represents a WiFi Access Point
|
||||
* Common interface that is shared between WiFi devices
|
||||
*/
|
||||
class WiFiAccessPoint
|
||||
{
|
||||
class WiFiAccessPoint {
|
||||
/** WiFiAccessPoint lifetime
|
||||
*/
|
||||
public:
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
* Common interface that is shared between WiFi devices
|
||||
* @addtogroup netsocket
|
||||
*/
|
||||
class WiFiInterface: public virtual NetworkInterface
|
||||
{
|
||||
class WiFiInterface: public virtual NetworkInterface {
|
||||
public:
|
||||
/** Get the default WiFi interface.
|
||||
*
|
||||
|
@ -49,7 +48,7 @@ public:
|
|||
* @return 0 on success, or error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t set_credentials(const char *ssid, const char *pass,
|
||||
nsapi_security_t security = NSAPI_SECURITY_NONE) = 0;
|
||||
nsapi_security_t security = NSAPI_SECURITY_NONE) = 0;
|
||||
|
||||
/** Set the WiFi network channel
|
||||
*
|
||||
|
@ -76,7 +75,7 @@ public:
|
|||
* @return 0 on success, or error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t connect(const char *ssid, const char *pass,
|
||||
nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0) = 0;
|
||||
nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0) = 0;
|
||||
|
||||
/** Start the interface
|
||||
*
|
||||
|
@ -106,7 +105,8 @@ public:
|
|||
*/
|
||||
virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) = 0;
|
||||
|
||||
virtual WiFiInterface *wifiInterface() {
|
||||
virtual WiFiInterface *wifiInterface()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ static void nsapi_dns_query_async_socket_callback_handle(NetworkStack *stack);
|
|||
static void nsapi_dns_query_async_response(void *ptr);
|
||||
static void nsapi_dns_query_async_initiate_next(void);
|
||||
|
||||
// *INDENT-OFF*
|
||||
static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
|
||||
{NSAPI_IPv4, {8, 8, 8, 8}}, // Google
|
||||
{NSAPI_IPv4, {209, 244, 0, 3}}, // Level 3
|
||||
|
@ -110,6 +111,7 @@ static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
|
|||
{NSAPI_IPv6, {0x20,0x01, 0x16,0x08, 0,0x10, 0,0x25, // DNS.WATCH
|
||||
0,0, 0,0, 0x1c,0x04, 0xb1,0x2f}},
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
#if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
|
||||
static DNS_CACHE *dns_cache[MBED_CONF_NSAPI_DNS_CACHE_SIZE];
|
||||
|
@ -129,7 +131,7 @@ static bool dns_timer_running = false;
|
|||
extern "C" nsapi_error_t nsapi_dns_add_server(nsapi_addr_t addr)
|
||||
{
|
||||
memmove(&dns_servers[1], &dns_servers[0],
|
||||
(DNS_SERVERS_SIZE-1)*sizeof(nsapi_addr_t));
|
||||
(DNS_SERVERS_SIZE - 1)*sizeof(nsapi_addr_t));
|
||||
|
||||
dns_servers[0] = addr;
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -377,7 +379,7 @@ static nsapi_error_t nsapi_dns_cache_find(const char *host, nsapi_version_t vers
|
|||
delete dns_cache[i];
|
||||
dns_cache[i] = NULL;
|
||||
} else if ((version == NSAPI_UNSPEC || version == dns_cache[i]->address.version) &&
|
||||
strcmp(dns_cache[i]->host, host) == 0) {
|
||||
strcmp(dns_cache[i]->host, host) == 0) {
|
||||
if (address) {
|
||||
*address = dns_cache[i]->address;
|
||||
}
|
||||
|
@ -431,7 +433,7 @@ static nsapi_error_t nsapi_dns_get_server_addr(NetworkStack *stack, uint8_t *ind
|
|||
|
||||
// core query function
|
||||
static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
|
||||
nsapi_addr_t *addr, unsigned addr_count, nsapi_version_t version)
|
||||
nsapi_addr_t *addr, unsigned addr_count, nsapi_version_t version)
|
||||
{
|
||||
// check for valid host name
|
||||
int host_len = host ? strlen(host) : 0;
|
||||
|
@ -454,7 +456,7 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
|
|||
socket.set_timeout(MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME);
|
||||
|
||||
// create network packet
|
||||
uint8_t * const packet = (uint8_t *)malloc(DNS_BUFFER_SIZE);
|
||||
uint8_t *const packet = (uint8_t *)malloc(DNS_BUFFER_SIZE);
|
||||
if (!packet) {
|
||||
return NSAPI_ERROR_NO_MEMORY;
|
||||
}
|
||||
|
@ -538,14 +540,14 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
|
|||
|
||||
// convenience functions for other forms of queries
|
||||
extern "C" nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version)
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version)
|
||||
{
|
||||
NetworkStack *nstack = nsapi_create_stack(stack);
|
||||
return nsapi_dns_query_multiple(nstack, host, addr, addr_count, version);
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
|
||||
SocketAddress *addresses, nsapi_size_t addr_count, nsapi_version_t version)
|
||||
SocketAddress *addresses, nsapi_size_t addr_count, nsapi_version_t version)
|
||||
{
|
||||
nsapi_addr_t *addrs = new (std::nothrow) nsapi_addr_t[addr_count];
|
||||
nsapi_size_or_error_t result = nsapi_dns_query_multiple(stack, host, addrs, addr_count, version);
|
||||
|
@ -561,7 +563,7 @@ nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *
|
|||
}
|
||||
|
||||
extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_version_t version)
|
||||
nsapi_addr_t *addr, nsapi_version_t version)
|
||||
{
|
||||
NetworkStack *nstack = nsapi_create_stack(stack);
|
||||
nsapi_size_or_error_t result = nsapi_dns_query_multiple(nstack, host, addr, 1, version);
|
||||
|
@ -569,7 +571,7 @@ extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
|||
}
|
||||
|
||||
nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
|
||||
SocketAddress *address, nsapi_version_t version)
|
||||
SocketAddress *address, nsapi_version_t version)
|
||||
{
|
||||
nsapi_addr_t addr;
|
||||
nsapi_size_or_error_t result = nsapi_dns_query_multiple(stack, host, &addr, 1, version);
|
||||
|
@ -578,8 +580,8 @@ nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
|
|||
}
|
||||
|
||||
nsapi_value_or_error_t nsapi_dns_query_async(NetworkStack *stack, const char *host,
|
||||
NetworkStack::hostbyname_cb_t callback, call_in_callback_cb_t call_in_cb,
|
||||
nsapi_version_t version)
|
||||
NetworkStack::hostbyname_cb_t callback, call_in_callback_cb_t call_in_cb,
|
||||
nsapi_version_t version)
|
||||
{
|
||||
return nsapi_dns_query_multiple_async(stack, host, callback, 0, call_in_cb, version);
|
||||
}
|
||||
|
@ -600,8 +602,8 @@ nsapi_error_t nsapi_dns_call_in(call_in_callback_cb_t cb, int delay, mbed::Callb
|
|||
}
|
||||
|
||||
nsapi_value_or_error_t nsapi_dns_query_multiple_async(NetworkStack *stack, const char *host,
|
||||
NetworkStack::hostbyname_cb_t callback, nsapi_size_t addr_count,
|
||||
call_in_callback_cb_t call_in_cb, nsapi_version_t version)
|
||||
NetworkStack::hostbyname_cb_t callback, nsapi_size_t addr_count,
|
||||
call_in_callback_cb_t call_in_cb, nsapi_version_t version)
|
||||
{
|
||||
dns_mutex->lock();
|
||||
|
||||
|
@ -724,7 +726,7 @@ static void nsapi_dns_query_async_initiate_next(void)
|
|||
query = dns_query_queue[i];
|
||||
id = dns_query_queue[i]->unique_id;
|
||||
}
|
||||
// If some query is already ongoing do not trigger
|
||||
// If some query is already ongoing do not trigger
|
||||
} else if (dns_query_queue[i]->state == DNS_INITIATED) {
|
||||
query = NULL;
|
||||
break;
|
||||
|
@ -770,7 +772,7 @@ static void nsapi_dns_query_async_timeout(void)
|
|||
// Retries
|
||||
dns_query_queue[i]->socket_timeout = 0;
|
||||
nsapi_dns_call_in(dns_query_queue[i]->call_in_cb, 0,
|
||||
mbed::callback(nsapi_dns_query_async_send, reinterpret_cast<void *>(dns_query_queue[i]->unique_id)));
|
||||
mbed::callback(nsapi_dns_query_async_send, reinterpret_cast<void *>(dns_query_queue[i]->unique_id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,7 +908,7 @@ static nsapi_error_t nsapi_dns_query_async_delete(int unique_id)
|
|||
|
||||
for (int i = 0; i < DNS_QUERY_QUEUE_SIZE; i++) {
|
||||
if (dns_query_queue[i] && dns_query_queue[i] != query && dns_query_queue[i]->socket &&
|
||||
dns_query_queue[i]->stack == query->stack) {
|
||||
dns_query_queue[i]->stack == query->stack) {
|
||||
close_socket = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_version_t version);
|
||||
nsapi_addr_t *addr, nsapi_version_t version);
|
||||
|
||||
/** Query a domain name server for multiple IP address of a given hostname
|
||||
*
|
||||
|
@ -51,7 +51,7 @@ nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version);
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version);
|
||||
|
||||
/** Add a domain name server to list of servers to query
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ typedef mbed::Callback<nsapi_error_t (int delay_ms, mbed::Callback<void()> user_
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
|
||||
SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4);
|
||||
SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
/** Query a domain name server for an IP address of a given hostname
|
||||
*
|
||||
|
@ -88,8 +88,8 @@ nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
|
|||
* cancel, NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_error_t nsapi_dns_query_async(NetworkStack *stack, const char *host,
|
||||
NetworkStack::hostbyname_cb_t callback, call_in_callback_cb_t call_in_cb,
|
||||
nsapi_version_t version = NSAPI_IPv4);
|
||||
NetworkStack::hostbyname_cb_t callback, call_in_callback_cb_t call_in_cb,
|
||||
nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
/** Query a domain name server for an IP address of a given hostname (asynchronous)
|
||||
*
|
||||
|
@ -101,7 +101,7 @@ nsapi_error_t nsapi_dns_query_async(NetworkStack *stack, const char *host,
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_version_t version = NSAPI_IPv4);
|
||||
nsapi_addr_t *addr, nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
/** Query a domain name server for an IP address of a given hostname
|
||||
*
|
||||
|
@ -114,7 +114,7 @@ extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
|
|||
*/
|
||||
template <typename S>
|
||||
nsapi_error_t nsapi_dns_query(S *stack, const char *host,
|
||||
SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4)
|
||||
SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4)
|
||||
{
|
||||
return nsapi_dns_query(nsapi_create_stack(stack), host, addr, version);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ nsapi_error_t nsapi_dns_query(S *stack, const char *host,
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
|
||||
SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
|
||||
SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
/** Query a domain name server for an IP address of a given hostname (asynchronous)
|
||||
*
|
||||
|
@ -144,8 +144,8 @@ nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *
|
|||
* cancel, NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
nsapi_size_or_error_t nsapi_dns_query_multiple_async(NetworkStack *stack, const char *host,
|
||||
NetworkStack::hostbyname_cb_t callback, nsapi_size_t addr_count,
|
||||
call_in_callback_cb_t call_in_cb, nsapi_version_t version = NSAPI_IPv4);
|
||||
NetworkStack::hostbyname_cb_t callback, nsapi_size_t addr_count,
|
||||
call_in_callback_cb_t call_in_cb, nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
/** Query a domain name server for multiple IP address of a given hostname
|
||||
*
|
||||
|
@ -158,7 +158,7 @@ nsapi_size_or_error_t nsapi_dns_query_multiple_async(NetworkStack *stack, const
|
|||
* NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
|
||||
*/
|
||||
extern "C" nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
|
||||
nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);
|
||||
|
||||
|
||||
/** Query a domain name server for multiple IP address of a given hostname
|
||||
|
@ -173,10 +173,10 @@ extern "C" nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack,
|
|||
*/
|
||||
template <typename S>
|
||||
nsapi_size_or_error_t nsapi_dns_query_multiple(S *stack, const char *host,
|
||||
SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4)
|
||||
SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4)
|
||||
{
|
||||
return nsapi_dns_query_multiple(nsapi_create_stack(stack),
|
||||
host, addr, addr_count, version);
|
||||
host, addr, addr_count, version);
|
||||
}
|
||||
|
||||
/** Cancels asynchronous hostname translation
|
||||
|
|
|
@ -47,7 +47,7 @@ nsapi_error_t nsapi_ppp_set_blocking(bool blocking);
|
|||
*
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t, intptr_t)> status_cb=0, const char *uname=0, const char *pwd=0, const nsapi_ip_stack_t stack=DEFAULT_STACK);
|
||||
nsapi_error_t nsapi_ppp_connect(FileHandle *stream, Callback<void(nsapi_event_t, intptr_t)> status_cb = 0, const char *uname = 0, const char *pwd = 0, const nsapi_ip_stack_t stack = DEFAULT_STACK);
|
||||
|
||||
/** Close a PPP connection
|
||||
*
|
||||
|
|
|
@ -64,7 +64,7 @@ enum nsapi_error {
|
|||
*
|
||||
* @enum nsapi_connection_status
|
||||
*/
|
||||
typedef enum nsapi_connection_status {
|
||||
typedef enum nsapi_connection_status {
|
||||
NSAPI_STATUS_LOCAL_UP = 0, /*!< local IP address set */
|
||||
NSAPI_STATUS_GLOBAL_UP = 1, /*!< global IP address set */
|
||||
NSAPI_STATUS_DISCONNECTED = 2, /*!< no connection to network */
|
||||
|
@ -79,7 +79,7 @@ enum nsapi_error {
|
|||
*
|
||||
* @enum nsapi_event
|
||||
*/
|
||||
typedef enum nsapi_event {
|
||||
typedef enum nsapi_event {
|
||||
NSAPI_EVENT_CONNECTION_STATUS_CHANGE = 0, /*!< network connection status has changed, the parameter = new status (nsapi_connection_status_t) */
|
||||
NSAPI_EVENT_CELLULAR_STATUS_BASE = 0x1000, /*!< Cellular modem status has changed, See the enum values from enum cellular_connection_status_t in /features/cellular/framework/common/CellularCommon.h */
|
||||
NSAPI_EVENT_CELLULAR_STATUS_END = 0x1FFF /*!< cellular modem status has changed, See the enum values from enum cellular_connection_status_t in /features/cellular/framework/common/CellularCommon.h */
|
||||
|
@ -201,8 +201,8 @@ typedef void *nsapi_socket_t;
|
|||
* @enum nsapi_protocol
|
||||
*/
|
||||
typedef enum nsapi_protocol {
|
||||
NSAPI_TCP, /*!< Socket is of TCP type */
|
||||
NSAPI_UDP, /*!< Socket is of UDP type */
|
||||
NSAPI_TCP, /*!< Socket is of TCP type */
|
||||
NSAPI_UDP, /*!< Socket is of UDP type */
|
||||
} nsapi_protocol_t;
|
||||
|
||||
/** Enum of standardized stack option levels
|
||||
|
@ -320,8 +320,7 @@ typedef struct nsapi_ip_mreq {
|
|||
*
|
||||
* Unsupported operations can be left as null pointers.
|
||||
*/
|
||||
typedef struct nsapi_stack_api
|
||||
{
|
||||
typedef struct nsapi_stack_api {
|
||||
/** Get the local IP address
|
||||
*
|
||||
* @param stack Stack handle
|
||||
|
@ -366,7 +365,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*setstackopt)(nsapi_stack_t *stack, int level,
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
|
||||
/* Get stack-specific stack options
|
||||
*
|
||||
|
@ -382,7 +381,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*getstackopt)(nsapi_stack_t *stack, int level,
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
|
||||
/** Opens a socket
|
||||
*
|
||||
|
@ -398,7 +397,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*socket_open)(nsapi_stack_t *stack, nsapi_socket_t *socket,
|
||||
nsapi_protocol_t proto);
|
||||
nsapi_protocol_t proto);
|
||||
|
||||
/** Close the socket
|
||||
*
|
||||
|
@ -423,7 +422,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure.
|
||||
*/
|
||||
nsapi_error_t (*socket_bind)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
nsapi_addr_t addr, uint16_t port);
|
||||
nsapi_addr_t addr, uint16_t port);
|
||||
|
||||
/** Listen for connections on a TCP socket
|
||||
*
|
||||
|
@ -450,7 +449,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*socket_connect)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
nsapi_addr_t addr, uint16_t port);
|
||||
nsapi_addr_t addr, uint16_t port);
|
||||
|
||||
/** Accepts a connection on a TCP socket
|
||||
*
|
||||
|
@ -473,7 +472,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*socket_accept)(nsapi_stack_t *stack, nsapi_socket_t server,
|
||||
nsapi_socket_t *socket, nsapi_addr_t *addr, uint16_t *port);
|
||||
nsapi_socket_t *socket, nsapi_addr_t *addr, uint16_t *port);
|
||||
|
||||
/** Send data over a TCP socket
|
||||
*
|
||||
|
@ -491,7 +490,7 @@ typedef struct nsapi_stack_api
|
|||
* code on failure
|
||||
*/
|
||||
nsapi_size_or_error_t (*socket_send)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
/** Receive data over a TCP socket
|
||||
*
|
||||
|
@ -509,7 +508,7 @@ typedef struct nsapi_stack_api
|
|||
* code on failure
|
||||
*/
|
||||
nsapi_size_or_error_t (*socket_recv)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
void *data, nsapi_size_t size);
|
||||
void *data, nsapi_size_t size);
|
||||
|
||||
/** Send a packet over a UDP socket
|
||||
*
|
||||
|
@ -529,7 +528,7 @@ typedef struct nsapi_stack_api
|
|||
* code on failure
|
||||
*/
|
||||
nsapi_size_or_error_t (*socket_sendto)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
nsapi_addr_t addr, uint16_t port, const void *data, nsapi_size_t size);
|
||||
nsapi_addr_t addr, uint16_t port, const void *data, nsapi_size_t size);
|
||||
|
||||
/** Receive a packet over a UDP socket
|
||||
*
|
||||
|
@ -549,7 +548,7 @@ typedef struct nsapi_stack_api
|
|||
* code on failure
|
||||
*/
|
||||
nsapi_size_or_error_t (*socket_recvfrom)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
nsapi_addr_t *addr, uint16_t *port, void *buffer, nsapi_size_t size);
|
||||
nsapi_addr_t *addr, uint16_t *port, void *buffer, nsapi_size_t size);
|
||||
|
||||
/** Register a callback on state change of the socket
|
||||
*
|
||||
|
@ -566,7 +565,7 @@ typedef struct nsapi_stack_api
|
|||
* @param data Argument to pass to callback
|
||||
*/
|
||||
void (*socket_attach)(nsapi_stack_t *stack, nsapi_socket_t socket,
|
||||
void (*callback)(void *), void *data);
|
||||
void (*callback)(void *), void *data);
|
||||
|
||||
/* Set stack-specific socket options
|
||||
*
|
||||
|
@ -583,7 +582,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*setsockopt)(nsapi_stack_t *stack, nsapi_socket_t socket, int level,
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
int optname, const void *optval, unsigned optlen);
|
||||
|
||||
/* Get stack-specific socket options
|
||||
*
|
||||
|
@ -600,7 +599,7 @@ typedef struct nsapi_stack_api
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
nsapi_error_t (*getsockopt)(nsapi_stack_t *stack, nsapi_socket_t socket, int level,
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
int optname, void *optval, unsigned *optlen);
|
||||
} nsapi_stack_api_t;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue