Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
L3IP.h
00001 /* 00002 * Copyright (c) 2018 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef L3IP_H 00019 #define L3IP_H 00020 00021 #include <stdbool.h> 00022 #include "Callback.h" 00023 #include "NetStackMemoryManager.h" 00024 #include "SocketAddress.h" 00025 00026 /** 00027 * This interface should be used to abstract low level access to networking hardware 00028 * All operations receive a `void *` hardware pointer which an l3ip device provides when 00029 * it is registered with a stack. 00030 */ 00031 class L3IP { 00032 public: 00033 00034 /** Return the default on-board L3IP 00035 * 00036 * Returns the default on-board L3IP - this will be target-specific, and 00037 * may not be available on all targets. 00038 */ 00039 static L3IP &get_default_instance(); 00040 00041 /** 00042 * Callback to be registered with L3IP interface and to be called for received packets 00043 * 00044 * @param buf Received data 00045 */ 00046 //typedef void (*l3ip_link_input_fn)(void *data, net_stack_mem_buf_t *buf); 00047 typedef mbed::Callback<void (net_stack_mem_buf_t *buf)> l3ip_link_input_cb_t; 00048 00049 /** 00050 * Callback to be registered with L3IP interface and to be called for link status changes 00051 * 00052 * @param up Link status 00053 */ 00054 //typedef void (*l3ip_link_state_change_fn)(void *data, bool up); 00055 typedef mbed::Callback<void (bool up)> l3ip_link_state_change_cb_t; 00056 00057 /** 00058 * Return maximum transmission unit 00059 * 00060 * @return MTU in bytes 00061 */ 00062 virtual uint32_t get_mtu_size() const = 0; 00063 00064 /** 00065 * Gets memory buffer alignment preference 00066 * 00067 * Gets preferred memory buffer alignment of the l3ip device. 00068 * @return Memory alignment requirement in bytes 00069 */ 00070 virtual uint32_t get_align_preference() const = 0; 00071 00072 /** 00073 * Return interface name 00074 * 00075 * @param name Pointer to where the name should be written 00076 * @param size Maximum number of characters to copy 00077 */ 00078 virtual void get_ifname(char *name, uint8_t size) const = 0; 00079 00080 /** 00081 * Sends the packet over the link 00082 * 00083 * That cannot be called from an interrupt context. 00084 * 00085 * @param buf Packet to be send 00086 * @return True if the packet was send successfully, false otherwise 00087 */ 00088 virtual bool link_out(net_stack_mem_buf_t *buf) = 0; 00089 00090 /** 00091 * Initializes the hardware 00092 * 00093 * @return True on success, False in case of an error. 00094 */ 00095 virtual bool power_up() = 0; 00096 00097 /** 00098 * Deinitializes the hardware 00099 * 00100 */ 00101 virtual void power_down() = 0; 00102 00103 /** 00104 * Sets a callback that needs to be called for packets received for that interface 00105 * 00106 * @param input_cb Function to be register as a callback 00107 */ 00108 virtual void set_link_input_cb(l3ip_link_input_cb_t input_cb) = 0; 00109 00110 /** 00111 * Sets a callback that needs to be called on link status changes for given interface 00112 * 00113 * @param state_cb Function to be register as a callback 00114 */ 00115 virtual void set_link_state_cb(l3ip_link_state_change_cb_t state_cb) = 0; 00116 00117 /** Add device to an IP4 multicast group 00118 * 00119 * @param address An IP4 multicast group address 00120 */ 00121 virtual void add_ipv4_multicast_group(const SocketAddress &address) = 0; 00122 00123 /** Add device to an IP6 multicast group 00124 * 00125 * @param address An IP6 multicast group address 00126 */ 00127 virtual void add_ipv6_multicast_group(const SocketAddress &address) = 0; 00128 00129 /** Remove device from an IPV4 multicast group 00130 * 00131 * @param address An IPV4 multicast group address 00132 */ 00133 virtual void remove_ipv4_multicast_group(const SocketAddress &address) = 0; 00134 00135 /** Remove device from an IPV6 multicast group 00136 * 00137 * @param address An IPV6 multicast group address 00138 */ 00139 virtual void remove_ipv6_multicast_group(const SocketAddress &address) = 0; 00140 00141 /** Request reception of all multicast packets 00142 * 00143 * @param all True to receive all multicasts 00144 * False to receive only multicasts addressed to specified groups 00145 */ 00146 virtual void set_all_multicast(bool all) = 0; 00147 00148 /** Sets memory manager that is used to handle memory buffers 00149 * 00150 * @param mem_mngr Pointer to memory manager 00151 */ 00152 virtual void set_memory_manager(NetStackMemoryManager &mem_mngr) = 0; 00153 }; 00154 00155 00156 00157 00158 #endif /* L3IP_H */
Generated on Tue Jul 12 2022 13:54:26 by
1.7.2