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
PPP.h
00001 /* 00002 * Copyright (c) 2019 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 PPP_H_ 00019 #define PPP_H_ 00020 00021 #include <stdbool.h> 00022 #include "Callback.h" 00023 #include "FileHandle.h" 00024 #include "NetStackMemoryManager.h" 00025 00026 class PPP { 00027 public: 00028 00029 /** Return the default on-board PPP 00030 * 00031 * Returns the default on-board PPP - this will be target-specific, and 00032 * may not be available on all targets. 00033 */ 00034 static PPP &get_default_instance(); 00035 00036 virtual ~PPP() {}; 00037 00038 /** 00039 * Callback to be registered with PPP interface and to be called for received packets 00040 * 00041 * @param buf Received data 00042 */ 00043 //typedef void (*ppp_link_input_fn)(void *data, net_stack_mem_buf_t *buf); 00044 typedef mbed::Callback<void (net_stack_mem_buf_t *buf)> ppp_link_input_cb_t; 00045 00046 /** 00047 * Callback to be registered with PPP interface and to be called for link status changes 00048 * 00049 * @param up Link status 00050 */ 00051 //typedef void (*ppp_link_state_change_fn)(void *data, bool up); 00052 typedef mbed::Callback<void (bool up)> ppp_link_state_change_cb_t; 00053 00054 /** 00055 * Return maximum transmission unit 00056 * 00057 * @return MTU in bytes 00058 */ 00059 virtual uint32_t get_mtu_size() = 0; 00060 00061 /** 00062 * Gets memory buffer alignment preference 00063 * 00064 * Gets preferred memory buffer alignment of the cellular device. 00065 * @return Memory alignment requirement in bytes 00066 */ 00067 virtual uint32_t get_align_preference() const = 0; 00068 00069 /** 00070 * Return interface name 00071 * 00072 * @param name Pointer to where the name should be written 00073 * @param size Maximum number of characters to copy 00074 */ 00075 virtual void get_ifname(char *name, uint8_t size) const = 0; 00076 00077 /** 00078 * Sends the packet over the link 00079 * 00080 * That cannot be called from an interrupt context. 00081 * 00082 * @param buf Packet to be sent 00083 * @return True if the packet was sent, false otherwise 00084 */ 00085 virtual bool link_out(net_stack_mem_buf_t *buf, nsapi_ip_stack_t ip_stack) = 0; 00086 00087 /** 00088 * Initializes the PPP 00089 * 00090 * @return True on success, False in case of an error. 00091 */ 00092 virtual bool power_up() = 0; 00093 00094 /** 00095 * Deinitializes the PPP 00096 * 00097 */ 00098 virtual void power_down() = 0; 00099 00100 /** 00101 * Sets a callback that needs to be called for packets received for that interface 00102 * 00103 * @param input_cb Function to be register as a callback 00104 */ 00105 virtual void set_link_input_cb(ppp_link_input_cb_t input_cb) = 0; 00106 00107 /** 00108 * Sets a callback that needs to be called on link status changes for given interface 00109 * 00110 * @param state_cb Function to be register as a callback 00111 */ 00112 virtual void set_link_state_cb(ppp_link_state_change_cb_t state_cb) = 0; 00113 00114 /** Sets memory manager that is used to handle memory buffers 00115 * 00116 * @param mem_mngr Pointer to memory manager 00117 */ 00118 virtual void set_memory_manager(NetStackMemoryManager &mem_mngr) = 0; 00119 00120 /** Sets file stream used to communicate with modem 00121 * 00122 * @param stream Pointer to file handle 00123 */ 00124 virtual void set_stream(mbed::FileHandle *stream) = 0; 00125 00126 /** Sets IP protocol versions of IP stack 00127 * 00128 * @param ip_stack IP protocol version 00129 */ 00130 virtual void set_ip_stack(nsapi_ip_stack_t ip_stack) = 0; 00131 00132 /** Sets user name and password for PPP protocol 00133 * 00134 * @param uname User name 00135 * @param password Password 00136 */ 00137 virtual void set_credentials(const char *uname, const char *password) = 0; 00138 00139 /** Gets local IP address 00140 * 00141 * @param version IP address version 00142 * @return IP address 00143 */ 00144 virtual const nsapi_addr_t *get_ip_address(nsapi_version_t version) = 0; 00145 00146 /** Get the local network mask. 00147 * 00148 * @return Local network mask or null if no network mask has been received. 00149 */ 00150 virtual const nsapi_addr_t *get_netmask() = 0; 00151 00152 /** Get the local gateway. 00153 * 00154 * @return Local gateway or null if no network mask has been received. 00155 */ 00156 virtual const nsapi_addr_t *get_gateway() = 0; 00157 00158 /** Gets DNS server address 00159 * 00160 * @param index Server index 00161 */ 00162 virtual const nsapi_addr_t *get_dns_server(uint8_t index) = 0; 00163 }; 00164 00165 #endif /* PPP_H_ */
Generated on Tue Jul 12 2022 13:54:42 by
