Lines Matching +full:short +full:- +full:codes
2 * Copyright (c) 2019-2020 Foundries.io
4 * SPDX-License-Identifier: Apache-2.0
209 int rc = -1; in find_apn()
219 s--; in find_apn()
223 s--; in find_apn()
231 s--; in find_apn()
237 int len = eos - s; in find_apn()
255 int rc = -1; in modem_detect_apn()
262 strncat(mmcmnc, imsi, sizeof(mmcmnc)-1); in modem_detect_apn()
303 struct sockaddr *dst_addr = msg->msg_name; in send_socket_data()
307 return -EINVAL; in send_socket_data()
310 for (int i = 0; i < msg->msg_iovlen; i++) { in send_socket_data()
311 if (!msg->msg_iov[i].iov_base || msg->msg_iov[i].iov_len == 0) { in send_socket_data()
313 return -1; in send_socket_data()
315 buf_len += msg->msg_iov[i].iov_len; in send_socket_data()
318 if (!sock->is_connected && sock->ip_proto != IPPROTO_UDP) { in send_socket_data()
320 return -1; in send_socket_data()
323 if (!dst_addr && sock->ip_proto == IPPROTO_UDP) { in send_socket_data()
324 dst_addr = &sock->dst; in send_socket_data()
332 if (sock->type == SOCK_DGRAM) { in send_socket_data()
334 return -1; in send_socket_data()
343 if (sock->ip_proto == IPPROTO_UDP) { in send_socket_data()
359 "AT+USOST=%d,\"%s\",%u,%zu", sock->id, in send_socket_data()
364 sock->id, buf_len); in send_socket_data()
390 ret = -ETIMEDOUT; in send_socket_data()
401 if (sock->ip_proto != IPPROTO_UDP) { in send_socket_data()
412 for (int i = 0; i < msg->msg_iovlen; i++) { in send_socket_data()
413 int len = MIN(buf_len, msg->msg_iov[i].iov_len); in send_socket_data()
418 mctx.iface.write(&mctx.iface, msg->msg_iov[i].iov_base, len); in send_socket_data()
419 buf_len -= len; in send_socket_data()
430 } else if (ret == -EAGAIN) { in send_socket_data()
431 ret = -ETIMEDOUT; in send_socket_data()
461 return -EINVAL; in send_cert()
465 return -EINVAL; in send_cert()
498 } else if (ret == -EAGAIN) { in send_cert()
499 ret = -ETIMEDOUT; in send_cert()
538 modem_cmd_handler_set_error(data, -EIO); in MODEM_CMD_DEFINE()
546 /* TODO: map extended error codes to values */ in MODEM_CMD_DEFINE()
547 modem_cmd_handler_set_error(data, -EIO); in MODEM_CMD_DEFINE()
562 sizeof(mdata.mdm_manufacturer) - 1, in MODEM_CMD_DEFINE()
563 data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
575 sizeof(mdata.mdm_model) - 1, in MODEM_CMD_DEFINE()
576 data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
601 sizeof(mdata.mdm_revision) - 1, in MODEM_CMD_DEFINE()
602 data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
613 out_len = net_buf_linearize(mdata.mdm_imei, sizeof(mdata.mdm_imei) - 1, in MODEM_CMD_DEFINE()
614 data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
625 out_len = net_buf_linearize(mdata.mdm_imsi, sizeof(mdata.mdm_imsi) - 1, in MODEM_CMD_DEFINE()
626 data->rx_buf, 0, len); in MODEM_CMD_DEFINE()
649 mdata.mdm_rssi = -140 + (rsrp - 1); in MODEM_CMD_DEFINE()
652 mdata.mdm_rssi = -110 + (rxlev - 1); in MODEM_CMD_DEFINE()
655 mdata.mdm_rssi = -1000; in MODEM_CMD_DEFINE()
672 mdata.mdm_rssi = -46; in MODEM_CMD_DEFINE()
675 mdata.mdm_rssi = -110 + ((rssi * 2) + 1); in MODEM_CMD_DEFINE()
677 mdata.mdm_rssi = -1000; in MODEM_CMD_DEFINE()
746 id = ATOI(argv[0], -1, "socket_id"); in MODEM_CMD_DEFINE()
750 modem_socket_put(&mdata.socket_config, sock->sock_fd); in MODEM_CMD_DEFINE()
754 /* don't give back semaphore -- OK to follow */ in MODEM_CMD_DEFINE()
785 LOG_ERR("Short +USOR[D|F] value. Aborting!"); in on_cmd_sockread_common()
786 return -EAGAIN; in on_cmd_sockread_common()
793 if (!data->rx_buf || *data->rx_buf->data != '\"') { in on_cmd_sockread_common()
795 return -EINVAL; in on_cmd_sockread_common()
801 return -EAGAIN; in on_cmd_sockread_common()
805 if ((net_buf_frags_len(data->rx_buf) - 2) < socket_data_length) { in on_cmd_sockread_common()
806 LOG_DBG("Not enough data -- wait!"); in on_cmd_sockread_common()
807 return -EAGAIN; in on_cmd_sockread_common()
811 len--; in on_cmd_sockread_common()
812 net_buf_pull_u8(data->rx_buf); in on_cmd_sockread_common()
813 if (!data->rx_buf->len) { in on_cmd_sockread_common()
814 data->rx_buf = net_buf_frag_del(NULL, data->rx_buf); in on_cmd_sockread_common()
820 ret = -EINVAL; in on_cmd_sockread_common()
824 sock_data = (struct socket_read_data *)sock->data; in on_cmd_sockread_common()
827 ret = -EINVAL; in on_cmd_sockread_common()
831 ret = net_buf_linearize(sock_data->recv_buf, sock_data->recv_buf_len, in on_cmd_sockread_common()
832 data->rx_buf, 0, (uint16_t)socket_data_length); in on_cmd_sockread_common()
833 data->rx_buf = net_buf_skip(data->rx_buf, ret); in on_cmd_sockread_common()
834 sock_data->recv_read_len = ret; in on_cmd_sockread_common()
838 ret = -EINVAL; in on_cmd_sockread_common()
844 -socket_data_length); in on_cmd_sockread_common()
846 /* don't give back semaphore -- OK to follow */ in on_cmd_sockread_common()
874 argv[0][strlen(argv[0]) - 1] = '\0'; in MODEM_CMD_DEFINE()
876 /* FIXME: Hard-code DNS on SARA-R4 to return IPv4 */ in MODEM_CMD_DEFINE()
880 &((struct sockaddr_in *)&result_addr)->sin_addr); in MODEM_CMD_DEFINE()
897 sock->is_connected = false; in MODEM_CMD_DEFINE()
961 LOG_DBG("MDM_RESET_PIN -> NOT_ASSERTED"); in pin_init()
965 LOG_DBG("MDM_POWER_PIN -> ENABLE"); in pin_init()
969 LOG_DBG("MDM_POWER_PIN -> DISABLE"); in pin_init()
976 LOG_DBG("MDM_POWER_PIN -> ENABLE"); in pin_init()
987 LOG_DBG("MDM_POWER_PIN -> DISABLE"); in pin_init()
990 LOG_DBG("MDM_POWER_PIN -> ENABLE"); in pin_init()
999 LOG_DBG("MDM_POWER_PIN -> DISABLE"); in pin_init()
1005 k_usleep(50); /* 50-80 microseconds */ in pin_init()
1013 LOG_DBG("MDM_POWER_PIN -> ENABLE"); in pin_init()
1073 /* re-start RSSI query work */ in modem_rssi_query_work()
1116 /* re-start RSSI query work */ in modem_rssi_query_work()
1198 sizeof(mdata.mdm_apn)-1); in modem_reset()
1213 ret = -1; in modem_reset()
1219 if (ret < 0 && ret != -ETIMEDOUT) { in modem_reset()
1313 /* wait for RSSI < 0 and > -1000 */ in modem_reset()
1316 mdata.mdm_rssi <= -1000)) { in modem_reset()
1321 if (mdata.mdm_rssi >= 0 || mdata.mdm_rssi <= -1000) { in modem_reset()
1325 ret = -ENETUNREACH; in modem_reset()
1394 if (addr->sa_family == AF_INET6) { in create_socket()
1395 local_port = ntohs(net_sin6(addr)->sin6_port); in create_socket()
1396 } else if (addr->sa_family == AF_INET) { in create_socket()
1397 local_port = ntohs(net_sin(addr)->sin_port); in create_socket()
1401 if (sock->ip_proto == IPPROTO_UDP) { in create_socket()
1419 if (sock->ip_proto == IPPROTO_TLS_1_2) { in create_socket()
1423 snprintk(atbuf, sizeof(atbuf), "AT+USOSEC=%d,1,%d", sock->id, sock->id); in create_socket()
1430 snprintk(atbuf, sizeof(atbuf), "AT+USECPRF=%d", sock->id); in create_socket()
1437 snprintk(atbuf, sizeof(atbuf), "AT+USECPRF=%d,0,1", sock->id); in create_socket()
1444 snprintk(atbuf, sizeof(atbuf), "AT+USECPRF=%d,1,3", sock->id); in create_socket()
1451 snprintk(atbuf, sizeof(atbuf), "AT+USECPRF=%d,3,\"ca\"", sock->id); in create_socket()
1464 modem_socket_put(&mdata.socket_config, sock->sock_fd); in create_socket()
1465 errno = -ret; in create_socket()
1466 return -1; in create_socket()
1482 errno = -ret; in offload_socket()
1483 return -1; in offload_socket()
1501 if (sock->is_connected || sock->ip_proto == IPPROTO_UDP) { in offload_close()
1502 snprintk(buf, sizeof(buf), "AT+USOCL=%d", sock->id); in offload_close()
1512 modem_socket_put(&mdata.socket_config, sock->sock_fd); in offload_close()
1522 memcpy(&sock->src, addr, sizeof(*addr)); in offload_bind()
1527 return -1; in offload_bind()
1545 return -1; in offload_connect()
1551 sock->id, sock->sock_fd); in offload_connect()
1553 return -1; in offload_connect()
1559 return -1; in offload_connect()
1563 memcpy(&sock->dst, addr, sizeof(*addr)); in offload_connect()
1564 if (addr->sa_family == AF_INET6) { in offload_connect()
1565 dst_port = ntohs(net_sin6(addr)->sin6_port); in offload_connect()
1566 } else if (addr->sa_family == AF_INET) { in offload_connect()
1567 dst_port = ntohs(net_sin(addr)->sin_port); in offload_connect()
1570 return -1; in offload_connect()
1574 if (sock->ip_proto == IPPROTO_UDP) { in offload_connect()
1581 errno = -ret; in offload_connect()
1583 return -1; in offload_connect()
1586 snprintk(buf, sizeof(buf), "AT+USOCO=%d,\"%s\",%d", sock->id, in offload_connect()
1593 errno = -ret; in offload_connect()
1594 return -1; in offload_connect()
1597 sock->is_connected = true; in offload_connect()
1617 return -1; in offload_recvfrom()
1622 return -1; in offload_recvfrom()
1630 return -1; in offload_recvfrom()
1633 if (!sock->is_connected && sock->ip_proto != IPPROTO_UDP) { in offload_recvfrom()
1652 sock->ip_proto == IPPROTO_UDP ? "RF" : "RD", sock->id, in offload_recvfrom()
1660 sock->data = &sock_data; in offload_recvfrom()
1666 errno = -ret; in offload_recvfrom()
1667 ret = -1; in offload_recvfrom()
1673 *fromlen = sizeof(sock->dst); in offload_recvfrom()
1674 memcpy(from, &sock->dst, *fromlen); in offload_recvfrom()
1683 sock->data = NULL; in offload_recvfrom()
1704 errno = -ret; in offload_sendto()
1705 return -1; in offload_sendto()
1741 return -1; in offload_ioctl()
1761 .msg_name = msg->msg_name, in offload_sendmsg()
1762 .msg_namelen = msg->msg_namelen, in offload_sendmsg()
1768 for (int i = 0; i < msg->msg_iovlen; i++) { in offload_sendmsg()
1769 if (!msg->msg_iov[i].iov_base || msg->msg_iov[i].iov_len == 0) { in offload_sendmsg()
1771 return -1; in offload_sendmsg()
1773 full_len += msg->msg_iov[i].iov_len; in offload_sendmsg()
1777 msg->msg_iovlen, flags, full_len); in offload_sendmsg()
1783 crafted_msg.msg_iovlen = msg->msg_iovlen; in offload_sendmsg()
1784 crafted_msg.msg_iov = &msg->msg_iov[0]; in offload_sendmsg()
1786 bkp_iovec_idx = -1; in offload_sendmsg()
1789 int to_removed = sent - removed; in offload_sendmsg()
1791 if (to_removed >= msg->msg_iov[i].iov_len) { in offload_sendmsg()
1792 crafted_msg.msg_iovlen -= 1; in offload_sendmsg()
1793 crafted_msg.msg_iov = &msg->msg_iov[i + 1]; in offload_sendmsg()
1795 removed += msg->msg_iov[i].iov_len; in offload_sendmsg()
1797 /* Backup msg->msg_iov[i] before "removing" in offload_sendmsg()
1801 bkp_iovec.iov_len = msg->msg_iov[i].iov_len; in offload_sendmsg()
1802 bkp_iovec.iov_base = msg->msg_iov[i].iov_base; in offload_sendmsg()
1804 /* Update msg->msg_iov[i] to "remove" in offload_sendmsg()
1807 msg->msg_iov[i].iov_len -= to_removed; in offload_sendmsg()
1808 msg->msg_iov[i].iov_base = &(((uint8_t *)msg->msg_iov[i].iov_base)[to_removed]); in offload_sendmsg()
1819 if (bkp_iovec_idx != -1) { in offload_sendmsg()
1820 msg->msg_iov[bkp_iovec_idx].iov_len = bkp_iovec.iov_len; in offload_sendmsg()
1821 msg->msg_iov[bkp_iovec_idx].iov_base = bkp_iovec.iov_base; in offload_sendmsg()
1826 errno = -ret; in offload_sendmsg()
1827 return -1; in offload_sendmsg()
1848 return -EINVAL; in map_credentials()
1857 switch (cert->type) { in map_credentials()
1866 return -EINVAL; in map_credentials()
1871 ret = send_cert(sock, cmd, 1, cert->buf, cert->len, id); in map_credentials()
1885 return -EINVAL; in map_credentials()
1903 return -EINVAL; in offload_setsockopt()
1907 return -EINVAL; in offload_setsockopt()
1912 return -EINVAL; in offload_setsockopt()
1915 return -EINVAL; in offload_setsockopt()
1965 /* TODO: This is a bare-bones implementation of DNS handling
1983 /* FIXME: Hard-code DNS to return only IPv4 */ in offload_getaddrinfo()
1999 /* FIXME: DNS is hard-coded to return only IPv4 */ in offload_getaddrinfo()
2001 net_sin(&result_addr)->sin_port = htons(port); in offload_getaddrinfo()
2007 &((struct sockaddr_in *)&result_addr)->sin_addr) in offload_getaddrinfo()
2014 if (hints && hints->ai_flags & AI_NUMERICHOST) { in offload_getaddrinfo()
2028 &net_sin(&result_addr)->sin_addr, in offload_getaddrinfo()
2037 /* using static result from offload_getaddrinfo() -- no need to free */ in offload_freeaddrinfo()
2055 return -ENOTSUP; in net_offload_dummy_get()
2078 struct modem_data *data = dev->data; in modem_get_mac()
2081 data->mac_addr[0] = 0x00; in modem_get_mac()
2082 data->mac_addr[1] = 0x10; in modem_get_mac()
2087 UNALIGNED_PUT(hash_value, (uint32_t *)(data->mac_addr + 2)); in modem_get_mac()
2089 return data->mac_addr; in modem_get_mac()
2097 struct modem_data *data = dev->data; in modem_net_iface_init()
2100 iface->if_dev->offload = &modem_net_offload; in modem_net_iface_init()
2102 sizeof(data->mac_addr), in modem_net_iface_init()
2104 data->net_iface = iface; in modem_net_iface_init()