Mistake on this page?
Report an issue in GitHub or email us
L3IP.h
1 /*
2  * Copyright (c) 2018 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef L3IP_H
19 #define L3IP_H
20 
21 #include <stdbool.h>
22 #include "Callback.h"
23 #include "NetStackMemoryManager.h"
24 #include "SocketAddress.h"
25 
26 /**
27  * This interface should be used to abstract low level access to networking hardware
28  * All operations receive a `void *` hardware pointer which an l3ip device provides when
29  * it is registered with a stack.
30  */
31 class L3IP {
32 public:
33 
34  /** Return the default on-board L3IP
35  *
36  * Returns the default on-board L3IP - this will be target-specific, and
37  * may not be available on all targets.
38  */
39  static L3IP &get_default_instance();
40 
41  /**
42  * Callback to be registered with L3IP interface and to be called for received packets
43  *
44  * @param buf Received data
45  */
46  //typedef void (*l3ip_link_input_fn)(void *data, net_stack_mem_buf_t *buf);
48 
49  /**
50  * Callback to be registered with L3IP interface and to be called for link status changes
51  *
52  * @param up Link status
53  */
54  //typedef void (*l3ip_link_state_change_fn)(void *data, bool up);
56 
57  /**
58  * Return maximum transmission unit
59  *
60  * @return MTU in bytes
61  */
62  virtual uint32_t get_mtu_size() const = 0;
63 
64  /**
65  * Gets memory buffer alignment preference
66  *
67  * Gets preferred memory buffer alignment of the l3ip device.
68  * @return Memory alignment requirement in bytes
69  */
70  virtual uint32_t get_align_preference() const = 0;
71 
72  /**
73  * Return interface name
74  *
75  * @param name Pointer to where the name should be written
76  * @param size Maximum number of characters to copy
77  */
78  virtual void get_ifname(char *name, uint8_t size) const = 0;
79 
80  /**
81  * Sends the packet over the link
82  *
83  * That cannot be called from an interrupt context.
84  *
85  * @param buf Packet to be send
86  * @return True if the packet was send successfully, false otherwise
87  */
88  virtual bool link_out(net_stack_mem_buf_t *buf) = 0;
89 
90  /**
91  * Initializes the hardware
92  *
93  * @return True on success, False in case of an error.
94  */
95  virtual bool power_up() = 0;
96 
97  /**
98  * Deinitializes the hardware
99  *
100  */
101  virtual void power_down() = 0;
102 
103  /**
104  * Sets a callback that needs to be called for packets received for that interface
105  *
106  * @param input_cb Function to be register as a callback
107  */
108  virtual void set_link_input_cb(l3ip_link_input_cb_t input_cb) = 0;
109 
110  /**
111  * Sets a callback that needs to be called on link status changes for given interface
112  *
113  * @param state_cb Function to be register as a callback
114  */
115  virtual void set_link_state_cb(l3ip_link_state_change_cb_t state_cb) = 0;
116 
117  /** Add device to an IP4 multicast group
118  *
119  * @param address An IP4 multicast group address
120  */
121  virtual void add_ipv4_multicast_group(const SocketAddress &address) = 0;
122 
123  /** Add device to an IP6 multicast group
124  *
125  * @param address An IP6 multicast group address
126  */
127  virtual void add_ipv6_multicast_group(const SocketAddress &address) = 0;
128 
129  /** Remove device from an IPV4 multicast group
130  *
131  * @param address An IPV4 multicast group address
132  */
133  virtual void remove_ipv4_multicast_group(const SocketAddress &address) = 0;
134 
135  /** Remove device from an IPV6 multicast group
136  *
137  * @param address An IPV6 multicast group address
138  */
139  virtual void remove_ipv6_multicast_group(const SocketAddress &address) = 0;
140 
141  /** Request reception of all multicast packets
142  *
143  * @param all True to receive all multicasts
144  * False to receive only multicasts addressed to specified groups
145  */
146  virtual void set_all_multicast(bool all) = 0;
147 
148  /** Sets memory manager that is used to handle memory buffers
149  *
150  * @param mem_mngr Pointer to memory manager
151  */
152  virtual void set_memory_manager(NetStackMemoryManager &mem_mngr) = 0;
153 };
154 
155 
156 
157 
158 #endif /* L3IP_H */
virtual void power_down()=0
Deinitializes the hardware.
virtual void remove_ipv6_multicast_group(const SocketAddress &address)=0
Remove device from an IPV6 multicast group.
virtual uint32_t get_mtu_size() const =0
Return maximum transmission unit.
SocketAddress class.
virtual void set_all_multicast(bool all)=0
Request reception of all multicast packets.
virtual void set_link_state_cb(l3ip_link_state_change_cb_t state_cb)=0
Sets a callback that needs to be called on link status changes for given interface.
virtual bool link_out(net_stack_mem_buf_t *buf)=0
Sends the packet over the link.
virtual void remove_ipv4_multicast_group(const SocketAddress &address)=0
Remove device from an IPV4 multicast group.
virtual void set_memory_manager(NetStackMemoryManager &mem_mngr)=0
Sets memory manager that is used to handle memory buffers.
virtual void add_ipv6_multicast_group(const SocketAddress &address)=0
Add device to an IP6 multicast group.
virtual bool power_up()=0
Initializes the hardware.
This interface should be used to abstract low level access to networking hardware All operations rece...
Definition: L3IP.h:31
SocketAddress class.
Definition: SocketAddress.h:36
mbed::Callback< void(bool up)> l3ip_link_state_change_cb_t
Callback to be registered with L3IP interface and to be called for link status changes.
Definition: L3IP.h:55
static L3IP & get_default_instance()
Return the default on-board L3IP.
virtual void add_ipv4_multicast_group(const SocketAddress &address)=0
Add device to an IP4 multicast group.
virtual uint32_t get_align_preference() const =0
Gets memory buffer alignment preference.
virtual void set_link_input_cb(l3ip_link_input_cb_t input_cb)=0
Sets a callback that needs to be called for packets received for that interface.
virtual void get_ifname(char *name, uint8_t size) const =0
Return interface name.
mbed::Callback< void(net_stack_mem_buf_t *buf)> l3ip_link_input_cb_t
Callback to be registered with L3IP interface and to be called for received packets.
Definition: L3IP.h:47
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.