Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion samples/tmo_shell/src/tmo_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,13 @@ int sock_connect(const struct shell *shell, size_t argc, char **argv)
int ret;
char *host;
struct sockaddr target;
errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
char *port_st = argv[3];
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
Expand Down Expand Up @@ -680,7 +686,13 @@ int sock_bind(const struct shell *shell, size_t argc, char **argv)
shell_help(shell);
return -EINVAL;
}
errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -713,7 +725,13 @@ int sock_send(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -745,7 +763,13 @@ int sock_sendto(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -834,7 +858,13 @@ int sock_sendb(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -929,7 +959,13 @@ int sock_recvb(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -984,6 +1020,11 @@ int sock_rcv(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}
int sd = (int)strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -1029,6 +1070,11 @@ int sock_rcvfrom(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}
int sd = (int)strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -1083,7 +1129,13 @@ int sock_close(const struct shell *shell, size_t argc, char **argv)
shell_help(shell);
return -EINVAL;
}
errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -1120,7 +1172,13 @@ int sock_sendsms(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);
if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down Expand Up @@ -1152,9 +1210,19 @@ int sock_recvsms(const struct shell *shell, size_t argc, char **argv)
return -EINVAL;
}

errno = 0;
int sd = strtol(argv[1], NULL, 10);

if (errno != 0) {
shell_error(shell, "Socket %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int wait = strtol(argv[2], NULL, 10);
if (errno != 0 && errno != ERANGE) {
shell_error(shell, "Timeout %s is invalid, errno = %d; %s", argv[1], errno,
strerror(errno));
return errno;
}
int sock_idx;
for (sock_idx = 0; sock_idx < MAX_SOCK_REC; sock_idx++) {
if (socks[sock_idx].sd == sd && socks[sock_idx].flags & BIT(sock_open)) {
Expand Down