Merge pull request #6702 from AriParkkila/single-stack

Cellular: Fix to prefer IPv6 single stack with fallback to IPv4
pull/6735/head
Cruz Monrreal 2018-04-24 12:16:34 -05:00 committed by GitHub
commit 4c973e3aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View File

@ -459,7 +459,7 @@ bool AT_CellularNetwork::set_new_context(int cid)
strncpy(pdp_type, "IPV6", sizeof(pdp_type));
break;
case IPV4V6_STACK:
strncpy(pdp_type, "IPV4V6", sizeof(pdp_type));
strncpy(pdp_type, "IPV6", sizeof(pdp_type)); // try first IPV6 and then fall-back to IPv4
break;
default:
break;

View File

@ -81,6 +81,11 @@ const char * AT_CellularStack::get_ip_address()
return _ip;
}
nsapi_error_t AT_CellularStack::socket_stack_init()
{
return NSAPI_ERROR_OK;
}
nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
{
if (!is_protocol_supported(proto) || !handle) {
@ -90,6 +95,10 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
int max_socket_count = get_max_socket_count();
if (!_socket) {
if (socket_stack_init() != NSAPI_ERROR_OK) {
return NSAPI_ERROR_NO_SOCKET;
}
_socket = new CellularSocket*[max_socket_count];
if (!_socket) {
tr_error("No memory to open socket!");

View File

@ -46,6 +46,13 @@ public: // NetworkStack
virtual const char *get_ip_address();
protected: // NetworkStack
/**
* Modem specific socket stack initialization
*
* @return 0 on success
*/
virtual nsapi_error_t socket_stack_init();
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto);
virtual nsapi_error_t socket_close(nsapi_socket_t handle);
@ -87,8 +94,10 @@ protected:
SocketAddress localAddress;
void (*_cb)(void *);
void *_data;
bool created;
bool rx_avail; // used to synchronize reading from modem
bool created; // socket has been created on modem stack
bool started; // socket has been opened on modem stack
bool tx_ready; // socket is ready for sending on modem stack
bool rx_avail; // socket has data for reading on modem stack
};
/**