49 |
static void *tcpip_init_done_arg; |
static void *tcpip_init_done_arg; |
50 |
static sys_mbox_t mbox; |
static sys_mbox_t mbox; |
51 |
|
|
52 |
|
static int tcpip_tcp_timer_active = 0; |
53 |
|
|
54 |
|
|
55 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
56 |
static void |
static void |
57 |
tcpip_tcp_timer(void *arg) |
tcpip_tcp_timer(void *arg) |
58 |
{ |
{ |
59 |
|
(void)arg; |
60 |
|
|
61 |
tcp_tmr(); |
tcp_tmr(); |
62 |
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); |
if(tcp_active_pcbs || tcp_tw_pcbs) { |
63 |
|
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); |
64 |
|
} else { |
65 |
|
tcpip_tcp_timer_active = 0; |
66 |
|
} |
67 |
} |
} |
|
/*-----------------------------------------------------------------------------------*/ |
|
68 |
|
|
69 |
|
void |
70 |
|
tcp_timer_needed(void) |
71 |
|
{ |
72 |
|
if(!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) { |
73 |
|
tcpip_tcp_timer_active = 1; |
74 |
|
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); |
75 |
|
} |
76 |
|
} |
77 |
|
/*-----------------------------------------------------------------------------------*/ |
78 |
static void |
static void |
79 |
tcpip_thread(void *arg) |
tcpip_thread(void *arg) |
80 |
{ |
{ |
84 |
udp_init(); |
udp_init(); |
85 |
tcp_init(); |
tcp_init(); |
86 |
|
|
|
sys_timeout(TCP_TMR_INTERVAL, (sys_timeout_handler)tcpip_tcp_timer, NULL); |
|
|
|
|
87 |
if(tcpip_init_done != NULL) { |
if(tcpip_init_done != NULL) { |
88 |
tcpip_init_done(tcpip_init_done_arg); |
tcpip_init_done(tcpip_init_done_arg); |
89 |
} |
} |
99 |
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg)); |
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg)); |
100 |
ip_input(msg->msg.inp.p, msg->msg.inp.netif); |
ip_input(msg->msg.inp.p, msg->msg.inp.netif); |
101 |
break; |
break; |
102 |
|
case TCPIP_MSG_LINK: |
103 |
|
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: LINK packet %p\n", (void *)msg)); |
104 |
|
msg->msg.inp.netif->input(msg->msg.inp.p, msg->msg.inp.netif); |
105 |
|
break; |
106 |
default: |
default: |
107 |
break; |
break; |
108 |
} |
} |
128 |
return ERR_OK; |
return ERR_OK; |
129 |
} |
} |
130 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
131 |
|
err_t |
132 |
|
tcpip_link_input(struct pbuf *p, struct netif *inp) |
133 |
|
{ |
134 |
|
struct tcpip_msg *msg; |
135 |
|
|
136 |
|
msg = memp_mallocp(MEMP_TCPIP_MSG); |
137 |
|
if(msg == NULL) { |
138 |
|
pbuf_free(p); |
139 |
|
return ERR_MEM; |
140 |
|
} |
141 |
|
|
142 |
|
msg->type = TCPIP_MSG_LINK; |
143 |
|
msg->msg.inp.p = p; |
144 |
|
msg->msg.inp.netif = inp; |
145 |
|
sys_mbox_post(mbox, msg); |
146 |
|
return ERR_OK; |
147 |
|
} |
148 |
|
/*-----------------------------------------------------------------------------------*/ |
149 |
void |
void |
150 |
tcpip_apimsg(struct api_msg *apimsg) |
tcpip_apimsg(struct api_msg *apimsg) |
151 |
{ |
{ |
166 |
tcpip_init_done = initfunc; |
tcpip_init_done = initfunc; |
167 |
tcpip_init_done_arg = arg; |
tcpip_init_done_arg = arg; |
168 |
mbox = sys_mbox_new(); |
mbox = sys_mbox_new(); |
169 |
sys_thread_new((void *)tcpip_thread, NULL); |
sys_thread_new(tcpip_thread, NULL); |
170 |
} |
} |
171 |
/*-----------------------------------------------------------------------------------*/ |
/*-----------------------------------------------------------------------------------*/ |
172 |
|
|