source: mainline/uspace/srv/net/tcp/tcp.c@ b7fd2a0

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b7fd2a0 was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[21580dd]1/*
[2f19103]2 * Copyright (c) 2015 Jiri Svoboda
[21580dd]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup tcp
[89e57cee]30 * @{
[21580dd]31 */
32
[c5808b41]33/**
34 * @file TCP (Transmission Control Protocol) network module
[21580dd]35 */
36
37#include <async.h>
[e98b1d5]38#include <errno.h>
[c5808b41]39#include <io/log.h>
40#include <stdio.h>
41#include <task.h>
[21580dd]42
[2989c7e]43#include "conn.h"
[42f61f01]44#include "inet.h"
[8218b6b]45#include "ncsim.h"
[c5808b41]46#include "rqueue.h"
[779541b]47#include "service.h"
[c5808b41]48#include "test.h"
[d14840d]49#include "ucall.h"
[21580dd]50
[c5808b41]51#define NAME "tcp"
[21580dd]52
[d14840d]53static tcp_rqueue_cb_t tcp_rqueue_cb = {
54 .seg_received = tcp_as_segment_arrived
55};
56
[b7fd2a0]57static errno_t tcp_init(void)
[7c8267b]58{
[b7fd2a0]59 errno_t rc;
[21580dd]60
[a1a101d]61 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_init()");
[1812a0d]62
[2989c7e]63 rc = tcp_conns_init();
64 if (rc != EOK) {
65 assert(rc == ENOMEM);
66 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing connections");
67 return ENOMEM;
68 }
69
[d14840d]70 tcp_rqueue_init(&tcp_rqueue_cb);
[88a6819]71 tcp_rqueue_fibril_start();
[1812a0d]72
[c76e926]73 tcp_ncsim_init();
[88a6819]74 tcp_ncsim_fibril_start();
[a4ee3ab2]75
[c76e926]76 if (0) tcp_test();
77
[42f61f01]78 rc = tcp_inet_init();
79 if (rc != EOK)
[1812a0d]80 return ENOENT;
[21580dd]81
[779541b]82 rc = tcp_service_init();
83 if (rc != EOK) {
84 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing service.");
85 return ENOENT;
86 }
[1812a0d]87
88 return EOK;
[21580dd]89}
90
[c5808b41]91int main(int argc, char **argv)
[7c8267b]92{
[b7fd2a0]93 errno_t rc;
[2e99277]94
[c5808b41]95 printf(NAME ": TCP (Transmission Control Protocol) network module\n");
[7c8267b]96
[267f235]97 rc = log_init(NAME);
[0578271]98 if (rc != EOK) {
[c5808b41]99 printf(NAME ": Failed to initialize log.\n");
100 return 1;
[21580dd]101 }
[7c8267b]102
[ecff3d9]103 rc = tcp_init();
104 if (rc != EOK)
105 return 1;
106
107 printf(NAME ": Accepting connections.\n");
[c76e926]108 task_retval(0);
[c5808b41]109 async_manager();
[849ed54]110
[c5808b41]111 /* Not reached */
112 return 0;
[014dd57b]113}
114
[c5808b41]115/**
116 * @}
[21580dd]117 */
Note: See TracBrowser for help on using the repository browser.