#include "netif/slipif.h"
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
#include "lwip/sys.h"
#include "lwip/stats.h"
#include "lwip/sio.h"
Include dependency graph for slipif.c:
Go to the source code of this file.
Defines | |
#define | SLIP_END 0300 |
#define | SLIP_ESC 0333 |
#define | SLIP_ESC_END 0334 |
#define | SLIP_ESC_ESC 0335 |
#define | MAX_SIZE 1500 |
Functions | |
err_t | slipif_output (struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) |
pbuf * | slipif_input (struct netif *netif) |
void | slipif_loop (void *nf) |
err_t | slipif_init (struct netif *netif) |
|
Definition at line 52 of file slipif.c. Referenced by slipif_input(). |
|
Definition at line 47 of file slipif.c. Referenced by slipif_input(), and slipif_output(). |
|
Definition at line 48 of file slipif.c. Referenced by slipif_input(), and slipif_output(). |
|
Definition at line 49 of file slipif.c. Referenced by slipif_input(), and slipif_output(). |
|
Definition at line 50 of file slipif.c. Referenced by slipif_input(), and slipif_output(). |
|
SLIP netif initialization Call the arch specific sio_open and remember the opened device in the state field of the netif. Definition at line 197 of file slipif.c. References DEBUGF, ERR_IF, ERR_OK, netif::mtu, netif::name, netif::num, netif::output, sio_open(), SLIP_DEBUG, slipif_loop(), slipif_output(), SLIPIF_THREAD_PRIO, netif::state, and sys_thread_new().
00198 { 00199 00200 DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num)); 00201 00202 netif->name[0] = 's'; 00203 netif->name[1] = 'l'; 00204 netif->output = slipif_output; 00205 netif->mtu = 1500; 00206 00207 netif->state = sio_open(netif->num); 00208 if (!netif->state) 00209 return ERR_IF; 00210 00211 sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO); 00212 return ERR_OK; 00213 } |
Here is the call graph for this function:
|
Handle the incoming SLIP stream character by character Poll the serial layer by calling sio_recv()
Definition at line 99 of file slipif.c. References DEBUGF, MAX_SIZE, NULL, pbuf_alloc(), pbuf_chain(), PBUF_LINK, PBUF_POOL, pbuf_realloc(), sio_recv(), SLIP_DEBUG, SLIP_END, SLIP_ESC, SLIP_ESC_END, SLIP_ESC_ESC, netif::state, and u8_t. Referenced by slipif_loop().
00100 { 00101 u8_t c; 00102 struct pbuf *p, *q; 00103 int recved; 00104 int i; 00105 00106 q = p = NULL; 00107 recved = i = 0; 00108 c = 0; 00109 00110 while(1) { 00111 c = sio_recv(netif->state); 00112 switch(c) { 00113 case SLIP_END: 00114 if(recved > 0) { 00115 /* Received whole packet. */ 00116 pbuf_realloc(q, recved); 00117 00118 #ifdef LINK_STATS 00119 ++lwip_stats.link.recv; 00120 #endif /* LINK_STATS */ 00121 00122 DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n")); 00123 return q; 00124 } 00125 break; 00126 00127 case SLIP_ESC: 00128 c = sio_recv(netif->state); 00129 switch(c) { 00130 case SLIP_ESC_END: 00131 c = SLIP_END; 00132 break; 00133 case SLIP_ESC_ESC: 00134 c = SLIP_ESC; 00135 break; 00136 } 00137 /* FALLTHROUGH */ 00138 00139 default: 00140 if(p == NULL) { 00141 DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); 00142 p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL); 00143 00144 #ifdef LINK_STATS 00145 if(p == NULL) { 00146 ++lwip_stats.link.drop; 00147 DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); 00148 } 00149 #endif /* LINK_STATS */ 00150 00151 if(q != NULL) { 00152 pbuf_chain(q, p); 00153 } else { 00154 q = p; 00155 } 00156 } 00157 if(p != NULL && recved < MAX_SIZE) { 00158 ((u8_t *)p->payload)[i] = c; 00159 recved++; 00160 i++; 00161 if(i >= p->len) { 00162 i = 0; 00163 p = NULL; 00164 } 00165 } 00166 break; 00167 } 00168 00169 } 00170 return NULL; 00171 } |
Here is the call graph for this function:
|
The SLIP input thread Feed the IP layer with incoming packets Definition at line 179 of file slipif.c. References slipif_input(). Referenced by slipif_init().
|
Here is the call graph for this function:
|
Send a pbuf doing the necessary SLIP encapsulation Uses the serial layer's sio_send() Definition at line 60 of file slipif.c. References NULL, sio_send(), SLIP_END, SLIP_ESC, SLIP_ESC_END, SLIP_ESC_ESC, netif::state, and u8_t. Referenced by slipif_init().
00061 { 00062 struct pbuf *q; 00063 int i; 00064 u8_t c; 00065 00066 /* Send pbuf out on the serial I/O device. */ 00067 sio_send(SLIP_END, netif->state); 00068 00069 for(q = p; q != NULL; q = q->next) { 00070 for(i = 0; i < q->len; i++) { 00071 c = ((u8_t *)q->payload)[i]; 00072 switch(c) { 00073 case SLIP_END: 00074 sio_send(SLIP_ESC, netif->state); 00075 sio_send(SLIP_ESC_END, netif->state); 00076 break; 00077 case SLIP_ESC: 00078 sio_send(SLIP_ESC, netif->state); 00079 sio_send(SLIP_ESC_ESC, netif->state); 00080 break; 00081 default: 00082 sio_send(c, netif->state); 00083 break; 00084 } 00085 } 00086 } 00087 sio_send(SLIP_END, netif->state); 00088 return 0; 00089 } |
Here is the call graph for this function: