source: mainline/uspace/lib/net/tl/icmp_remote.c@ 8219eb9

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 8219eb9 was 6b82009, checked in by Martin Decky <martin@…>, 14 years ago

networking stack: convert to the new async framework

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2009 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 libnet
30 * @{
31 */
32
33/** @file
34 * ICMP interface implementation for remote modules.
35 * @see icmp_remote.h
36 */
37
38#include <icmp_remote.h>
39#include <net/modules.h>
40#include <packet_client.h>
41#include <ipc/services.h>
42#include <ipc/icmp.h>
43#include <sys/types.h>
44#include <async.h>
45#include <errno.h>
46
47/** Send the Destination Unreachable error notification packet.
48 *
49 * Beginning of the packet is sent as the notification packet data.
50 * The source and the destination addresses should be set in the original
51 * packet.
52 *
53 * @param[in] sess ICMP module session.
54 * @param[in] code Error specific code.
55 * @param[in] mtu Error MTU value.
56 * @param[in] packet Original packet.
57 *
58 * @return EOK on success.
59 * @return EPERM if the ICMP error notifications are disabled.
60 * @return ENOMEM if there is not enough memory left.
61 *
62 */
63int icmp_destination_unreachable_msg(async_sess_t *sess, icmp_code_t code,
64 icmp_param_t mtu, packet_t *packet)
65{
66 async_exch_t *exch = async_exchange_begin(sess);
67 async_msg_3(exch, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
68 (sysarg_t) packet_get_id(packet), (sysarg_t) mtu);
69 async_exchange_end(exch);
70
71 return EOK;
72}
73
74/** Send the Source Quench error notification packet.
75 *
76 * Beginning of the packet is sent as the notification packet data.
77 * The source and the destination addresses should be set in the original
78 * packet.
79 *
80 * @param[in] sess ICMP module session.
81 * @param[in] packet Original packet.
82 *
83 * @return EOK on success.
84 * @return EPERM if the ICMP error notifications are disabled.
85 * @return ENOMEM if there is not enough memory left.
86 *
87 */
88int icmp_source_quench_msg(async_sess_t *sess, packet_t *packet)
89{
90 async_exch_t *exch = async_exchange_begin(sess);
91 async_msg_2(exch, NET_ICMP_SOURCE_QUENCH, 0,
92 (sysarg_t) packet_get_id(packet));
93 async_exchange_end(exch);
94
95 return EOK;
96}
97
98/** Send the Time Exceeded error notification packet.
99 *
100 * Beginning of the packet is sent as the notification packet data.
101 * The source and the destination addresses should be set in the original
102 * packet.
103 *
104 * @param[in] sess ICMP module session.
105 * @param[in] code Error specific code.
106 * @param[in] packet Original packet.
107 *
108 * @return EOK on success.
109 * @return EPERM if the ICMP error notifications are disabled.
110 * @return ENOMEM if there is not enough memory left.
111 *
112 */
113int icmp_time_exceeded_msg(async_sess_t *sess, icmp_code_t code,
114 packet_t *packet)
115{
116 async_exch_t *exch = async_exchange_begin(sess);
117 async_msg_2(exch, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
118 (sysarg_t) packet_get_id(packet));
119 async_exchange_end(exch);
120
121 return EOK;
122}
123
124/** Send the Parameter Problem error notification packet.
125 *
126 * Beginning of the packet is sent as the notification packet data.
127 * The source and the destination addresses should be set in the original
128 * packet.
129 *
130 * @param[in] sess ICMP module session.
131 * @param[in] code Error specific code.
132 * @param[in] pointer Problematic parameter offset.
133 * @param[in] packet Original packet.
134 *
135 * @return EOK on success.
136 * @return EPERM if the ICMP error notifications are disabled.
137 * @return ENOMEM if there is not enough memory left.
138 *
139 */
140int icmp_parameter_problem_msg(async_sess_t *sess, icmp_code_t code,
141 icmp_param_t pointer, packet_t *packet)
142{
143 async_exch_t *exch = async_exchange_begin(sess);
144 async_msg_3(exch, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
145 (sysarg_t) packet_get_id(packet), (sysarg_t) pointer);
146 async_exchange_end(exch);
147
148 return EOK;
149}
150
151/** @}
152 */
Note: See TracBrowser for help on using the repository browser.