@@ -110,7 +110,7 @@ class NanostackSocket {
110
110
111
111
static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX];
112
112
113
- static int map_mesh_error (mesh_error_t err)
113
+ static nsapi_error_t map_mesh_error (mesh_error_t err)
114
114
{
115
115
switch (err) {
116
116
case MESH_ERROR_NONE: return 0 ;
@@ -167,7 +167,7 @@ NanostackSocket::~NanostackSocket()
167
167
close ();
168
168
}
169
169
if (socket_id >= 0 ) {
170
- int ret = socket_free (socket_id);
170
+ nsapi_error_t ret = socket_free (socket_id);
171
171
MBED_ASSERT (0 == ret);
172
172
MBED_ASSERT (socket_tbl[socket_id] == this );
173
173
socket_tbl[socket_id] = NULL ;
@@ -209,7 +209,7 @@ void NanostackSocket::close()
209
209
MBED_ASSERT (mode != SOCKET_MODE_CLOSED);
210
210
211
211
if (socket_id >= 0 ) {
212
- int ret = socket_close (socket_id, (addr_valid ? &ns_address : NULL ));
212
+ nsapi_error_t ret = socket_close (socket_id, (addr_valid ? &ns_address : NULL ));
213
213
MBED_ASSERT (0 == ret);
214
214
} else {
215
215
MBED_ASSERT (SOCKET_MODE_UNOPENED == mode);
@@ -466,7 +466,7 @@ MeshInterfaceNanostack::MeshInterfaceNanostack(NanostackRfPhy *phy)
466
466
// Nothing to do
467
467
}
468
468
469
- int MeshInterfaceNanostack::initialize (NanostackRfPhy *phy)
469
+ nsapi_error_t MeshInterfaceNanostack::initialize (NanostackRfPhy *phy)
470
470
{
471
471
if (this ->phy != NULL ) {
472
472
error (" Phy already set" );
@@ -486,7 +486,7 @@ void MeshInterfaceNanostack::mesh_network_handler(mesh_connection_status_t statu
486
486
nanostack_unlock ();
487
487
}
488
488
489
- int MeshInterfaceNanostack::register_rf ()
489
+ nsapi_error_t MeshInterfaceNanostack::register_rf ()
490
490
{
491
491
nanostack_lock ();
492
492
@@ -504,7 +504,7 @@ int MeshInterfaceNanostack::register_rf()
504
504
return 0 ;
505
505
}
506
506
507
- int MeshInterfaceNanostack::actual_connect ()
507
+ nsapi_error_t MeshInterfaceNanostack::actual_connect ()
508
508
{
509
509
nanostack_assert_locked ();
510
510
@@ -532,7 +532,7 @@ NetworkStack * MeshInterfaceNanostack::get_stack()
532
532
return NanostackInterface::get_stack ();
533
533
}
534
534
535
- int MeshInterfaceNanostack::disconnect ()
535
+ nsapi_error_t MeshInterfaceNanostack::disconnect ()
536
536
{
537
537
nanostack_lock ();
538
538
@@ -562,7 +562,7 @@ const char *MeshInterfaceNanostack::get_mac_address()
562
562
return mac_addr_str;
563
563
}
564
564
565
- int ThreadInterface::connect ()
565
+ nsapi_error_t ThreadInterface::connect ()
566
566
{
567
567
// initialize mesh networking resources, memory, timers, etc...
568
568
mesh_system_init ();
@@ -586,14 +586,14 @@ int ThreadInterface::connect()
586
586
nanostack_unlock ();
587
587
return map_mesh_error (status);
588
588
}
589
- int ret = this ->actual_connect ();
589
+ nsapi_error_t ret = this ->actual_connect ();
590
590
591
591
nanostack_unlock ();
592
592
593
593
return ret;
594
594
}
595
595
596
- int LoWPANNDInterface::connect ()
596
+ nsapi_error_t LoWPANNDInterface::connect ()
597
597
{
598
598
// initialize mesh networking resources, memory, timers, etc...
599
599
mesh_system_init ();
@@ -617,7 +617,7 @@ int LoWPANNDInterface::connect()
617
617
nanostack_unlock ();
618
618
return map_mesh_error (status);
619
619
}
620
- int ret = this ->actual_connect ();
620
+ nsapi_error_t ret = this ->actual_connect ();
621
621
622
622
nanostack_unlock ();
623
623
@@ -646,7 +646,7 @@ const char * NanostackInterface::get_ip_address()
646
646
return NULL ;
647
647
}
648
648
649
- int NanostackInterface::socket_open (void **handle, nsapi_protocol_t protocol)
649
+ nsapi_error_t NanostackInterface::socket_open (void **handle, nsapi_protocol_t protocol)
650
650
{
651
651
// Validate parameters
652
652
if (NULL == handle) {
@@ -687,7 +687,7 @@ int NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)
687
687
return 0 ;
688
688
}
689
689
690
- int NanostackInterface::socket_close (void *handle)
690
+ nsapi_error_t NanostackInterface::socket_close (void *handle)
691
691
{
692
692
// Validate parameters
693
693
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -707,7 +707,7 @@ int NanostackInterface::socket_close(void *handle)
707
707
708
708
}
709
709
710
- int NanostackInterface::socket_sendto (void *handle, const SocketAddress &address, const void *data, unsigned int size)
710
+ nsapi_size_or_error_t NanostackInterface::socket_sendto (void *handle, const SocketAddress &address, const void *data, nsapi_size_t size)
711
711
{
712
712
// Validate parameters
713
713
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -718,7 +718,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
718
718
719
719
nanostack_lock ();
720
720
721
- int ret;
721
+ nsapi_size_or_error_t ret;
722
722
if (socket->closed ()) {
723
723
ret = NSAPI_ERROR_NO_CONNECTION;
724
724
} else if (NANOSTACK_SOCKET_TCP == socket->proto ) {
@@ -758,7 +758,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
758
758
return ret;
759
759
}
760
760
761
- int NanostackInterface::socket_recvfrom (void *handle, SocketAddress *address, void *buffer, unsigned size)
761
+ nsapi_size_or_error_t NanostackInterface::socket_recvfrom (void *handle, SocketAddress *address, void *buffer, nsapi_size_t size)
762
762
{
763
763
// Validate parameters
764
764
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -777,7 +777,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
777
777
778
778
nanostack_lock ();
779
779
780
- int ret;
780
+ nsapi_size_or_error_t ret;
781
781
if (socket->closed ()) {
782
782
ret = NSAPI_ERROR_NO_CONNECTION;
783
783
} else if (NANOSTACK_SOCKET_TCP == socket->proto ) {
@@ -796,7 +796,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
796
796
return ret;
797
797
}
798
798
799
- int NanostackInterface::socket_bind (void *handle, const SocketAddress &address)
799
+ nsapi_error_t NanostackInterface::socket_bind (void *handle, const SocketAddress &address)
800
800
{
801
801
// Validate parameters
802
802
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -812,7 +812,7 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
812
812
ns_address.type = ADDRESS_IPV6;
813
813
memset (ns_address.address , 0 , sizeof ns_address.address );
814
814
ns_address.identifier = address.get_port ();
815
- int ret = NSAPI_ERROR_DEVICE_ERROR;
815
+ nsapi_error_t ret = NSAPI_ERROR_DEVICE_ERROR;
816
816
if (0 == ::socket_bind (socket->socket_id , &ns_address)) {
817
817
socket->set_bound ();
818
818
ret = 0 ;
@@ -825,22 +825,22 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
825
825
return ret;
826
826
}
827
827
828
- int NanostackInterface::setsockopt (void *handle, int level, int optname, const void *optval, unsigned optlen)
828
+ nsapi_error_t NanostackInterface::setsockopt (void *handle, int level, int optname, const void *optval, unsigned optlen)
829
829
{
830
830
return NSAPI_ERROR_UNSUPPORTED;
831
831
}
832
832
833
- int NanostackInterface::getsockopt (void *handle, int level, int optname, void *optval, unsigned *optlen)
833
+ nsapi_error_t NanostackInterface::getsockopt (void *handle, int level, int optname, void *optval, unsigned *optlen)
834
834
{
835
835
return NSAPI_ERROR_UNSUPPORTED;
836
836
}
837
837
838
- int NanostackInterface::socket_listen (void *handle, int backlog)
838
+ nsapi_error_t NanostackInterface::socket_listen (void *handle, int backlog)
839
839
{
840
840
return NSAPI_ERROR_UNSUPPORTED;
841
841
}
842
842
843
- int NanostackInterface::socket_connect (void *handle, const SocketAddress &addr)
843
+ nsapi_error_t NanostackInterface::socket_connect (void *handle, const SocketAddress &addr)
844
844
{
845
845
// Validate parameters
846
846
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -851,7 +851,7 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
851
851
852
852
nanostack_lock ();
853
853
854
- int ret;
854
+ nsapi_error_t ret;
855
855
ns_address_t ns_addr;
856
856
int random_port = socket->is_bound () ? 0 : 1 ;
857
857
convert_mbed_addr_to_ns (&ns_addr, &addr);
@@ -869,12 +869,12 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
869
869
return ret;
870
870
}
871
871
872
- int NanostackInterface::socket_accept (void *server, void **handle, SocketAddress *address)
872
+ nsapi_error_t NanostackInterface::socket_accept (void *server, void **handle, SocketAddress *address)
873
873
{
874
874
return NSAPI_ERROR_UNSUPPORTED;
875
875
}
876
876
877
- int NanostackInterface::socket_send (void *handle, const void *p, unsigned size)
877
+ nsapi_size_or_error_t NanostackInterface::socket_send (void *handle, const void *p, nsapi_size_t size)
878
878
{
879
879
// Validate parameters
880
880
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -885,7 +885,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
885
885
886
886
nanostack_lock ();
887
887
888
- int ret;
888
+ nsapi_size_or_error_t ret;
889
889
if (socket->closed ()) {
890
890
ret = NSAPI_ERROR_NO_CONNECTION;
891
891
} else if (socket->is_connecting ()) {
@@ -918,7 +918,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
918
918
return ret;
919
919
}
920
920
921
- int NanostackInterface::socket_recv (void *handle, void *data, unsigned size)
921
+ nsapi_size_or_error_t NanostackInterface::socket_recv (void *handle, void *data, nsapi_size_t size)
922
922
{
923
923
// Validate parameters
924
924
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -929,7 +929,7 @@ int NanostackInterface::socket_recv(void *handle, void *data, unsigned size)
929
929
930
930
nanostack_lock ();
931
931
932
- int ret;
932
+ nsapi_size_or_error_t ret;
933
933
if (socket->closed ()) {
934
934
ret = NSAPI_ERROR_NO_CONNECTION;
935
935
} else if (socket->data_available ()) {
0 commit comments