1 | /*
|
---|
2 | * Copyright (c) 2008 Lukas Mejdrech
|
---|
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 icmp
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /** @file
|
---|
34 | * ICMP module.
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef NET_ICMP_H_
|
---|
38 | #define NET_ICMP_H_
|
---|
39 |
|
---|
40 | #include <fibril_synch.h>
|
---|
41 |
|
---|
42 | #include <net/icmp_codes.h>
|
---|
43 | #include <net/packet.h>
|
---|
44 | #include <adt/int_map.h>
|
---|
45 | #include <icmp_header.h>
|
---|
46 |
|
---|
47 | /** Type definition of the ICMP reply data.
|
---|
48 | * @see icmp_reply
|
---|
49 | */
|
---|
50 | typedef struct icmp_reply icmp_reply_t;
|
---|
51 |
|
---|
52 | /** Type definition of the ICMP global data.
|
---|
53 | * @see icmp_globals
|
---|
54 | */
|
---|
55 | typedef struct icmp_globals icmp_globals_t;
|
---|
56 |
|
---|
57 | /** Pending replies map.
|
---|
58 | *
|
---|
59 | * Maps message identifiers to the pending replies.
|
---|
60 | * Sending fibril waits for its associated reply event.
|
---|
61 | * Receiving fibril sets the associated reply with the return value and signals
|
---|
62 | * the event.
|
---|
63 | */
|
---|
64 | INT_MAP_DECLARE(icmp_replies, icmp_reply_t);
|
---|
65 |
|
---|
66 | /** Echo specific data map.
|
---|
67 | *
|
---|
68 | * The identifier is used in the future semi-remote calls instead of the ICMP
|
---|
69 | * phone.
|
---|
70 | */
|
---|
71 | INT_MAP_DECLARE(icmp_echo_data, icmp_echo_t);
|
---|
72 |
|
---|
73 | /** ICMP reply data. */
|
---|
74 | struct icmp_reply {
|
---|
75 | /** Reply result. */
|
---|
76 | int result;
|
---|
77 | /** Safety lock. */
|
---|
78 | fibril_mutex_t mutex;
|
---|
79 | /** Received or timeouted reply signaling. */
|
---|
80 | fibril_condvar_t condvar;
|
---|
81 | };
|
---|
82 |
|
---|
83 | /** ICMP global data. */
|
---|
84 | struct icmp_globals {
|
---|
85 | /** IP module phone. */
|
---|
86 | int ip_phone;
|
---|
87 | /** Packet dimension. */
|
---|
88 | packet_dimension_t packet_dimension;
|
---|
89 | /** Networking module phone. */
|
---|
90 | int net_phone;
|
---|
91 | /** Indicates whether ICMP error reporting is enabled. */
|
---|
92 | int error_reporting;
|
---|
93 | /** Indicates whether ICMP echo replying (ping) is enabled. */
|
---|
94 | int echo_replying;
|
---|
95 | /** The last used identifier number. */
|
---|
96 | icmp_param_t last_used_id;
|
---|
97 | /** The budled modules assigned echo specific data. */
|
---|
98 | icmp_echo_data_t echo_data;
|
---|
99 | /** Echo timeout locks. */
|
---|
100 | icmp_replies_t replies;
|
---|
101 | /** Safety lock. */
|
---|
102 | fibril_rwlock_t lock;
|
---|
103 | };
|
---|
104 |
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | /** @}
|
---|
108 | */
|
---|