forked from xen-project/xen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlwip.patch-cvs
2398 lines (2258 loc) · 83.7 KB
/
lwip.patch-cvs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
? .ChangeLog.swp
? ChangeLog
Index: CHANGELOG
===================================================================
RCS file: /sources/lwip/lwip/CHANGELOG,v
retrieving revision 1.300
retrieving revision 1.318
diff -u -p -r1.300 -r1.318
--- CHANGELOG 23 Mar 2008 13:49:39 -0000 1.300
+++ CHANGELOG 14 Jul 2008 20:12:36 -0000 1.318
@@ -19,9 +19,77 @@ HISTORY
++ New features:
+ 2008-06-30 Simon Goldschmidt
+ * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from
+ interrupt context isn't safe: LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT allows
+ mem_free to run between mem_malloc iterations. Added illegal counter for
+ mem stats.
+
+ 2008-06-27 Simon Goldschmidt
+ * stats.h/.c, some other files: patch #6483: stats module improvement:
+ Added defines to display each module's statistic individually, added stats
+ defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter.
+
+ 2008-06-17 Simon Goldschmidt
+ * err.h: patch #6459: Made err_t overridable to use a more efficient type
+ (define LWIP_ERR_T in cc.h)
+
+ 2008-06-17 Simon Goldschmidt
+ * slipif.c: patch #6480: Added a configuration option for slipif for symmetry
+ to loopif
+
+ 2008-06-17 Simon Goldschmidt (patch by Luca Ceresoli)
+ * netif.c, loopif.c, ip.c, netif.h, loopif.h, opt.h: Checked in slightly
+ modified version of patch # 6370: Moved loopif code to netif.c so that
+ loopback traffic is supported on all netifs (all local IPs).
+ Added option to limit loopback packets for each netifs.
+
++ Bugfixes:
+ 2008-08-14 Simon Goldschmidt
+ * api_msg.c: fixed bug #23847: do_close_internal references freed memory (when
+ tcp_close returns != ERR_OK)
+
+ 2008-07-08 Frédéric Bernon
+ * stats.h: Fix some build bugs introduced with patch #6483 (missing some parameters
+ in macros, mainly if MEM_STATS=0 and MEMP_STATS=0).
+
+ 2008-06-24 Jonathan Larmour
+ * tcp_in.c: Fix for bug #23693 as suggested by Art R. Ensure cseg is unused
+ if tcp_seg_copy fails.
+
+ 2008-06-17 Simon Goldschmidt
+ * inet_chksum.c: Checked in some ideas of patch #6460 (loop optimizations)
+ and created defines for swapping bytes and folding u32 to u16.
+
+ 2008-05-30 Kieran Mansley
+ * tcp_in.c Remove redundant "if" statement, and use real rcv_wnd
+ rather than rcv_ann_wnd when deciding if packets are in-window.
+ Contributed by <[email protected]>
+
+ 2008-05-30 Kieran Mansley
+ * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow
+ passing as function pointers when MEM_LIBC_MALLOC is defined.
+
+ 2008-05-09 Jonathan Larmour
+ * err.h, err.c, sockets.c: Fix bug #23119: Reorder timeout error code to
+ stop it being treated as a fatal error.
+
+ 2008-04-15 Simon Goldschmidt
+ * dhcp.c: fixed bug #22804: dhcp_stop doesn't clear NETIF_FLAG_DHCP
+ (flag now cleared)
+
+ 2008-03-27 Simon Goldschmidt
+ * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free
+ from interrupt context isn't safe): set LWIP_USE_HEAP_FROM_INTERRUPT to 1
+ in lwipopts.h or use pbuf_free_callback(p)/mem_free_callback(m) to free pbufs
+ or heap memory from interrupt context
+
+ 2008-03-26 Simon Goldschmidt
+ * tcp_in.c, tcp.c: fixed bug #22249: division by zero could occur if a remote
+ host sent a zero mss as TCP option.
+
(STABLE-1.3.0)
Index: src/api/api_msg.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/api_msg.c,v
retrieving revision 1.102
retrieving revision 1.104
diff -u -p -r1.102 -r1.104
--- src/api/api_msg.c 21 Mar 2008 16:23:14 -0000 1.102
+++ src/api/api_msg.c 15 Jul 2008 11:18:58 -0000 1.104
@@ -598,11 +598,16 @@ do_close_internal(struct netconn *conn)
LWIP_ASSERT("pcb already closed", (conn->pcb.tcp != NULL));
/* Set back some callback pointers */
+ tcp_arg(conn->pcb.tcp, NULL);
if (conn->pcb.tcp->state == LISTEN) {
- tcp_arg(conn->pcb.tcp, NULL);
tcp_accept(conn->pcb.tcp, NULL);
} else {
tcp_recv(conn->pcb.tcp, NULL);
+ tcp_accept(conn->pcb.tcp, NULL);
+ /* some callbacks have to be reset if tcp_close is not successful */
+ tcp_sent(conn->pcb.tcp, NULL);
+ tcp_poll(conn->pcb.tcp, NULL, 4);
+ tcp_err(conn->pcb.tcp, NULL);
}
/* Try to close the connection */
err = tcp_close(conn->pcb.tcp);
@@ -610,11 +615,6 @@ do_close_internal(struct netconn *conn)
/* Closing succeeded */
conn->state = NETCONN_NONE;
/* Set back some callback pointers as conn is going away */
- tcp_err(conn->pcb.tcp, NULL);
- tcp_poll(conn->pcb.tcp, NULL, 4);
- tcp_sent(conn->pcb.tcp, NULL);
- tcp_recv(conn->pcb.tcp, NULL);
- tcp_arg(conn->pcb.tcp, NULL);
conn->pcb.tcp = NULL;
conn->err = ERR_OK;
/* Trigger select() in socket layer. This send should something else so the
@@ -623,6 +623,14 @@ do_close_internal(struct netconn *conn)
API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0);
/* wake up the application task */
sys_sem_signal(conn->op_completed);
+ } else {
+ /* Closing failed, restore some of the callbacks */
+ /* Closing of listen pcb will never fail! */
+ LWIP_ASSERT("Closing a listen pcb may not fail!", (conn->pcb.tcp->state != LISTEN));
+ tcp_sent(conn->pcb.tcp, sent_tcp);
+ tcp_poll(conn->pcb.tcp, poll_tcp, 4);
+ tcp_err(conn->pcb.tcp, err_tcp);
+ tcp_arg(conn->pcb.tcp, conn);
}
/* If closing didn't succeed, we get called again either
from poll_tcp or from sent_tcp */
Index: src/api/err.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/err.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -r1.11 -r1.12
--- src/api/err.c 13 Dec 2007 23:06:50 -0000 1.11
+++ src/api/err.c 9 May 2008 12:14:23 -0000 1.12
@@ -44,17 +44,17 @@ static const char *err_strerr[] = {
"Ok.", /* ERR_OK 0 */
"Out of memory error.", /* ERR_MEM -1 */
"Buffer error.", /* ERR_BUF -2 */
- "Routing problem.", /* ERR_RTE -3 */
- "Connection aborted.", /* ERR_ABRT -4 */
- "Connection reset.", /* ERR_RST -5 */
- "Connection closed.", /* ERR_CLSD -6 */
- "Not connected.", /* ERR_CONN -7 */
- "Illegal value.", /* ERR_VAL -8 */
- "Illegal argument.", /* ERR_ARG -9 */
- "Address in use.", /* ERR_USE -10 */
- "Low-level netif error.", /* ERR_IF -11 */
- "Already connected.", /* ERR_ISCONN -12 */
- "Timeout.", /* ERR_TIMEOUT -13 */
+ "Timeout.", /* ERR_TIMEOUT -3 */
+ "Routing problem.", /* ERR_RTE -4 */
+ "Connection aborted.", /* ERR_ABRT -5 */
+ "Connection reset.", /* ERR_RST -6 */
+ "Connection closed.", /* ERR_CLSD -7 */
+ "Not connected.", /* ERR_CONN -8 */
+ "Illegal value.", /* ERR_VAL -9 */
+ "Illegal argument.", /* ERR_ARG -10 */
+ "Address in use.", /* ERR_USE -11 */
+ "Low-level netif error.", /* ERR_IF -12 */
+ "Already connected.", /* ERR_ISCONN -13 */
"Operation in progress." /* ERR_INPROGRESS -14 */
};
Index: src/api/netdb.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/netdb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- src/api/netdb.c 26 Jan 2008 16:11:39 -0000 1.4
+++ src/api/netdb.c 16 Jul 2008 20:36:12 -0000 1.5
@@ -326,7 +326,8 @@ lwip_getaddrinfo(const char *nodename, c
if (nodename != NULL) {
/* copy nodename to canonname if specified */
size_t namelen = strlen(nodename);
- ai->ai_canonname = mem_malloc(namelen + 1);
+ LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1);
+ ai->ai_canonname = mem_malloc((mem_size_t)(namelen + 1));
if (ai->ai_canonname == NULL) {
goto memerr;
}
Index: src/api/sockets.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/sockets.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -p -r1.116 -r1.117
--- src/api/sockets.c 13 Mar 2008 20:03:57 -0000 1.116
+++ src/api/sockets.c 9 May 2008 12:14:24 -0000 1.117
@@ -128,17 +128,17 @@ static const int err_to_errno_table[] =
0, /* ERR_OK 0 No error, everything OK. */
ENOMEM, /* ERR_MEM -1 Out of memory error. */
ENOBUFS, /* ERR_BUF -2 Buffer error. */
- EHOSTUNREACH, /* ERR_RTE -3 Routing problem. */
- ECONNABORTED, /* ERR_ABRT -4 Connection aborted. */
- ECONNRESET, /* ERR_RST -5 Connection reset. */
- ESHUTDOWN, /* ERR_CLSD -6 Connection closed. */
- ENOTCONN, /* ERR_CONN -7 Not connected. */
- EINVAL, /* ERR_VAL -8 Illegal value. */
- EIO, /* ERR_ARG -9 Illegal argument. */
- EADDRINUSE, /* ERR_USE -10 Address in use. */
- -1, /* ERR_IF -11 Low-level netif error */
- -1, /* ERR_ISCONN -12 Already connected. */
- ETIMEDOUT, /* ERR_TIMEOUT -13 Timeout */
+ ETIMEDOUT, /* ERR_TIMEOUT -3 Timeout */
+ EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */
+ ECONNABORTED, /* ERR_ABRT -5 Connection aborted. */
+ ECONNRESET, /* ERR_RST -6 Connection reset. */
+ ESHUTDOWN, /* ERR_CLSD -7 Connection closed. */
+ ENOTCONN, /* ERR_CONN -8 Not connected. */
+ EINVAL, /* ERR_VAL -9 Illegal value. */
+ EIO, /* ERR_ARG -10 Illegal argument. */
+ EADDRINUSE, /* ERR_USE -11 Address in use. */
+ -1, /* ERR_IF -12 Low-level netif error */
+ -1, /* ERR_ISCONN -13 Already connected. */
EINPROGRESS /* ERR_INPROGRESS -14 Operation in progress */
};
Index: src/api/tcpip.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/tcpip.c,v
retrieving revision 1.70
retrieving revision 1.73
diff -u -p -r1.70 -r1.73
--- src/api/tcpip.c 12 Jan 2008 11:52:22 -0000 1.70
+++ src/api/tcpip.c 27 Jun 2008 20:34:51 -0000 1.73
@@ -518,4 +518,42 @@ tcpip_init(void (* initfunc)(void *), vo
sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
}
+/**
+ * Simple callback function used with tcpip_callback to free a pbuf
+ * (pbuf_free has a wrong signature for tcpip_callback)
+ *
+ * @param p The pbuf (chain) to be dereferenced.
+ */
+static void
+pbuf_free_int(void *p)
+{
+ struct pbuf *q = p;
+ pbuf_free(q);
+}
+
+/**
+ * A simple wrapper function that allows you to free a pbuf from interrupt context.
+ *
+ * @param p The pbuf (chain) to be dereferenced.
+ * @return ERR_OK if callback could be enqueued, an err_t if not
+ */
+err_t
+pbuf_free_callback(struct pbuf *p)
+{
+ return tcpip_callback_with_block(pbuf_free_int, p, 0);
+}
+
+/**
+ * A simple wrapper function that allows you to free heap memory from
+ * interrupt context.
+ *
+ * @param m the heap memory to free
+ * @return ERR_OK if callback could be enqueued, an err_t if not
+ */
+err_t
+mem_free_callback(void *m)
+{
+ return tcpip_callback_with_block(mem_free, m, 0);
+}
+
#endif /* !NO_SYS */
Index: src/core/dhcp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/dhcp.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -p -r1.86 -r1.87
--- src/core/dhcp.c 4 Mar 2008 14:25:58 -0000 1.86
+++ src/core/dhcp.c 15 Apr 2008 17:24:55 -0000 1.87
@@ -568,6 +568,8 @@ dhcp_start(struct netif *netif)
LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;);
dhcp = netif->dhcp;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num));
+ /* Remove the flag that says this netif is handled by DHCP,
+ it is set when we succeeded starting. */
netif->flags &= ~NETIF_FLAG_DHCP;
/* no DHCP client attached yet? */
@@ -609,6 +611,7 @@ dhcp_start(struct netif *netif)
dhcp_stop(netif);
return ERR_MEM;
}
+ /* Set the flag that says this netif is handled by DHCP. */
netif->flags |= NETIF_FLAG_DHCP;
return result;
}
@@ -1063,6 +1066,8 @@ dhcp_stop(struct netif *netif)
{
struct dhcp *dhcp = netif->dhcp;
LWIP_ERROR("dhcp_stop: netif != NULL", (netif != NULL), return;);
+ /* Remove the flag that says this netif is handled by DHCP. */
+ netif->flags &= ~NETIF_FLAG_DHCP;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_stop()\n"));
/* netif is DHCP configured? */
Index: src/core/mem.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/mem.c,v
retrieving revision 1.59
retrieving revision 1.62
diff -u -p -r1.59 -r1.62
--- src/core/mem.c 4 Mar 2008 16:31:32 -0000 1.59
+++ src/core/mem.c 30 Jun 2008 18:16:51 -0000 1.62
@@ -177,9 +177,36 @@ static u8_t *ram;
static struct mem *ram_end;
/** pointer to the lowest free block, this is used for faster search */
static struct mem *lfree;
+
/** concurrent access protection */
static sys_sem_t mem_sem;
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+
+static volatile u8_t mem_free_count;
+
+/* Allow mem_free from other (e.g. interrupt) context */
+#define LWIP_MEM_FREE_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_free)
+#define LWIP_MEM_FREE_PROTECT() SYS_ARCH_PROTECT(lev_free)
+#define LWIP_MEM_FREE_UNPROTECT() SYS_ARCH_UNPROTECT(lev_free)
+#define LWIP_MEM_ALLOC_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_alloc)
+#define LWIP_MEM_ALLOC_PROTECT() SYS_ARCH_PROTECT(lev_alloc)
+#define LWIP_MEM_ALLOC_UNPROTECT() SYS_ARCH_UNPROTECT(lev_alloc)
+
+#else /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+
+/* Protect the heap only by using a semaphore */
+#define LWIP_MEM_FREE_DECL_PROTECT()
+#define LWIP_MEM_FREE_PROTECT() sys_arch_sem_wait(mem_sem, 0)
+#define LWIP_MEM_FREE_UNPROTECT() sys_sem_signal(mem_sem)
+/* mem_malloc is protected using semaphore AND LWIP_MEM_ALLOC_PROTECT */
+#define LWIP_MEM_ALLOC_DECL_PROTECT()
+#define LWIP_MEM_ALLOC_PROTECT()
+#define LWIP_MEM_ALLOC_UNPROTECT()
+
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+
+
/**
* "Plug holes" by combining adjacent empty struct mems.
* After this function is through, there should not exist
@@ -255,9 +282,7 @@ mem_init(void)
/* initialize the lowest-free pointer to the start of the heap */
lfree = (struct mem *)ram;
-#if MEM_STATS
- lwip_stats.mem.avail = MEM_SIZE_ALIGNED;
-#endif /* MEM_STATS */
+ MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED);
}
/**
@@ -270,6 +295,7 @@ void
mem_free(void *rmem)
{
struct mem *mem;
+ LWIP_MEM_FREE_DECL_PROTECT();
if (rmem == NULL) {
LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n"));
@@ -277,20 +303,20 @@ mem_free(void *rmem)
}
LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0);
- /* protect the heap from concurrent access */
- sys_arch_sem_wait(mem_sem, 0);
-
LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
(u8_t *)rmem < (u8_t *)ram_end);
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
+ SYS_ARCH_DECL_PROTECT(lev);
LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n"));
-#if MEM_STATS
- ++lwip_stats.mem.err;
-#endif /* MEM_STATS */
- sys_sem_signal(mem_sem);
+ /* protect mem stats from concurrent access */
+ SYS_ARCH_PROTECT(lev);
+ MEM_STATS_INC(illegal);
+ SYS_ARCH_UNPROTECT(lev);
return;
}
+ /* protect the heap from concurrent access */
+ LWIP_MEM_FREE_PROTECT();
/* Get the corresponding struct mem ... */
mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM);
/* ... which has to be in a used state ... */
@@ -303,13 +329,14 @@ mem_free(void *rmem)
lfree = mem;
}
-#if MEM_STATS
- lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram);
-#endif /* MEM_STATS */
+ MEM_STATS_DEC_USED(used, mem->next - ((u8_t *)mem - ram));
/* finally, see if prev or next are free also */
plug_holes(mem);
- sys_sem_signal(mem_sem);
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ mem_free_count = 1;
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+ LWIP_MEM_FREE_UNPROTECT();
}
/**
@@ -321,6 +348,8 @@ mem_free(void *rmem)
* @param newsize required size after shrinking (needs to be smaller than or
* equal to the previous size)
* @return for compatibility reasons: is always == rmem, at the moment
+ * or NULL if newsize is > old size, in which case rmem is NOT touched
+ * or freed!
*/
void *
mem_realloc(void *rmem, mem_size_t newsize)
@@ -328,6 +357,8 @@ mem_realloc(void *rmem, mem_size_t newsi
mem_size_t size;
mem_size_t ptr, ptr2;
struct mem *mem, *mem2;
+ /* use the FREE_PROTECT here: it protects with sem OR SYS_ARCH_PROTECT */
+ LWIP_MEM_FREE_DECL_PROTECT();
/* Expand the size of the allocated memory region so that we can
adjust for alignment. */
@@ -346,7 +377,12 @@ mem_realloc(void *rmem, mem_size_t newsi
(u8_t *)rmem < (u8_t *)ram_end);
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
+ SYS_ARCH_DECL_PROTECT(lev);
LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n"));
+ /* protect mem stats from concurrent access */
+ SYS_ARCH_PROTECT(lev);
+ MEM_STATS_INC(illegal);
+ SYS_ARCH_UNPROTECT(lev);
return rmem;
}
/* Get the corresponding struct mem ... */
@@ -366,11 +402,9 @@ mem_realloc(void *rmem, mem_size_t newsi
}
/* protect the heap from concurrent access */
- sys_arch_sem_wait(mem_sem, 0);
+ LWIP_MEM_FREE_PROTECT();
-#if MEM_STATS
- lwip_stats.mem.used -= (size - newsize);
-#endif /* MEM_STATS */
+ MEM_STATS_DEC_USED(used, (size - newsize));
mem2 = (struct mem *)&ram[mem->next];
if(mem2->used == 0) {
@@ -426,7 +460,10 @@ mem_realloc(void *rmem, mem_size_t newsi
-> don't do anyhting.
-> the remaining space stays unused since it is too small
} */
- sys_sem_signal(mem_sem);
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ mem_free_count = 1;
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+ LWIP_MEM_FREE_UNPROTECT();
return rmem;
}
@@ -444,6 +481,10 @@ mem_malloc(mem_size_t size)
{
mem_size_t ptr, ptr2;
struct mem *mem, *mem2;
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ u8_t local_mem_free_count = 0;
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+ LWIP_MEM_ALLOC_DECL_PROTECT();
if (size == 0) {
return NULL;
@@ -464,88 +505,101 @@ mem_malloc(mem_size_t size)
/* protect the heap from concurrent access */
sys_arch_sem_wait(mem_sem, 0);
+ LWIP_MEM_ALLOC_PROTECT();
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ /* run as long as a mem_free disturbed mem_malloc */
+ do {
+ local_mem_free_count = 0;
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
+
+ /* Scan through the heap searching for a free block that is big enough,
+ * beginning with the lowest free block.
+ */
+ for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED - size;
+ ptr = ((struct mem *)&ram[ptr])->next) {
+ mem = (struct mem *)&ram[ptr];
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ mem_free_count = 0;
+ LWIP_MEM_ALLOC_UNPROTECT();
+ /* allow mem_free to run */
+ LWIP_MEM_ALLOC_PROTECT();
+ if (mem_free_count != 0) {
+ local_mem_free_count = mem_free_count;
+ }
+ mem_free_count = 0;
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
- /* Scan through the heap searching for a free block that is big enough,
- * beginning with the lowest free block.
- */
- for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED - size;
- ptr = ((struct mem *)&ram[ptr])->next) {
- mem = (struct mem *)&ram[ptr];
-
- if ((!mem->used) &&
- (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) {
- /* mem is not used and at least perfect fit is possible:
- * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */
-
- if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) {
- /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing
- * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem')
- * -> split large block, create empty remainder,
- * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if
- * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size,
- * struct mem would fit in but no data between mem2 and mem2->next
- * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty
- * region that couldn't hold data, but when mem->next gets freed,
- * the 2 regions would be combined, resulting in more free memory
- */
- ptr2 = ptr + SIZEOF_STRUCT_MEM + size;
- /* create mem2 struct */
- mem2 = (struct mem *)&ram[ptr2];
- mem2->used = 0;
- mem2->next = mem->next;
- mem2->prev = ptr;
- /* and insert it between mem and mem->next */
- mem->next = ptr2;
- mem->used = 1;
-
- if (mem2->next != MEM_SIZE_ALIGNED) {
- ((struct mem *)&ram[mem2->next])->prev = ptr2;
- }
-#if MEM_STATS
- lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
- if (lwip_stats.mem.max < lwip_stats.mem.used) {
- lwip_stats.mem.max = lwip_stats.mem.used;
+ if ((!mem->used) &&
+ (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) {
+ /* mem is not used and at least perfect fit is possible:
+ * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */
+
+ if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) {
+ /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing
+ * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem')
+ * -> split large block, create empty remainder,
+ * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if
+ * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size,
+ * struct mem would fit in but no data between mem2 and mem2->next
+ * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty
+ * region that couldn't hold data, but when mem->next gets freed,
+ * the 2 regions would be combined, resulting in more free memory
+ */
+ ptr2 = ptr + SIZEOF_STRUCT_MEM + size;
+ /* create mem2 struct */
+ mem2 = (struct mem *)&ram[ptr2];
+ mem2->used = 0;
+ mem2->next = mem->next;
+ mem2->prev = ptr;
+ /* and insert it between mem and mem->next */
+ mem->next = ptr2;
+ mem->used = 1;
+
+ if (mem2->next != MEM_SIZE_ALIGNED) {
+ ((struct mem *)&ram[mem2->next])->prev = ptr2;
+ }
+ MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM));
+ } else {
+ /* (a mem2 struct does no fit into the user data space of mem and mem->next will always
+ * be used at this point: if not we have 2 unused structs in a row, plug_holes should have
+ * take care of this).
+ * -> near fit or excact fit: do not split, no mem2 creation
+ * also can't move mem->next directly behind mem, since mem->next
+ * will always be used at this point!
+ */
+ mem->used = 1;
+ MEM_STATS_INC_USED(used, mem->next - ((u8_t *)mem - ram));
}
-#endif /* MEM_STATS */
- } else {
- /* (a mem2 struct does no fit into the user data space of mem and mem->next will always
- * be used at this point: if not we have 2 unused structs in a row, plug_holes should have
- * take care of this).
- * -> near fit or excact fit: do not split, no mem2 creation
- * also can't move mem->next directly behind mem, since mem->next
- * will always be used at this point!
- */
- mem->used = 1;
-#if MEM_STATS
- lwip_stats.mem.used += mem->next - ((u8_t *)mem - ram);
- if (lwip_stats.mem.max < lwip_stats.mem.used) {
- lwip_stats.mem.max = lwip_stats.mem.used;
- }
-#endif /* MEM_STATS */
- }
- if (mem == lfree) {
- /* Find next free block after mem and update lowest free pointer */
- while (lfree->used && lfree != ram_end) {
- lfree = (struct mem *)&ram[lfree->next];
+ if (mem == lfree) {
+ /* Find next free block after mem and update lowest free pointer */
+ while (lfree->used && lfree != ram_end) {
+ LWIP_MEM_ALLOC_UNPROTECT();
+ /* prevent high interrupt latency... */
+ LWIP_MEM_ALLOC_PROTECT();
+ lfree = (struct mem *)&ram[lfree->next];
+ }
+ LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used)));
}
- LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used)));
- }
- sys_sem_signal(mem_sem);
- LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.",
- (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end);
- LWIP_ASSERT("mem_malloc: allocated memory properly aligned.",
- (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
- LWIP_ASSERT("mem_malloc: sanity check alignment",
- (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0);
+ LWIP_MEM_ALLOC_UNPROTECT();
+ sys_sem_signal(mem_sem);
+ LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.",
+ (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end);
+ LWIP_ASSERT("mem_malloc: allocated memory properly aligned.",
+ (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
+ LWIP_ASSERT("mem_malloc: sanity check alignment",
+ (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0);
- return (u8_t *)mem + SIZEOF_STRUCT_MEM;
+ return (u8_t *)mem + SIZEOF_STRUCT_MEM;
+ }
}
- }
+#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
+ /* if we got interrupted by a mem_free, try again */
+ } while(local_mem_free_count != 0);
+#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size));
-#if MEM_STATS
- ++lwip_stats.mem.err;
-#endif /* MEM_STATS */
+ MEM_STATS_INC(err);
+ LWIP_MEM_ALLOC_UNPROTECT();
sys_sem_signal(mem_sem);
return NULL;
}
Index: src/core/memp.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/memp.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -p -r1.55 -r1.56
--- src/core/memp.c 25 Nov 2007 10:43:28 -0000 1.55
+++ src/core/memp.c 27 Jun 2008 18:37:54 -0000 1.56
@@ -252,13 +252,12 @@ memp_init(void)
struct memp *memp;
u16_t i, j;
-#if MEMP_STATS
for (i = 0; i < MEMP_MAX; ++i) {
- lwip_stats.memp[i].used = lwip_stats.memp[i].max =
- lwip_stats.memp[i].err = 0;
- lwip_stats.memp[i].avail = memp_num[i];
+ MEMP_STATS_AVAIL(used, i, 0);
+ MEMP_STATS_AVAIL(max, i, 0);
+ MEMP_STATS_AVAIL(err, i, 0);
+ MEMP_STATS_AVAIL(avail, i, memp_num[i]);
}
-#endif /* MEMP_STATS */
memp = LWIP_MEM_ALIGN(memp_memory);
/* for every pool: */
@@ -315,20 +314,13 @@ memp_malloc_fn(memp_t type, const char*
memp->file = file;
memp->line = line;
#endif /* MEMP_OVERFLOW_CHECK */
-#if MEMP_STATS
- ++lwip_stats.memp[type].used;
- if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) {
- lwip_stats.memp[type].max = lwip_stats.memp[type].used;
- }
-#endif /* MEMP_STATS */
+ MEMP_STATS_INC_USED(used, type);
LWIP_ASSERT("memp_malloc: memp properly aligned",
((mem_ptr_t)memp % MEM_ALIGNMENT) == 0);
memp = (struct memp*)((u8_t*)memp + MEMP_SIZE);
} else {
LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %s\n", memp_desc[type]));
-#if MEMP_STATS
- ++lwip_stats.memp[type].err;
-#endif /* MEMP_STATS */
+ MEMP_STATS_INC(err, type);
}
SYS_ARCH_UNPROTECT(old_level);
@@ -365,9 +357,7 @@ memp_free(memp_t type, void *mem)
#endif /* MEMP_OVERFLOW_CHECK >= 2 */
#endif /* MEMP_OVERFLOW_CHECK */
-#if MEMP_STATS
- lwip_stats.memp[type].used--;
-#endif /* MEMP_STATS */
+ MEMP_STATS_DEC(used, type);
memp->next = memp_tab[type];
memp_tab[type] = memp;
Index: src/core/netif.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/netif.c,v
retrieving revision 1.65
retrieving revision 1.68
diff -u -p -r1.65 -r1.68
--- src/core/netif.c 9 Oct 2007 20:00:55 -0000 1.65
+++ src/core/netif.c 19 Jun 2008 16:27:18 -0000 1.68
@@ -45,6 +45,12 @@
#include "lwip/snmp.h"
#include "lwip/igmp.h"
#include "netif/etharp.h"
+#if ENABLE_LOOPBACK
+#include "lwip/sys.h"
+#if LWIP_NETIF_LOOPBACK_MULTITHREADING
+#include "lwip/tcpip.h"
+#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
+#endif /* ENABLE_LOOPBACK */
#if LWIP_NETIF_STATUS_CALLBACK
#define NETIF_STATUS_CALLBACK(n) { if (n->status_callback) (n->status_callback)(n); }
@@ -106,6 +112,10 @@ netif_add(struct netif *netif, struct ip
#if LWIP_IGMP
netif->igmp_mac_filter = NULL;
#endif /* LWIP_IGMP */
+#if ENABLE_LOOPBACK
+ netif->loop_first = NULL;
+ netif->loop_last = NULL;
+#endif /* ENABLE_LOOPBACK */
/* remember netif specific state information data */
netif->state = state;
@@ -114,6 +124,9 @@ netif_add(struct netif *netif, struct ip
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
+#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
+ netif->loop_cnt_current = 0;
+#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */
netif_set_addr(netif, ipaddr, netmask, gw);
@@ -493,7 +506,158 @@ u8_t netif_is_link_up(struct netif *neti
*/
void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif ))
{
- if ( netif )
- netif->link_callback = link_callback;
+ if (netif) {
+ netif->link_callback = link_callback;
+ }
}
#endif /* LWIP_NETIF_LINK_CALLBACK */
+
+#if ENABLE_LOOPBACK
+/**
+ * Send an IP packet to be received on the same netif (loopif-like).
+ * The pbuf is simply copied and handed back to netif->input.
+ * In multithreaded mode, this is done directly since netif->input must put
+ * the packet on a queue.
+ * In callback mode, the packet is put on an internal queue and is fed to
+ * netif->input by netif_poll().
+ *
+ * @param netif the lwip network interface structure
+ * @param p the (IP) packet to 'send'
+ * @param ipaddr the ip address to send the packet to (not used)
+ * @return ERR_OK if the packet has been sent
+ * ERR_MEM if the pbuf used to copy the packet couldn't be allocated
+ */
+err_t
+netif_loop_output(struct netif *netif, struct pbuf *p,
+ struct ip_addr *ipaddr)
+{
+ struct pbuf *r;
+ err_t err;
+ struct pbuf *last;
+#if LWIP_LOOPBACK_MAX_PBUFS
+ u8_t clen = 0;
+#endif /* LWIP_LOOPBACK_MAX_PBUFS */
+ SYS_ARCH_DECL_PROTECT(lev);
+ LWIP_UNUSED_ARG(ipaddr);
+
+ /* Allocate a new pbuf */
+ r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
+ if (r == NULL) {
+ return ERR_MEM;
+ }
+#if LWIP_LOOPBACK_MAX_PBUFS
+ clen = pbuf_clen(r);
+ /* check for overflow or too many pbuf on queue */
+ if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
+ ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) {
+ pbuf_free(r);
+ r = NULL;
+ return ERR_MEM;
+ }
+ netif->loop_cnt_current += clen;
+#endif /* LWIP_LOOPBACK_MAX_PBUFS */
+
+ /* Copy the whole pbuf queue p into the single pbuf r */
+ if ((err = pbuf_copy(r, p)) != ERR_OK) {
+ pbuf_free(r);
+ r = NULL;
+ return err;
+ }
+
+ /* Put the packet on a linked list which gets emptied through calling
+ netif_poll(). */
+
+ /* let last point to the last pbuf in chain r */
+ for (last = r; last->next != NULL; last = last->next);
+
+ SYS_ARCH_PROTECT(lev);
+ if(netif->loop_first != NULL) {
+ LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
+ netif->loop_last->next = r;
+ netif->loop_last = last;
+ } else {
+ netif->loop_first = r;
+ netif->loop_last = last;
+ }
+ SYS_ARCH_UNPROTECT(lev);
+
+#if LWIP_NETIF_LOOPBACK_MULTITHREADING
+ /* For multithreading environment, schedule a call to netif_poll */
+ tcpip_callback(netif_poll, netif);
+#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
+
+ return ERR_OK;
+}
+
+/**
+ * Call netif_poll() in the main loop of your application. This is to prevent
+ * reentering non-reentrant functions like tcp_input(). Packets passed to
+ * netif_loop_output() are put on a list that is passed to netif->input() by
+ * netif_poll().
+ */
+void
+netif_poll(struct netif *netif)
+{
+ struct pbuf *in;
+ SYS_ARCH_DECL_PROTECT(lev);
+
+ do {
+ /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */
+ SYS_ARCH_PROTECT(lev);
+ in = netif->loop_first;
+ if(in != NULL) {
+ struct pbuf *in_end = in;
+#if LWIP_LOOPBACK_MAX_PBUFS
+ u8_t clen = pbuf_clen(in);
+ /* adjust the number of pbufs on queue */
+ LWIP_ASSERT("netif->loop_cnt_current underflow",
+ ((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
+ netif->loop_cnt_current -= clen;
+#endif /* LWIP_LOOPBACK_MAX_PBUFS */
+ while(in_end->len != in_end->tot_len) {
+ LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL);
+ in_end = in_end->next;
+ }
+ /* 'in_end' now points to the last pbuf from 'in' */
+ if(in_end == netif->loop_last) {
+ /* this was the last pbuf in the list */
+ netif->loop_first = netif->loop_last = NULL;
+ } else {
+ /* pop the pbuf off the list */
+ netif->loop_first = in_end->next;
+ LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL);
+ }
+ /* De-queue the pbuf from its successors on the 'loop_' list. */
+ in_end->next = NULL;
+ }
+ SYS_ARCH_UNPROTECT(lev);
+
+ if(in != NULL) {
+ /* loopback packets are always IP packets! */
+ if(ip_input(in, netif) != ERR_OK) {
+ pbuf_free(in);
+ }
+ /* Don't reference the packet any more! */
+ in = NULL;
+ }
+ /* go on while there is a packet on the list */
+ } while(netif->loop_first != NULL);
+}
+
+#if !LWIP_NETIF_LOOPBACK_MULTITHREADING
+/**
+ * Calls netif_poll() for every netif on the netif_list.
+ */
+void
+netif_poll_all(void)
+{
+ struct netif *netif = netif_list;
+ /* loop through netifs */
+ while (netif != NULL) {
+ netif_poll(netif);
+ /* proceed to next network interface */
+ netif = netif->next;
+ }
+}
+#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
+#endif /* ENABLE_LOOPBACK */
Index: src/core/pbuf.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/pbuf.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -p -r1.127 -r1.128
--- src/core/pbuf.c 4 Mar 2008 16:37:46 -0000 1.127
+++ src/core/pbuf.c 1 Apr 2008 19:05:40 -0000 1.128
@@ -667,8 +667,8 @@ pbuf_dechain(struct pbuf *p)
*
* @note Only one packet is copied, no packet queue!
*
- * @param p_to pbuf source of the copy
- * @param p_from pbuf destination of the copy
+ * @param p_to pbuf destination of the copy
+ * @param p_from pbuf source of the copy
*
* @return ERR_OK if pbuf was copied
* ERR_ARG if one of the pbufs is NULL or p_to is not big
Index: src/core/stats.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/stats.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -p -r1.27 -r1.28
--- src/core/stats.c 4 Mar 2008 16:31:32 -0000 1.27
+++ src/core/stats.c 27 Jun 2008 18:37:54 -0000 1.28
@@ -54,7 +54,6 @@ stats_display_proto(struct stats_proto *
{
LWIP_PLATFORM_DIAG(("\n%s\n\t", name));
LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit));
- LWIP_PLATFORM_DIAG(("rexmit: %"STAT_COUNTER_F"\n\t", proto->rexmit));
LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv));
LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw));
LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop));
@@ -68,6 +67,7 @@ stats_display_proto(struct stats_proto *
LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit));
}
+#if IGMP_STATS
void
stats_display_igmp(struct stats_igmp *igmp)
{
@@ -82,7 +82,9 @@ stats_display_igmp(struct stats_igmp *ig
LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed));
LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed));
}
+#endif /* IGMP_STATS */
+#if MEM_STATS || MEMP_STATS
void
stats_display_mem(struct stats_mem *mem, char *name)
{
@@ -93,48 +95,53 @@ stats_display_mem(struct stats_mem *mem,
LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err));
}
+#if MEMP_STATS
void
-stats_display(void)
+stats_display_memp(struct stats_mem *mem, int index)
{
-#if MEMP_STATS