42 #define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
48 #define SLIP_ESC_END 0334
49 #define SLIP_ESC_ESC 0335
51 PROCESS(slip_process,
"SLIP driver");
56 #define SLIP_STATISTICS(statement)
58 uint16_t slip_rubbish, slip_twopackets, slip_overflow, slip_ip_drop;
59 #define SLIP_STATISTICS(statement) statement
63 #define RX_BUFSIZE (UIP_BUFSIZE - UIP_LLH_LEN + 16)
83 static uint8_t state = STATE_TWOPACKETS;
84 static uint16_t begin, end;
85 static uint8_t rxbuf[RX_BUFSIZE];
86 static uint16_t pkt_end;
88 static void (* input_callback)(void) =
NULL;
110 if(i == UIP_TCPIP_HLEN) {
117 }
else if(c == SLIP_ESC) {
129 slip_write(
const void *_ptr,
int len)
131 const uint8_t *ptr = _ptr;
137 for(i = 0; i < len; ++i) {
142 }
else if(c == SLIP_ESC) {
156 begin = end = pkt_end = 0;
162 slip_poll_handler(uint8_t *outbuf, uint16_t blen)
165 if(rxbuf[begin] ==
'C') {
167 if(begin < end && (end - begin) >= 6
168 && memcmp(&rxbuf[begin],
"CLIENT", 6) == 0) {
169 state = STATE_TWOPACKETS;
170 memset(&rxbuf[begin], 0x0, 6);
174 for(i = 0; i < 13; i++) {
180 #ifdef SLIP_CONF_ANSWER_MAC_REQUEST
181 else if(rxbuf[begin] ==
'?') {
184 char* hexchar =
"0123456789abcdef";
185 if(begin < end && (end - begin) >= 2
186 && rxbuf[begin + 1] ==
'M') {
187 state = STATE_TWOPACKETS;
189 rxbuf[begin + 1] = 0;
193 linkaddr_t
addr = get_mac_addr();
197 for(j = 0; j < 8; j++) {
211 if(begin != pkt_end) {
214 if(begin < pkt_end) {
215 len = pkt_end - begin;
219 memcpy(outbuf, &rxbuf[begin], len);
222 len = (RX_BUFSIZE - begin) + (pkt_end - 0);
227 for(i = begin; i < RX_BUFSIZE; i++) {
228 *outbuf++ = rxbuf[i];
230 for(i = 0; i < pkt_end; i++) {
231 *outbuf++ = rxbuf[i];
238 if(state == STATE_TWOPACKETS) {
265 #if !NETSTACK_CONF_WITH_IPV6
268 memcpy(&buf[0],
"=IPA", 4);
269 memcpy(&buf[4], &uip_hostaddr, 4);
274 }
else if(uip_len > 0
275 && uip_len == (((uint16_t)(BUF->len[0]) << 8) + BUF->len[1])
278 if(BUF->ipid[0] == 0 && BUF->ipid[1] == 0 && BUF->ipoffset[0] & IP_DF) {
279 static uint16_t ip_id;
280 uint16_t nid = ip_id++;
281 BUF->ipid[0] = nid >> 8;
285 BUF->ipchksum += nid;
286 if(BUF->ipchksum < nid) {
290 #ifdef SLIP_CONF_TCPIP_INPUT
291 SLIP_CONF_TCPIP_INPUT();
297 SLIP_STATISTICS(slip_ip_drop++);
304 #ifdef SLIP_CONF_TCPIP_INPUT
305 SLIP_CONF_TCPIP_INPUT();
326 case STATE_TWOPACKETS:
330 if(c == SLIP_ESC_END) {
332 }
else if(c == SLIP_ESC_ESC) {
335 state = STATE_RUBBISH;
336 SLIP_STATISTICS(slip_rubbish++);
347 }
else if(c == SLIP_END) {
354 if(begin == pkt_end) {
357 state = STATE_TWOPACKETS;
358 SLIP_STATISTICS(slip_twopackets++);
372 if(next == RX_BUFSIZE) {
376 state = STATE_RUBBISH;
377 SLIP_STATISTICS(slip_overflow++);
386 if(c ==
'T' && rxbuf[begin] ==
'C') {
uint16_t uip_ipchksum(void)
Calculate the IP header checksum of the packet header in uip_buf.
uip_len
The length of the packet in the uip_buf buffer.
void process_poll(struct process *p)
Request a process to be polled.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
uint8_t slip_send(void)
Send an IP packet from the uIP buffer with SLIP.
#define UIP_FW_OK
A non-error message that indicates that something went OK.
#define PROCESS_END()
Define the end of a process.
#define PROCESS(name, strname)
Declare a process.
void slip_arch_writeb(unsigned char c)
Copyright (c) 2014, Analog Devices, Inc.
#define UIP_LLH_LEN
The link level header length.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
uip_appdata
Pointer to the application data in the packet buffer.
int slip_input_byte(unsigned char c)
Input a SLIP byte.
#define uip_buf
Macro to access uip_aligned_buf as an array of bytes.
void slip_set_input_callback(void(*c)(void))
Set a function to be called when there is activity on the SLIP interface; used for detecting if a nod...
#define NULL
The null pointer.
uIP packet forwarding header file.
Header file for the uIP TCP/IP stack.
#define PROCESS_YIELD_UNTIL(c)
Yield the currently running process until a condition occurs.
void tcpip_input(void)
Deliver an incoming packet to the TCP/IP stack.
#define UIP_BUFSIZE
The size of the uIP packet buffer.
CCIF uint16_t uip_htons(uint16_t val)
Convert a 16-bit quantity from host byte order to network byte order.
#define PROCESS_BEGIN()
Define the beginning of a process.