18 #ifndef PPP_SERVICE_IF_H 19 #define PPP_SERVICE_IF_H 21 #include "nsapi_types.h" 27 typedef uint16_t u16_t;
28 typedef int16_t s16_t;
29 typedef uint32_t u32_t;
30 typedef int32_t s32_t;
36 #define X8_F "02" PRIx8 101 #ifndef PPP_UNUSED_ARG 102 #define PPP_UNUSED_ARG(x) (void)x 105 #define PPP_MAX(x , y) (((x) > (y)) ? (x) : (y)) 106 #define PPP_MIN(x , y) (((x) < (y)) ? (x) : (y)) 112 #define IPADDR_STRLEN_MAX 46 114 #define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) 115 #define IP_CLASSA_NET 0xff000000 116 #define IP_CLASSA_NSHIFT 24 117 #define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) 118 #define IP_CLASSA_MAX 128 120 #define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) 121 #define IP_CLASSD_NET 0xf0000000 122 #define IP_CLASSD_NSHIFT 28 123 #define IP_CLASSD_HOST 0x0fffffff 124 #define IP_MULTICAST(a) IP_CLASSD(a) 126 #define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) 128 #define IP_LOOPBACKNET 127 130 #define ip4_addr_set_u32(dest_ipaddr, src_u32) \ 131 ppp_ip4_addr_set((nsapi_addr_t *)dest_ipaddr, &src_u32) 133 #define ip_addr_set_ip4_u32_val(ipaddr, val) \ 134 ppp_ip4_addr_set((nsapi_addr_t *)&ipaddr, &val) 138 void *memory_manager;
146 typedef err_t (*netif_input_fn)(
struct pbuf *p,
struct netif *inp);
148 typedef err_t (*netif_output_fn)(
struct netif *
netif,
struct pbuf *p,
152 typedef err_t (*netif_output_ip6_fn)(
struct netif *netif,
struct pbuf *p,
155 typedef err_t (*netif_init_fn)(
struct netif *netif);
170 netif_output_fn output;
180 netif_output_ip6_fn output_ip6;
194 #define netif_set_link_up(netif) ppp_netif_set_link_up(netif) 195 #define netif_set_link_down(netif) ppp_netif_set_link_down(netif) 197 #define PPP_MEMPOOL_PROTOTYPE(name) 198 #define PPP_MEMPOOL_INIT(name) 199 #define PPP_MEMPOOL_ALLOC(name) 1 200 #define PPP_MEMPOOL_FREE(name, x) 202 #define PPP_MEMPOOL_DECLARE(name,num,size,desc) \ 203 uint32_t name = size; 214 #define MEMPOOL_ALLOC(size) \ 217 #define MEMPOOL_FREE(x, ptr) \ 220 #define pbuf_remove_header(buf, size) \ 221 ppp_memory_buffer_remove_header(buf, size) 223 #define pbuf_add_header(buf, size) \ 224 ppp_memory_buffer_add_header(buf, size) 226 #define LINK_STATS_INC(x) 227 #define MIB2_STATS_NETIF_INC(n, x) 228 #define MIB2_INIT_NETIF(netif, type, speed) 229 #define MIB2_STATS_NETIF_ADD(n, x, val) 231 #define PPP_ASSERT(message, assertion) 233 typedef int sys_prot_t;
235 #define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev 236 #define SYS_ARCH_PROTECT(lev) lev = ppp_sys_arch_protect(ppp->netif->service_ptr) 237 #define SYS_ARCH_UNPROTECT(lev) ppp_sys_arch_unprotect(ppp->netif->service_ptr, lev) 239 #define PPPOS_DECL_PROTECT(lev) SYS_ARCH_DECL_PROTECT(lev) 240 #define PPPOS_PROTECT(lev) SYS_ARCH_PROTECT(lev) 241 #define PPPOS_UNPROTECT(lev) SYS_ARCH_UNPROTECT(lev) 244 #define ppp_isdigit(c) isdigit((unsigned char)(c)) 246 #define sys_now ppp_sys_now 247 #define sys_jiffies() ppp_sys_jiffies(); 249 #define TIMEOUT(f, a, t) do { ppp_sys_untimeout((f), (a)); ppp_sys_timeout(pcb->netif->service_ptr, (t)*1000, (f), (a)); } while(0) 250 #define TIMEOUTMS(f, a, t) do { ppp_sys_untimeout((f), (a)); ppp_sys_timeout(pcb->netif->service_ptr, (t), (f), (a)); } while(0) 251 #define UNTIMEOUT(f, a) do { ppp_sys_untimeout((f), (a)); } while(0) 253 #define sys_timeout(msecs, handler, arg) ppp_sys_timeout(pcb->netif->service_ptr, msecs, (ppp_sys_timeout_handler) handler, (void *) arg) 254 #define sys_untimeout(handler, arg) ppp_sys_untimeout(handler, (void *) arg) 256 #define OUTPUT_BUFFER 0 257 #define INPUT_BUFFER 1 259 #if defined(__arm__) && defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 6010050) 261 #define PACK_STRUCT_BEGIN __packed 262 #define PACK_STRUCT_STRUCT 263 #define PACK_STRUCT_END 264 #define PACK_STRUCT_FIELD(fld) fld 265 #define ALIGNED(n) __align(n) 266 #elif defined (__IAR_SYSTEMS_ICC__) 268 #define PACK_STRUCT_BEGIN __packed 269 #define PACK_STRUCT_STRUCT 270 #define PACK_STRUCT_END 271 #define PACK_STRUCT_FIELD(fld) fld 272 #define IAR_STR(a) #a 273 #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##)) 276 #define PACK_STRUCT_BEGIN 277 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 278 #define PACK_STRUCT_END 279 #define PACK_STRUCT_FIELD(fld) fld 280 #define ALIGNED(n) __attribute__((aligned (n))) 288 #define MEMCPY(dst,src,len) memcpy(dst,src,len) 291 #define UNUSED_ARG(x) (void)x 297 struct pbuf *ppp_memory_buffer_allocate(
void *memory_manager, uint16_t size, ppp_buf_type_e type);
298 void ppp_memory_buffer_free(
struct pbuf *buffer);
299 uint16_t ppp_memory_buffer_pool_alloc_unit_get(
void *memory_manager);
300 void ppp_memory_buffer_cat(
void *memory_manager,
struct pbuf *to_buf,
struct pbuf *cat_buf);
301 void ppp_memory_buffer_set_len(
void *memory_manager,
struct pbuf *buf, uint16_t len);
302 uint8_t ppp_memory_buffer_remove_header(
struct pbuf *buffer, uint16_t header_len);
303 uint8_t ppp_memory_buffer_add_header(
struct pbuf *buffer, uint16_t header_len);
305 struct pbuf *ppp_memory_buffer_convert_to(
void *memory_manager,
void *mem_buf);
306 void *ppp_memory_buffer_convert_from(
struct pbuf *
pbuf);
308 struct netif *ppp_netif_add(
struct netif *netif,
void *
state, netif_init_fn init);
309 #define ppp_netif_remove(param) 310 err_t ppp_ip_input(
struct pbuf *p,
struct netif *inp);
311 void ppp_ip4_addr_set(
nsapi_addr_t *addr, uint32_t *src);
313 void ppp_set_link_up(
struct netif *netif);
314 void ppp_set_link_down(
struct netif *netif);
316 typedef void ppp_service_cb(
void *arg);
319 sys_prot_t ppp_sys_arch_protect(
void *service_ptr);
320 void ppp_sys_arch_unprotect(
void *service_ptr, sys_prot_t p);
322 typedef void (*ppp_sys_timeout_handler)(
void *arg);
323 void ppp_sys_timeout(
void *service_ptr, u32_t msecs, ppp_sys_timeout_handler handler,
void *arg);
324 void ppp_sys_untimeout(ppp_sys_timeout_handler handler,
void *arg);
326 uint32_t ppp_sys_now(
void);
327 uint32_t ppp_sys_jiffies(
void);
329 void ppp_trace_to_ascii_hex_dump(
int output,
int len,
char *data);
330 void ppp_trace_to_ascii_hex_dump_print(
int output);
void * state
This field can be set by the PPP protocol and could point to state information for the protocol...
void * memory_manager
Pointer to memory manager.
netif_input_fn input
This function is called by the PPP service to pass a packet up the TCP/IP stack.
u16_t mtu
maximum transfer unit (in bytes)
void * stream
Pointer to memory stream.
IP address structure for passing IP addresses by value.
void * service_ptr
Pointer to PPP Service.