18#ifndef PPP_SERVICE_IF_H
19#define PPP_SERVICE_IF_H
21#include "nsapi_types.h"
27typedef uint16_t u16_t;
29typedef uint32_t u32_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;
146typedef err_t (*netif_input_fn)(
struct pbuf *p,
struct netif *inp);
148typedef err_t (*netif_output_fn)(
struct netif *
netif,
struct pbuf *p,
152typedef err_t (*netif_output_ip6_fn)(
struct netif *
netif,
struct pbuf *p,
155typedef 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)
233typedef 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 (__IAR_SYSTEMS_ICC__)
261#define PACK_STRUCT_BEGIN __packed
262#define PACK_STRUCT_STRUCT
263#define PACK_STRUCT_END
264#define PACK_STRUCT_FIELD(fld) fld
266#define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##))
269#define PACK_STRUCT_BEGIN
270#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
271#define PACK_STRUCT_END
272#define PACK_STRUCT_FIELD(fld) fld
273#define ALIGNED(n) __attribute__((aligned (n)))
281#define MEMCPY(dst,src,len) memcpy(dst,src,len)
284#define UNUSED_ARG(x) (void)x
290struct pbuf *ppp_memory_buffer_allocate(
void *memory_manager, uint16_t size, ppp_buf_type_e type);
291void ppp_memory_buffer_free(
struct pbuf *buffer);
292uint16_t ppp_memory_buffer_pool_alloc_unit_get(
void *memory_manager);
293void ppp_memory_buffer_cat(
void *memory_manager,
struct pbuf *to_buf,
struct pbuf *cat_buf);
294void ppp_memory_buffer_set_len(
void *memory_manager,
struct pbuf *buf, uint16_t len);
295uint8_t ppp_memory_buffer_remove_header(
struct pbuf *buffer, uint16_t header_len);
296uint8_t ppp_memory_buffer_add_header(
struct pbuf *buffer, uint16_t header_len);
298struct pbuf *ppp_memory_buffer_convert_to(
void *memory_manager,
void *mem_buf);
299void *ppp_memory_buffer_convert_from(
struct pbuf *
pbuf);
302#define ppp_netif_remove(param)
303err_t ppp_ip_input(
struct pbuf *p,
struct netif *inp);
304void ppp_ip4_addr_set(
nsapi_addr_t *addr, uint32_t *src);
309typedef void ppp_service_cb(
void *arg);
310err_t ppp_call_callback(
void *
service_ptr, ppp_service_cb callback,
void *arg);
313void ppp_sys_arch_unprotect(
void *
service_ptr, sys_prot_t p);
315typedef void (*ppp_sys_timeout_handler)(
void *arg);
316void ppp_sys_timeout(
void *
service_ptr, u32_t msecs, ppp_sys_timeout_handler handler,
void *arg);
317void ppp_sys_untimeout(ppp_sys_timeout_handler handler,
void *arg);
319uint32_t ppp_sys_now(
void);
320uint32_t ppp_sys_jiffies(
void);
322void ppp_trace_to_ascii_hex_dump(
int output,
int len,
char *data);
323void ppp_trace_to_ascii_hex_dump_print(
int output);
u16_t mtu
maximum transfer unit (in bytes)
void * state
This field can be set by the PPP protocol and could point to state information for the protocol.
void * service_ptr
Pointer to PPP Service.
netif_input_fn input
This function is called by the PPP service to pass a packet up the TCP/IP stack.
void * memory_manager
Pointer to memory manager.
void * stream
Pointer to memory stream.
IP address structure for passing IP addresses by value.