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