aboutsummaryrefslogtreecommitdiff
path: root/src/run.c
blob: 8ef952f20a642f2590384b8f5ca0f1524137aba6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * wip, a small TCP/IP stack.
 * Copyright (C) 2025  Xavier Del Campo Romero
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#include <wip/wip.h>
#include <wip/prv/routines.h>

int wip_run(struct wip *const w)
{
    enum wip_state n;

again:

    switch ((n = w->rx.next(w)))
    {
        case WIP_OK:
            goto again;

        case WIP_AGAIN:
            break;

        case WIP_FATAL:
            return -1;

        case WIP_INVALID:
            wip_rx(w);
            break;
    }

#if 0
    switch (w->tx.next(w))
    {
        case WIP_OK:
        case WIP_AGAIN:
            break;

        case WIP_INVALID:
        case WIP_FATAL:
            return -1;
    }
#endif

    return 0;
}