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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d517c5b 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
RevLine 
[21580dd]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
[a26b9e3]29/** @addtogroup libnet
[21580dd]30 * @{
31 */
32
33/** @file
[a26b9e3]34 * ICMP interface implementation for remote modules.
[f1938c6]35 * @see icmp_remote.h
[21580dd]36 */
37
[f1938c6]38#include <icmp_remote.h>
[a26b9e3]39#include <net/modules.h>
40#include <packet_client.h>
[21580dd]41#include <ipc/services.h>
[753bca3]42#include <ipc/icmp.h>
[21580dd]43#include <sys/types.h>
[6b82009]44#include <async.h>
45#include <errno.h>
[21580dd]46
[6b82009]47/** Send the Destination Unreachable error notification packet.
[a26b9e3]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 *
[6b82009]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 *
[a26b9e3]62 */
[6b82009]63int icmp_destination_unreachable_msg(async_sess_t *sess, icmp_code_t code,
[46d4d9f]64 icmp_param_t mtu, packet_t *packet)
[a26b9e3]65{
[6b82009]66 async_exch_t *exch = async_exchange_begin(sess);
67 async_msg_3(exch, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
[96b02eb9]68 (sysarg_t) packet_get_id(packet), (sysarg_t) mtu);
[6b82009]69 async_exchange_end(exch);
70
[21580dd]71 return EOK;
72}
73
[6b82009]74/** Send the Source Quench error notification packet.
[a26b9e3]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 *
[6b82009]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 *
[a26b9e3]87 */
[6b82009]88int icmp_source_quench_msg(async_sess_t *sess, packet_t *packet)
[a26b9e3]89{
[6b82009]90 async_exch_t *exch = async_exchange_begin(sess);
91 async_msg_2(exch, NET_ICMP_SOURCE_QUENCH, 0,
[96b02eb9]92 (sysarg_t) packet_get_id(packet));
[6b82009]93 async_exchange_end(exch);
94
[21580dd]95 return EOK;
96}
97
[6b82009]98/** Send the Time Exceeded error notification packet.
[a26b9e3]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 *
[6b82009]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 *
[a26b9e3]112 */
[6b82009]113int icmp_time_exceeded_msg(async_sess_t *sess, icmp_code_t code,
114 packet_t *packet)
[a26b9e3]115{
[6b82009]116 async_exch_t *exch = async_exchange_begin(sess);
117 async_msg_2(exch, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
[96b02eb9]118 (sysarg_t) packet_get_id(packet));
[6b82009]119 async_exchange_end(exch);
120
[21580dd]121 return EOK;
122}
123
[6b82009]124/** Send the Parameter Problem error notification packet.
[a26b9e3]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 *
[6b82009]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 *
[a26b9e3]139 */
[6b82009]140int icmp_parameter_problem_msg(async_sess_t *sess, icmp_code_t code,
[46d4d9f]141 icmp_param_t pointer, packet_t *packet)
[a26b9e3]142{
[6b82009]143 async_exch_t *exch = async_exchange_begin(sess);
144 async_msg_3(exch, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
[96b02eb9]145 (sysarg_t) packet_get_id(packet), (sysarg_t) pointer);
[6b82009]146 async_exchange_end(exch);
147
[21580dd]148 return EOK;
149}
150
151/** @}
152 */
Note: See TracBrowser for help on using the repository browser.