source: mainline/uspace/srv/net/tl/tcp/test.c@ 4c55a64

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

Remove old TCP module and replace it with a new one (WIP).

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * Copyright (c) 2011 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
35 */
36
37#include <async.h>
38#include <errno.h>
39#include <stdio.h>
40#include <thread.h>
41#include "state.h"
42#include "tcp_type.h"
43
44#include "test.h"
45
46static void test_srv(void *arg)
47{
48 tcp_conn_t *conn;
49 tcp_sock_t sock;
50
51 printf("test_srv()\n");
52 sock.port = 1024;
53 sock.addr.ipv4 = 0x7f000001;
54 tcp_uc_open(80, &sock, ap_passive, &conn);
55}
56
57static void test_cli(void *arg)
58{
59 tcp_conn_t *conn;
60 tcp_sock_t sock;
61
62 printf("test_cli()\n");
63
64 sock.port = 80;
65 sock.addr.ipv4 = 0x7f000001;
66
67 async_usleep(1000*1000*3);
68 tcp_uc_open(1024, &sock, ap_active, &conn);
69}
70
71void tcp_test(void)
72{
73 thread_id_t srv_tid;
74 thread_id_t cli_tid;
75 int rc;
76
77 printf("tcp_test()\n");
78
79 rc = thread_create(test_srv, NULL, "test_srv", &srv_tid);
80 if (rc != EOK) {
81 printf("Failed to create server thread.\n");
82 return;
83 }
84
85 rc = thread_create(test_cli, NULL, "test_cli", &cli_tid);
86 if (rc != EOK) {
87 printf("Failed to create client thread.\n");
88 return;
89 }
90}
91
92/**
93 * @}
94 */
Note: See TracBrowser for help on using the repository browser.