@@ -326,7 +326,7 @@ const char *mbed_lwip_get_mac_address(void)
326
326
return lwip_mac_address [0 ] ? lwip_mac_address : 0 ;
327
327
}
328
328
329
- char * mbed_lwip_get_ip_address (char * buf , int buflen )
329
+ char * mbed_lwip_get_ip_address (char * buf , nsapi_size_t buflen )
330
330
{
331
331
const ip_addr_t * addr = mbed_lwip_get_ip_addr (true, & lwip_netif );
332
332
if (!addr ) {
@@ -345,7 +345,7 @@ char *mbed_lwip_get_ip_address(char *buf, int buflen)
345
345
return NULL ;
346
346
}
347
347
348
- const char * mbed_lwip_get_netmask (char * buf , int buflen )
348
+ const char * mbed_lwip_get_netmask (char * buf , nsapi_size_t buflen )
349
349
{
350
350
#if LWIP_IPV4
351
351
const ip4_addr_t * addr = netif_ip4_netmask (& lwip_netif );
@@ -359,7 +359,7 @@ const char *mbed_lwip_get_netmask(char *buf, int buflen)
359
359
#endif
360
360
}
361
361
362
- char * mbed_lwip_get_gateway (char * buf , int buflen )
362
+ char * mbed_lwip_get_gateway (char * buf , nsapi_size_t buflen )
363
363
{
364
364
#if LWIP_IPV4
365
365
const ip4_addr_t * addr = netif_ip4_gw (& lwip_netif );
@@ -373,7 +373,7 @@ char *mbed_lwip_get_gateway(char *buf, int buflen)
373
373
#endif
374
374
}
375
375
376
- int mbed_lwip_init (emac_interface_t * emac )
376
+ nsapi_error_t mbed_lwip_init (emac_interface_t * emac )
377
377
{
378
378
// Check if we've already brought up lwip
379
379
if (!mbed_lwip_get_mac_address ()) {
@@ -409,7 +409,7 @@ int mbed_lwip_init(emac_interface_t *emac)
409
409
return NSAPI_ERROR_OK ;
410
410
}
411
411
412
- int mbed_lwip_bringup (bool dhcp , const char * ip , const char * netmask , const char * gw )
412
+ nsapi_error_t mbed_lwip_bringup (bool dhcp , const char * ip , const char * netmask , const char * gw )
413
413
{
414
414
// Check if we've already connected
415
415
if (lwip_connected ) {
@@ -509,7 +509,7 @@ int mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask, const char
509
509
return 0 ;
510
510
}
511
511
512
- int mbed_lwip_bringdown (void )
512
+ nsapi_error_t mbed_lwip_bringdown (void )
513
513
{
514
514
// Check if we've connected
515
515
if (!lwip_connected ) {
@@ -533,7 +533,7 @@ int mbed_lwip_bringdown(void)
533
533
}
534
534
535
535
/* LWIP error remapping */
536
- static int mbed_lwip_err_remap (err_t err ) {
536
+ static nsapi_error_t mbed_lwip_err_remap (err_t err ) {
537
537
switch (err ) {
538
538
case ERR_OK :
539
539
case ERR_CLSD :
@@ -559,7 +559,7 @@ static int mbed_lwip_err_remap(err_t err) {
559
559
}
560
560
561
561
/* LWIP network stack implementation */
562
- static int mbed_lwip_gethostbyname (nsapi_stack_t * stack , const char * host , nsapi_addr_t * addr , nsapi_version_t version )
562
+ static nsapi_error_t mbed_lwip_gethostbyname (nsapi_stack_t * stack , const char * host , nsapi_addr_t * addr , nsapi_version_t version )
563
563
{
564
564
ip_addr_t lwip_addr ;
565
565
@@ -600,7 +600,7 @@ static int mbed_lwip_gethostbyname(nsapi_stack_t *stack, const char *host, nsapi
600
600
return 0 ;
601
601
}
602
602
603
- static int mbed_lwip_socket_open (nsapi_stack_t * stack , nsapi_socket_t * handle , nsapi_protocol_t proto )
603
+ static nsapi_error_t mbed_lwip_socket_open (nsapi_stack_t * stack , nsapi_socket_t * handle , nsapi_protocol_t proto )
604
604
{
605
605
// check if network is connected
606
606
if (!lwip_connected ) {
@@ -643,7 +643,7 @@ static int mbed_lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t *handle, n
643
643
return 0 ;
644
644
}
645
645
646
- static int mbed_lwip_socket_close (nsapi_stack_t * stack , nsapi_socket_t handle )
646
+ static nsapi_error_t mbed_lwip_socket_close (nsapi_stack_t * stack , nsapi_socket_t handle )
647
647
{
648
648
struct lwip_socket * s = (struct lwip_socket * )handle ;
649
649
@@ -652,7 +652,7 @@ static int mbed_lwip_socket_close(nsapi_stack_t *stack, nsapi_socket_t handle)
652
652
return mbed_lwip_err_remap (err );
653
653
}
654
654
655
- static int mbed_lwip_socket_bind (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port )
655
+ static nsapi_error_t mbed_lwip_socket_bind (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port )
656
656
{
657
657
struct lwip_socket * s = (struct lwip_socket * )handle ;
658
658
ip_addr_t ip_addr ;
@@ -670,15 +670,15 @@ static int mbed_lwip_socket_bind(nsapi_stack_t *stack, nsapi_socket_t handle, ns
670
670
return mbed_lwip_err_remap (err );
671
671
}
672
672
673
- static int mbed_lwip_socket_listen (nsapi_stack_t * stack , nsapi_socket_t handle , int backlog )
673
+ static nsapi_error_t mbed_lwip_socket_listen (nsapi_stack_t * stack , nsapi_socket_t handle , int backlog )
674
674
{
675
675
struct lwip_socket * s = (struct lwip_socket * )handle ;
676
676
677
677
err_t err = netconn_listen_with_backlog (s -> conn , backlog );
678
678
return mbed_lwip_err_remap (err );
679
679
}
680
680
681
- static int mbed_lwip_socket_connect (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port )
681
+ static nsapi_error_t mbed_lwip_socket_connect (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port )
682
682
{
683
683
struct lwip_socket * s = (struct lwip_socket * )handle ;
684
684
ip_addr_t ip_addr ;
@@ -694,7 +694,7 @@ static int mbed_lwip_socket_connect(nsapi_stack_t *stack, nsapi_socket_t handle,
694
694
return mbed_lwip_err_remap (err );
695
695
}
696
696
697
- static int mbed_lwip_socket_accept (nsapi_stack_t * stack , nsapi_socket_t server , nsapi_socket_t * handle , nsapi_addr_t * addr , uint16_t * port )
697
+ static nsapi_error_t mbed_lwip_socket_accept (nsapi_stack_t * stack , nsapi_socket_t server , nsapi_socket_t * handle , nsapi_addr_t * addr , uint16_t * port )
698
698
{
699
699
struct lwip_socket * s = (struct lwip_socket * )server ;
700
700
struct lwip_socket * ns = mbed_lwip_arena_alloc ();
@@ -718,7 +718,7 @@ static int mbed_lwip_socket_accept(nsapi_stack_t *stack, nsapi_socket_t server,
718
718
return 0 ;
719
719
}
720
720
721
- static int mbed_lwip_socket_send (nsapi_stack_t * stack , nsapi_socket_t handle , const void * data , unsigned size )
721
+ static nsapi_size_or_error_t mbed_lwip_socket_send (nsapi_stack_t * stack , nsapi_socket_t handle , const void * data , nsapi_size_t size )
722
722
{
723
723
struct lwip_socket * s = (struct lwip_socket * )handle ;
724
724
size_t bytes_written = 0 ;
@@ -728,10 +728,10 @@ static int mbed_lwip_socket_send(nsapi_stack_t *stack, nsapi_socket_t handle, co
728
728
return mbed_lwip_err_remap (err );
729
729
}
730
730
731
- return (int )bytes_written ;
731
+ return (nsapi_size_or_error_t )bytes_written ;
732
732
}
733
733
734
- static int mbed_lwip_socket_recv (nsapi_stack_t * stack , nsapi_socket_t handle , void * data , unsigned size )
734
+ static nsapi_size_or_error_t mbed_lwip_socket_recv (nsapi_stack_t * stack , nsapi_socket_t handle , void * data , nsapi_size_t size )
735
735
{
736
736
struct lwip_socket * s = (struct lwip_socket * )handle ;
737
737
@@ -755,7 +755,7 @@ static int mbed_lwip_socket_recv(nsapi_stack_t *stack, nsapi_socket_t handle, vo
755
755
return recv ;
756
756
}
757
757
758
- static int mbed_lwip_socket_sendto (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port , const void * data , unsigned size )
758
+ static nsapi_size_or_error_t mbed_lwip_socket_sendto (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t addr , uint16_t port , const void * data , nsapi_size_t size )
759
759
{
760
760
struct lwip_socket * s = (struct lwip_socket * )handle ;
761
761
ip_addr_t ip_addr ;
@@ -780,7 +780,7 @@ static int mbed_lwip_socket_sendto(nsapi_stack_t *stack, nsapi_socket_t handle,
780
780
return size ;
781
781
}
782
782
783
- static int mbed_lwip_socket_recvfrom (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t * addr , uint16_t * port , void * data , unsigned size )
783
+ static nsapi_size_or_error_t mbed_lwip_socket_recvfrom (nsapi_stack_t * stack , nsapi_socket_t handle , nsapi_addr_t * addr , uint16_t * port , void * data , nsapi_size_t size )
784
784
{
785
785
struct lwip_socket * s = (struct lwip_socket * )handle ;
786
786
struct netbuf * buf ;
@@ -799,7 +799,7 @@ static int mbed_lwip_socket_recvfrom(nsapi_stack_t *stack, nsapi_socket_t handle
799
799
return recv ;
800
800
}
801
801
802
- static int mbed_lwip_setsockopt (nsapi_stack_t * stack , nsapi_socket_t handle , int level , int optname , const void * optval , unsigned optlen )
802
+ static nsapi_error_t mbed_lwip_setsockopt (nsapi_stack_t * stack , nsapi_socket_t handle , int level , int optname , const void * optval , unsigned optlen )
803
803
{
804
804
struct lwip_socket * s = (struct lwip_socket * )handle ;
805
805
0 commit comments