Skip to content

Commit

Permalink
adapt to msg api changes
Browse files Browse the repository at this point in the history
JIRA: RTOS-792
  • Loading branch information
lukileczo authored and agkaminski committed Mar 21, 2024
1 parent 612ece9 commit e0b34d3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 51 deletions.
49 changes: 27 additions & 22 deletions drivers/tuntap.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static err_t tap_output_cb(struct netif *netif, struct pbuf *p)
}


static int _tuntap_write(tuntap_priv_t *state, void *data, size_t size)
static int _tuntap_write(tuntap_priv_t *state, const void *data, size_t size)
{
struct pbuf *p;

Expand Down Expand Up @@ -149,28 +149,33 @@ static void tuntap_mainLoop(void* _state)

mutexLock(state->lock);
switch (msg.type) {
case mtOpen:
state->netif->flags |= NETIF_FLAG_LINK_UP;
break;
case mtClose:
state->netif->flags &= ~NETIF_FLAG_LINK_UP;
break;
case mtWrite:
msg.o.io.err = _tuntap_write(state, msg.i.data, msg.i.size);
break;
case mtRead:
msg.o.io.err = _tuntap_read(state, msg.o.data, msg.o.size);
break;
case mtGetAttr:
if (msg.i.attr.type != atPollStatus) {
msg.o.attr.err = -EINVAL;
case mtOpen:
state->netif->flags |= NETIF_FLAG_LINK_UP;
break;
case mtClose:
state->netif->flags &= ~NETIF_FLAG_LINK_UP;
break;
case mtWrite:
msg.o.err = _tuntap_write(state, msg.i.data, msg.i.size);

Check failure on line 159 in drivers/tuntap.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'
break;
case mtRead:
msg.o.err = _tuntap_read(state, msg.o.data, msg.o.size);

Check failure on line 162 in drivers/tuntap.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'
break;
case mtGetAttr:
if (msg.i.attr.type != atPollStatus) {
msg.o.err = -EINVAL;

Check failure on line 166 in drivers/tuntap.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'
break;
}
msg.o.attr.val = POLLOUT;
if (!fifo_is_empty(state->queue)) {
msg.o.attr.val |= POLLIN;
}
msg.o.err = EOK;

Check failure on line 173 in drivers/tuntap.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'
break;

default:
msg.o.err = -EINVAL;

Check failure on line 177 in drivers/tuntap.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7a7-imx6ull-evk)

'struct <anonymous>' has no member named 'err'
break;
}
msg.o.attr.val = POLLOUT;
if (!fifo_is_empty(state->queue))
msg.o.attr.val |= POLLIN;
msg.o.attr.err = EOK;
break;
}
mutexUnlock(state->lock);

Expand Down
8 changes: 4 additions & 4 deletions port/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ static void mainLoop(void)

switch (msg.type) {
case mtOpen:
msg.o.io.err = dev_open(msg.i.openclose.oid.id, msg.i.openclose.flags);
msg.o.err = dev_open(msg.oid.id, msg.i.openclose.flags);

Check failure on line 49 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 49 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

case mtClose:
msg.o.io.err = dev_close(msg.i.openclose.oid.id);
msg.o.err = dev_close(msg.oid.id);

Check failure on line 53 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 53 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

case mtRead:
msg.o.io.err = dev_read(msg.i.openclose.oid.id, msg.o.data, msg.o.size, msg.i.io.offs);
msg.o.err = dev_read(msg.oid.id, msg.o.data, msg.o.size, msg.i.io.offs);

Check failure on line 57 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 57 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

case mtWrite:
msg.o.io.err = dev_write(msg.i.openclose.oid.id, msg.i.data, msg.i.size, msg.i.io.offs);
msg.o.err = dev_write(msg.oid.id, msg.i.data, msg.i.size, msg.i.io.offs);

Check failure on line 61 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'struct <anonymous>' has no member named 'err'

Check failure on line 61 in port/main.c

View workflow job for this annotation

GitHub Actions / call-ci / build (armv7m7-imxrt106x-evk)

'msg_t' {aka 'struct _msg_t'} has no member named 'oid'; did you mean 'pid'?
break;

default:
Expand Down
39 changes: 19 additions & 20 deletions port/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,7 @@ static void do_socket_ioctl(msg_t *msg, int sock)
void *out_data = NULL;
const void *in_data = ioctl_unpackEx(msg, &request, NULL, &out_data);

int err = socket_ioctl(sock, request, in_data, out_data);
ioctl_setResponseErr(msg, request, err);
msg->o.err = socket_ioctl(sock, request, in_data, out_data);
}


Expand Down Expand Up @@ -696,21 +695,21 @@ static int socket_op(msg_t *msg, int sock)
smo->ret = -EINVAL;
break;
case mtRead:
msg->o.io.err = map_errno(key_sockets_recv(sock, msg->o.data, msg->o.size, 0));
msg->o.err = map_errno(key_sockets_recv(sock, msg->o.data, msg->o.size, 0));
break;
case mtWrite:
msg->o.io.err = map_errno(key_sockets_send(sock, msg->i.data, msg->i.size, 0));
msg->o.err = map_errno(key_sockets_send(sock, msg->i.data, msg->i.size, 0));
break;
case mtGetAttr:
if (msg->i.attr.type != atPollStatus) {
msg->o.attr.err = -EINVAL;
msg->o.err = -EINVAL;
break;
}
msg->o.attr.val = key_sockets_poll(sock, msg->i.attr.val, 0);
msg->o.attr.err = (msg->o.attr.val < 0) ? msg->o.attr.val : EOK;
msg->o.err = (msg->o.attr.val < 0) ? msg->o.attr.val : EOK;
break;
case mtClose:
msg->o.io.err = map_errno(key_sockets_close(sock));
msg->o.err = map_errno(key_sockets_close(sock));
return 1;
case sockmGetSockName:
smo->ret = -EINVAL;
Expand Down Expand Up @@ -796,26 +795,26 @@ static int socket_op(msg_t *msg, int sock)
break;
case mtRead:
if (msg->o.size <= SSIZE_MAX)
msg->o.io.err = map_errno(lwip_read(sock, msg->o.data, msg->o.size));
msg->o.err = map_errno(lwip_read(sock, msg->o.data, msg->o.size));
else
msg->o.io.err = -EINVAL;
msg->o.err = -EINVAL;
break;
case mtWrite:
if (msg->i.size <= SSIZE_MAX)
msg->o.io.err = map_errno(lwip_write(sock, msg->i.data, msg->i.size));
msg->o.err = map_errno(lwip_write(sock, msg->i.data, msg->i.size));
else
msg->o.io.err = -EINVAL;
msg->o.err = -EINVAL;
break;
case mtGetAttr:
if (msg->i.attr.type != atPollStatus) {
msg->o.attr.err = -EINVAL;
msg->o.err = -EINVAL;
break;
}
msg->o.attr.val = poll_one(&polls, msg->i.attr.val, 0);
msg->o.attr.err = (msg->o.attr.val < 0) ? msg->o.attr.val : EOK;
msg->o.err = (msg->o.attr.val < 0) ? msg->o.attr.val : EOK;
break;
case mtClose:
msg->o.io.err = map_errno(lwip_close(sock));
msg->o.err = map_errno(lwip_close(sock));
return 1;
case mtDevCtl:
do_socket_ioctl(msg, sock);
Expand Down Expand Up @@ -1146,21 +1145,21 @@ static void socketsrv_thread(void *arg)
if (smi->socket.domain == AF_KEY) {
#if LWIP_IPSEC
if ((sock = key_sockets_socket(smi->socket.domain, type, smi->socket.protocol)) < 0) {
msg.o.lookup.err = -errno;
msg.o.err = -errno;
}
else {
msg.o.lookup.err = wrap_key_socket(&msg.o.lookup.dev.port, sock, smi->socket.type);
msg.o.err = wrap_key_socket(&msg.o.lookup.dev.port, sock, smi->socket.type);
msg.o.lookup.fil = msg.o.lookup.dev;
}
#else
msg.o.lookup.err = -EINVAL;
msg.o.err = -EINVAL;
#endif /* LWIP_IPSEC */
break;
}
if ((sock = lwip_socket(smi->socket.domain, type, smi->socket.protocol)) < 0)
msg.o.lookup.err = -errno;
msg.o.err = -errno;
else {
msg.o.lookup.err = wrap_socket(&msg.o.lookup.dev.port, sock, smi->socket.type);
msg.o.err = wrap_socket(&msg.o.lookup.dev.port, sock, smi->socket.type);
msg.o.lookup.fil = msg.o.lookup.dev;
}
break;
Expand Down Expand Up @@ -1204,7 +1203,7 @@ static void socketsrv_thread(void *arg)
smo->sys.err = smo->ret == EAI_SYSTEM ? errno : 0;
break;
default:
msg.o.io.err = -EINVAL;
msg.o.err = -EINVAL;
}

msgRespond(port, &msg, respid);
Expand Down
10 changes: 5 additions & 5 deletions wi-fi/lwip/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,23 +495,23 @@ static void wifi_msg_thread(void *arg)

switch (msg.type) {
case mtOpen:
msg.o.io.err = wifi_dev_open(msg.i.openclose.flags);
msg.o.err = wifi_dev_open(msg.i.openclose.flags);
break;

case mtClose:
msg.o.io.err = wifi_dev_close();
msg.o.err = wifi_dev_close();
break;

case mtRead:
msg.o.io.err = wifi_dev_read(msg.o.data, msg.o.size, msg.i.io.offs);
msg.o.err = wifi_dev_read(msg.o.data, msg.o.size, msg.i.io.offs);
break;

case mtWrite:
msg.o.io.err = wifi_dev_write(msg.i.data, msg.i.size);
msg.o.err = wifi_dev_write(msg.i.data, msg.i.size);
break;

default:
msg.o.io.err = -EINVAL;
msg.o.err = -EINVAL;
break;
}

Expand Down

0 comments on commit e0b34d3

Please sign in to comment.