diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2014-08-08 14:42:07 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2014-08-08 14:42:07 +0300 |
| commit | a6163888f3c56123b1db313743c6147ba498732c (patch) | |
| tree | ff7d15d991d1d09ba6cbc0cec80924f57445bfdd /third_party/uip-1.0/doc/example-mainloop-without-arp.c | |
| parent | c3e4c9a25c2910d2d66d52215b3406b13d5b23d5 (diff) | |
Add third_party libs
Diffstat (limited to 'third_party/uip-1.0/doc/example-mainloop-without-arp.c')
| -rw-r--r-- | third_party/uip-1.0/doc/example-mainloop-without-arp.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/third_party/uip-1.0/doc/example-mainloop-without-arp.c b/third_party/uip-1.0/doc/example-mainloop-without-arp.c new file mode 100644 index 0000000..acc3e95 --- /dev/null +++ b/third_party/uip-1.0/doc/example-mainloop-without-arp.c @@ -0,0 +1,62 @@ +#include "uip.h"
+#include "uip_arp.h"
+#include "network-device.h"
+#include "httpd.h"
+#include "timer.h"
+
+/*---------------------------------------------------------------------------*/
+int
+main(void)
+{
+ int i;
+ uip_ipaddr_t ipaddr;
+ struct timer periodic_timer;
+
+ timer_set(&periodic_timer, CLOCK_SECOND / 2);
+
+ network_device_init();
+ uip_init();
+
+ uip_ipaddr(ipaddr, 192,168,0,2);
+ uip_sethostaddr(ipaddr);
+
+ httpd_init();
+
+ while(1) {
+ uip_len = network_device_read();
+ if(uip_len > 0) {
+ uip_input();
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ network_device_send();
+ }
+ } else if(timer_expired(&periodic_timer)) {
+ timer_reset(&periodic_timer);
+ for(i = 0; i < UIP_CONNS; i++) {
+ uip_periodic(i);
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ network_device_send();
+ }
+ }
+
+#if UIP_UDP
+ for(i = 0; i < UIP_UDP_CONNS; i++) {
+ uip_udp_periodic(i);
+ /* If the above function invocation resulted in data that
+ should be sent out on the network, the global variable
+ uip_len is set to a value > 0. */
+ if(uip_len > 0) {
+ network_device_send();
+ }
+ }
+#endif /* UIP_UDP */
+ }
+ }
+ return 0;
+}
+/*---------------------------------------------------------------------------*/
|
