source: mainline/uspace/srv/net/tcp/tcp.c@ 36f0738

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 36f0738 was d14840d, checked in by Jiri Svoboda <jiri@…>, 8 years ago

Add test for TCP rqueue.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2015 Jiri Svoboda
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
30 * @{
31 */
32
33/**
34 * @file TCP (Transmission Control Protocol) network module
35 */
36
37#include <async.h>
38#include <errno.h>
39#include <io/log.h>
40#include <stdio.h>
41#include <task.h>
42
43#include "conn.h"
44#include "inet.h"
45#include "ncsim.h"
46#include "rqueue.h"
47#include "service.h"
48#include "test.h"
49#include "ucall.h"
50
51#define NAME "tcp"
52
53static tcp_rqueue_cb_t tcp_rqueue_cb = {
54 .seg_received = tcp_as_segment_arrived
55};
56
57static int tcp_init(void)
58{
59 int rc;
60
61 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_init()");
62
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
70 tcp_rqueue_init(&tcp_rqueue_cb);
71 tcp_rqueue_fibril_start();
72
73 tcp_ncsim_init();
74 tcp_ncsim_fibril_start();
75
76 if (0) tcp_test();
77
78 rc = tcp_inet_init();
79 if (rc != EOK)
80 return ENOENT;
81
82 rc = tcp_service_init();
83 if (rc != EOK) {
84 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing service.");
85 return ENOENT;
86 }
87
88 return EOK;
89}
90
91int main(int argc, char **argv)
92{
93 int rc;
94
95 printf(NAME ": TCP (Transmission Control Protocol) network module\n");
96
97 rc = log_init(NAME);
98 if (rc != EOK) {
99 printf(NAME ": Failed to initialize log.\n");
100 return 1;
101 }
102
103 rc = tcp_init();
104 if (rc != EOK)
105 return 1;
106
107 printf(NAME ": Accepting connections.\n");
108 task_retval(0);
109 async_manager();
110
111 /* Not reached */
112 return 0;
113}
114
115/**
116 * @}
117 */
Note: See TracBrowser for help on using the repository browser.