Rev 2188 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2188 | Rev 2474 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
2 | * Copyright (c) 2006 Ondrej Palkovsky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
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 |
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. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
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 |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 |
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. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <stdio.h> |
29 | #include <stdio.h> |
30 | #include <unistd.h> |
30 | #include <unistd.h> |
31 | #include <async.h> |
31 | #include <async.h> |
32 | #include "../tester.h" |
32 | #include "../tester.h" |
33 | 33 | ||
34 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
34 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall) |
35 | { |
35 | { |
36 | ipc_callid_t callid; |
36 | ipc_callid_t callid; |
37 | ipc_call_t call; |
37 | ipc_call_t call; |
38 | ipcarg_t phonehash = icall->in_phone_hash; |
38 | ipcarg_t phonehash = icall->in_phone_hash; |
39 | int retval; |
39 | int retval; |
40 | int i; |
40 | int i; |
41 | 41 | ||
42 | printf("Connected phone: %P, accepting\n", icall->in_phone_hash); |
42 | printf("Connected phone: %P, accepting\n", icall->in_phone_hash); |
43 | ipc_answer_fast(iid, 0, 0, 0); |
43 | ipc_answer_fast(iid, 0, 0, 0); |
44 | for (i = 0; i < 1024; i++) |
44 | for (i = 0; i < 1024; i++) |
45 | if (!connections[i]) { |
45 | if (!connections[i]) { |
46 | connections[i] = phonehash; |
46 | connections[i] = phonehash; |
47 | break; |
47 | break; |
48 | } |
48 | } |
49 | 49 | ||
50 | while (1) { |
50 | while (1) { |
51 | callid = async_get_call(&call); |
51 | callid = async_get_call(&call); |
52 | switch (IPC_GET_METHOD(call)) { |
52 | switch (IPC_GET_METHOD(call)) { |
53 | case IPC_M_PHONE_HUNGUP: |
53 | case IPC_M_PHONE_HUNGUP: |
54 | printf("Phone (%P) hung up.\n", phonehash); |
54 | printf("Phone (%P) hung up.\n", phonehash); |
55 | retval = 0; |
55 | retval = 0; |
56 | break; |
56 | break; |
57 | default: |
57 | default: |
58 | printf("Received message from %P: %X\n", phonehash,callid); |
58 | printf("Received message from %P: %X\n", phonehash,callid); |
59 | for (i = 0; i < 1024; i++) |
59 | for (i = 0; i < 1024; i++) |
60 | if (!callids[i]) { |
60 | if (!callids[i]) { |
61 | callids[i] = callid; |
61 | callids[i] = callid; |
62 | break; |
62 | break; |
63 | } |
63 | } |
64 | continue; |
64 | continue; |
65 | } |
65 | } |
66 | ipc_answer_fast(callid, retval, 0, 0); |
66 | ipc_answer_fast(callid, retval, 0, 0); |
67 | } |
67 | } |
68 | } |
68 | } |
69 | 69 | ||
70 | char * test_register(bool quiet) |
70 | char * test_register(bool quiet) |
71 | { |
71 | { |
72 | int i; |
72 | int i; |
73 | 73 | ||
74 | async_set_client_connection(client_connection); |
74 | async_set_client_connection(client_connection); |
75 | 75 | ||
76 | for (i = IPC_TEST_START; i < IPC_TEST_START + 10; i++) { |
76 | for (i = IPC_TEST_START; i < IPC_TEST_START + 10; i++) { |
77 | ipcarg_t phonead; |
77 | ipcarg_t phonead; |
78 | int res = ipc_connect_to_me(PHONE_NS, i, 0, &phonead); |
78 | int res = ipc_connect_to_me(PHONE_NS, i, 0, &phonead); |
79 | if (!res) |
79 | if (!res) |
80 | break; |
80 | break; |
81 | printf("Failed registering as %d..:%d\n", i, res); |
81 | printf("Failed registering as %d..:%d\n", i, res); |
82 | } |
82 | } |
83 | printf("Registered as service: %d\n", i); |
83 | printf("Registered as service: %d\n", i); |
84 | myservice = i; |
84 | myservice = i; |
85 | 85 | ||
86 | return NULL; |
86 | return NULL; |
87 | } |
87 | } |
88 | 88 |