[fb9ffb0] | 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 | * Internetwork layer module interface for the underlying network interface
|
---|
[797b704] | 35 | * layer.
|
---|
[fb9ffb0] | 36 | */
|
---|
| 37 |
|
---|
[797b704] | 38 | #include <il_remote.h>
|
---|
[fb9ffb0] | 39 | #include <generic.h>
|
---|
| 40 | #include <packet_client.h>
|
---|
| 41 | #include <ipc/services.h>
|
---|
| 42 | #include <ipc/il.h>
|
---|
| 43 | #include <net/device.h>
|
---|
| 44 | #include <net/packet.h>
|
---|
| 45 |
|
---|
| 46 | /** Notify the internetwork layer modules about the device state change.
|
---|
| 47 | *
|
---|
[6b82009] | 48 | * @param[in] sess Internetwork layer module session.
|
---|
| 49 | * @param[in] device_id Device identifier.
|
---|
| 50 | * @param[in] state New device state.
|
---|
| 51 | * @param[in] target Target internetwork module service to be
|
---|
[fb9ffb0] | 52 | * delivered to.
|
---|
| 53 | *
|
---|
| 54 | * @return EOK on success.
|
---|
| 55 | *
|
---|
| 56 | */
|
---|
[609243f4] | 57 | int il_device_state_msg(async_sess_t *sess, nic_device_id_t device_id,
|
---|
| 58 | nic_device_state_t state, services_t target)
|
---|
[fb9ffb0] | 59 | {
|
---|
[6b82009] | 60 | return generic_device_state_msg_remote(sess, NET_IL_DEVICE_STATE,
|
---|
[fb9ffb0] | 61 | device_id, state, target);
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | /** Notify the internetwork layer modules about the received packet/s.
|
---|
| 65 | *
|
---|
[6b82009] | 66 | * @param[in] sess Internetwork layer module session.
|
---|
| 67 | * @param[in] device_id Device identifier.
|
---|
| 68 | * @param[in] packet Received packet or the received packet queue.
|
---|
| 69 | * @param[in] target Target internetwork module service to be
|
---|
[fb9ffb0] | 70 | * delivered to.
|
---|
| 71 | *
|
---|
| 72 | * @return EOK on success.
|
---|
| 73 | *
|
---|
| 74 | */
|
---|
[609243f4] | 75 | int il_received_msg(async_sess_t *sess, nic_device_id_t device_id,
|
---|
| 76 | packet_t *packet, services_t target)
|
---|
[fb9ffb0] | 77 | {
|
---|
[6b82009] | 78 | return generic_received_msg_remote(sess, NET_IL_RECEIVED, device_id,
|
---|
[fb9ffb0] | 79 | packet_get_id(packet), target, 0);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | /** Notify the internetwork layer modules about the mtu change.
|
---|
| 83 | *
|
---|
[6b82009] | 84 | * @param[in] sess Internetwork layer module session.
|
---|
| 85 | * @param[in] device_id Device identifier.
|
---|
| 86 | * @param[in] mtu New MTU value.
|
---|
| 87 | * @param[in] target Target internetwork module service to be
|
---|
[fb9ffb0] | 88 | * delivered to.
|
---|
| 89 | *
|
---|
| 90 | * @return EOK on success.
|
---|
| 91 | *
|
---|
| 92 | */
|
---|
[609243f4] | 93 | int il_mtu_changed_msg(async_sess_t *sess, nic_device_id_t device_id, size_t mtu,
|
---|
[fb9ffb0] | 94 | services_t target)
|
---|
| 95 | {
|
---|
[6b82009] | 96 | return generic_device_state_msg_remote(sess, NET_IL_MTU_CHANGED,
|
---|
| 97 | device_id, mtu, target);
|
---|
[fb9ffb0] | 98 | }
|
---|
| 99 |
|
---|
[609243f4] | 100 | /** Notify IL layer modules about address change (implemented by ARP)
|
---|
| 101 | *
|
---|
| 102 | */
|
---|
| 103 | int il_addr_changed_msg(async_sess_t *sess, nic_device_id_t device_id,
|
---|
| 104 | size_t addr_len, const uint8_t *address)
|
---|
| 105 | {
|
---|
| 106 | async_exch_t *exch = async_exchange_begin(sess);
|
---|
| 107 |
|
---|
| 108 | aid_t message_id = async_send_1(exch, NET_IL_ADDR_CHANGED,
|
---|
| 109 | (sysarg_t) device_id, NULL);
|
---|
| 110 | int rc = async_data_write_start(exch, address, addr_len);
|
---|
| 111 |
|
---|
| 112 | async_exchange_end(exch);
|
---|
| 113 |
|
---|
| 114 | sysarg_t res;
|
---|
| 115 | async_wait_for(message_id, &res);
|
---|
| 116 | if (rc != EOK)
|
---|
| 117 | return rc;
|
---|
| 118 |
|
---|
| 119 | return (int) res;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
[fb9ffb0] | 122 | /** @}
|
---|
| 123 | */
|
---|