Mistake on this page?
Report an issue in GitHub or email us
PPP.h
1 /*
2  * Copyright (c) 2019 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 PPP_H_
19 #define PPP_H_
20 
21 #include <stdbool.h>
22 #include "Callback.h"
23 #include "FileHandle.h"
24 #include "NetStackMemoryManager.h"
25 
26 class PPP {
27 public:
28 
29  /** Return the default on-board PPP
30  *
31  * Returns the default on-board PPP - this will be target-specific, and
32  * may not be available on all targets.
33  */
34  static PPP &get_default_instance();
35 
36  virtual ~PPP() = default;
37 
38  /**
39  * Callback to be registered with PPP interface and to be called for received packets
40  *
41  * @param buf Received data
42  */
43  //typedef void (*ppp_link_input_fn)(void *data, net_stack_mem_buf_t *buf);
45 
46  /**
47  * Callback to be registered with PPP interface and to be called for link status changes
48  *
49  * @param up Link status
50  */
51  //typedef void (*ppp_link_state_change_fn)(void *data, bool up);
53 
54  /**
55  * Return maximum transmission unit
56  *
57  * @return MTU in bytes
58  */
59  virtual uint32_t get_mtu_size() = 0;
60 
61  /**
62  * Gets memory buffer alignment preference
63  *
64  * Gets preferred memory buffer alignment of the cellular device.
65  * @return Memory alignment requirement in bytes
66  */
67  virtual uint32_t get_align_preference() const = 0;
68 
69  /**
70  * Return interface name
71  *
72  * @param name Pointer to where the name should be written
73  * @param size Maximum number of characters to copy
74  */
75  virtual void get_ifname(char *name, uint8_t size) const = 0;
76 
77  /**
78  * Sends the packet over the link
79  *
80  * That cannot be called from an interrupt context.
81  *
82  * @param buf Packet to be sent
83  * @return True if the packet was sent, false otherwise
84  */
85  virtual bool link_out(net_stack_mem_buf_t *buf, nsapi_ip_stack_t ip_stack) = 0;
86 
87  /**
88  * Initializes the PPP
89  *
90  * @return True on success, False in case of an error.
91  */
92  virtual bool power_up() = 0;
93 
94  /**
95  * Deinitializes the PPP
96  *
97  */
98  virtual void power_down() = 0;
99 
100  /**
101  * Sets a callback that needs to be called for packets received for that interface
102  *
103  * @param input_cb Function to be register as a callback
104  */
105  virtual void set_link_input_cb(ppp_link_input_cb_t input_cb) = 0;
106 
107  /**
108  * Sets a callback that needs to be called on link status changes for given interface
109  *
110  * @param state_cb Function to be register as a callback
111  */
112  virtual void set_link_state_cb(ppp_link_state_change_cb_t state_cb) = 0;
113 
114  /** Sets memory manager that is used to handle memory buffers
115  *
116  * @param mem_mngr Pointer to memory manager
117  */
118  virtual void set_memory_manager(NetStackMemoryManager &mem_mngr) = 0;
119 
120  /** Sets file stream used to communicate with modem
121  *
122  * @param stream Pointer to file handle
123  */
124  virtual void set_stream(mbed::FileHandle *stream) = 0;
125 
126  /** Sets IP protocol versions of IP stack
127  *
128  * @param ip_stack IP protocol version
129  */
130  virtual void set_ip_stack(nsapi_ip_stack_t ip_stack) = 0;
131 
132  /** Sets user name and password for PPP protocol
133  *
134  * @param uname User name
135  * @param password Password
136  */
137  virtual void set_credentials(const char *uname, const char *password) = 0;
138 
139  /** Gets local IP address
140  *
141  * @param version IP address version
142  * @return IP address
143  */
144  virtual const nsapi_addr_t *get_ip_address(nsapi_version_t version) = 0;
145 
146  /** Get the local network mask.
147  *
148  * @return Local network mask or null if no network mask has been received.
149  */
150  virtual const nsapi_addr_t *get_netmask() = 0;
151 
152  /** Get the local gateway.
153  *
154  * @return Local gateway or null if no network mask has been received.
155  */
156  virtual const nsapi_addr_t *get_gateway() = 0;
157 
158  /** Gets DNS server address
159  *
160  * @param index Server index
161  */
162  virtual const nsapi_addr_t *get_dns_server(uint8_t index) = 0;
163 };
164 
165 #endif /* PPP_H_ */
mbed::Callback< void(net_stack_mem_buf_t *buf)> ppp_link_input_cb_t
Callback to be registered with PPP interface and to be called for received packets.
Definition: PPP.h:44
virtual const nsapi_addr_t * get_dns_server(uint8_t index)=0
Gets DNS server address.
virtual uint32_t get_mtu_size()=0
Return maximum transmission unit.
virtual const nsapi_addr_t * get_netmask()=0
Get the local network mask.
mbed::Callback< void(bool up)> ppp_link_state_change_cb_t
Callback to be registered with PPP interface and to be called for link status changes.
Definition: PPP.h:52
Class FileHandle.
Definition: FileHandle.h:46
virtual void set_link_input_cb(ppp_link_input_cb_t input_cb)=0
Sets a callback that needs to be called for packets received for that interface.
virtual uint32_t get_align_preference() const =0
Gets memory buffer alignment preference.
virtual const nsapi_addr_t * get_ip_address(nsapi_version_t version)=0
Gets local IP address.
virtual void power_down()=0
Deinitializes the PPP.
virtual void set_stream(mbed::FileHandle *stream)=0
Sets file stream used to communicate with modem.
virtual void set_ip_stack(nsapi_ip_stack_t ip_stack)=0
Sets IP protocol versions of IP stack.
Definition: PPP.h:26
virtual void set_memory_manager(NetStackMemoryManager &mem_mngr)=0
Sets memory manager that is used to handle memory buffers.
virtual void set_link_state_cb(ppp_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 power_up()=0
Initializes the PPP.
virtual void get_ifname(char *name, uint8_t size) const =0
Return interface name.
static PPP & get_default_instance()
Return the default on-board PPP.
virtual bool link_out(net_stack_mem_buf_t *buf, nsapi_ip_stack_t ip_stack)=0
Sends the packet over the link.
IP address structure for passing IP addresses by value.
Definition: nsapi_types.h:237
virtual void set_credentials(const char *uname, const char *password)=0
Sets user name and password for PPP protocol.
virtual const nsapi_addr_t * get_gateway()=0
Get the local gateway.
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.