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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 014dd57b was 96b02eb9, checked in by Martin Decky <martin@…>, 15 years ago

more unification of basic types

  • use sysarg_t and native_t (unsigned and signed variant) in both kernel and uspace
  • remove ipcarg_t in favour of sysarg_t

(no change in functionality)

  • Property mode set to 100644
File size: 4.8 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.
35 * @see icmp_interface.h
[21580dd]36 */
37
[a26b9e3]38#include <icmp_interface.h>
39#include <net/modules.h>
40#include <packet_client.h>
41
[21580dd]42#include <async.h>
43#include <errno.h>
44#include <ipc/ipc.h>
45#include <ipc/services.h>
[753bca3]46#include <ipc/icmp.h>
[21580dd]47#include <sys/types.h>
48
[a26b9e3]49/** Sends the Destination Unreachable error notification packet.
50 *
51 * Beginning of the packet is sent as the notification packet data.
52 * The source and the destination addresses should be set in the original
53 * packet.
54 *
55 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
56 * @param[in] code The error specific code.
57 * @param[in] mtu The error MTU value.
58 * @param[in] packet The original packet.
[1bfd3d3]59 * @return EOK on success.
60 * @return EPERM if the ICMP error notifications are disabled.
61 * @return ENOMEM if there is not enough memory left.
[a26b9e3]62 */
63int
64icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code,
[46d4d9f]65 icmp_param_t mtu, packet_t *packet)
[a26b9e3]66{
[96b02eb9]67 async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (sysarg_t) code,
68 (sysarg_t) packet_get_id(packet), (sysarg_t) mtu);
[21580dd]69 return EOK;
70}
71
[a26b9e3]72/** Sends the Source Quench error notification packet.
73 *
74 * Beginning of the packet is sent as the notification packet data.
75 * The source and the destination addresses should be set in the original
76 * packet.
77 *
78 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
79 * @param[in] packet The original packet.
[1bfd3d3]80 * @return EOK on success.
81 * @return EPERM if the ICMP error notifications are disabled.
82 * @return ENOMEM if there is not enough memory left.
[a26b9e3]83 */
[46d4d9f]84int icmp_source_quench_msg(int icmp_phone, packet_t *packet)
[a26b9e3]85{
86 async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0,
[96b02eb9]87 (sysarg_t) packet_get_id(packet));
[21580dd]88 return EOK;
89}
90
[a26b9e3]91/** Sends the Time Exceeded error notification packet.
92 *
93 * Beginning of the packet is sent as the notification packet data.
94 * The source and the destination addresses should be set in the original
95 * packet.
96 *
97 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
98 * @param[in] code The error specific code.
99 * @param[in] packet The original packet.
[1bfd3d3]100 * @return EOK on success.
101 * @return EPERM if the ICMP error notifications are disabled.
102 * @return ENOMEM if there is not enough memory left.
[a26b9e3]103 */
[46d4d9f]104int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet)
[a26b9e3]105{
[96b02eb9]106 async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (sysarg_t) code,
107 (sysarg_t) packet_get_id(packet));
[21580dd]108 return EOK;
109}
110
[a26b9e3]111/** Sends the Parameter Problem error notification packet.
112 *
113 * Beginning of the packet is sent as the notification packet data.
114 * The source and the destination addresses should be set in the original
115 * packet.
116 *
117 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
118 * @param[in] code The error specific code.
119 * @param[in] pointer The problematic parameter offset.
120 * @param[in] packet The original packet.
[1bfd3d3]121 * @return EOK on success.
122 * @return EPERM if the ICMP error notifications are disabled.
123 * @return ENOMEM if there is not enough memory left.
[a26b9e3]124 */
125int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code,
[46d4d9f]126 icmp_param_t pointer, packet_t *packet)
[a26b9e3]127{
[96b02eb9]128 async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (sysarg_t) code,
129 (sysarg_t) packet_get_id(packet), (sysarg_t) pointer);
[21580dd]130 return EOK;
131}
132
133/** @}
134 */
[a26b9e3]135
Note: See TracBrowser for help on using the repository browser.