ip.ed - vx32 - Local 9vx git repository for patches.
(HTM) git clone git://r-36.net/vx32
(DIR) Log
(DIR) Files
(DIR) Refs
---
ip.ed (31039B)
---
1 diff -e ip.orig/arp.c ip/arp.c
2 643c
3 QUNLOCK(arp);
4 .
5 613,614c
6 RUNLOCK(ifc);
7 QLOCK(arp);
8 .
9 609c
10 QUNLOCK(arp); /* for icmpns */
11 .
12 589c
13 if((a->rxtsrem <= 0) || !(CANRLOCK(ifc)) || (a->ifcid != ifc->ifcid)){
14 .
15 574c
16 QLOCK(arp);
17 .
18 557c
19 QUNLOCK(arp);
20 .
21 554c
22 QLOCK(arp);
23 .
24 511c
25 QUNLOCK(arp);
26 .
27 481c
28 QLOCK(arp);
29 .
30 444c
31 QUNLOCK(arp);
32 .
33 426c
34 QLOCK(arp);
35 .
36 398c
37 QUNLOCK(arp);
38 .
39 380c
40 RUNLOCK(ifc);
41 .
42 375c
43 RLOCK(ifc);
44 .
45 372c
46 RUNLOCK(ifc);
47 .
48 366c
49 QUNLOCK(arp);
50 .
51 337c
52 QLOCK(arp);
53 .
54 292c
55 QUNLOCK(arp);
56 .
57 260c
58 QUNLOCK(arp);
59 .
60 258c
61 arprelease(Arp *arp, Arpent* ae)
62 .
63 250c
64 QUNLOCK(arp);
65 .
66 219c
67 QLOCK(arp);
68 .
69 50c
70 int ReTransTimer = RETRANS_TIMER;
71 .
72 48c
73 #define haship(s) ((ulong)((s)[IPaddrlen-1])%NHASH)
74 .
75 36c
76 QLock qlock;
77 .
78 14d
79 6c
80 #include "error.h"
81 .
82 2c
83 #include "lib.h"
84 .
85 diff -e ip.orig/chandial.c ip/chandial.c
86 6,7c
87 #include "error.h"
88 #include "ip/ip.h"
89 .
90 2c
91 #include "lib.h"
92 .
93 diff -e ip.orig/devip.c ip/devip.c
94 1430c
95 QUNLOCK(c);
96 .
97 1418c
98 QUNLOCK(c);
99 .
100 1404,1411c
101 QUNLOCK(c);
102 .
103 1399c
104 QLOCK(c);
105 .
106 1349c
107 QUNLOCK(c);
108 .
109 1326,1328d
110 1322,1323d
111 1318c
112 QUNLOCK(c);
113 .
114 1310c
115 if(CANQLOCK(c)){
116 .
117 1294c
118 QLOCK(c);
119 .
120 1185c
121 QUNLOCK(c);
122 .
123 1130c
124 QUNLOCK(c);
125 .
126 1128c
127 QLOCK(c);
128 .
129 1033c
130 QLOCK(c);
131 .
132 1029c
133 QLOCK(c);
134 .
135 1027c
136 QUNLOCK(c);
137 .
138 980c
139 QLOCK(c);
140 .
141 976c
142 QLOCK(c);
143 .
144 974c
145 QUNLOCK(c);
146 .
147 831c
148 QUNLOCK(p);
149 .
150 820,826c
151 QUNLOCK(p);
152 .
153 793c
154 QLOCK(p);
155 .
156 765c
157 QUNLOCK(p);
158 .
159 760c
160 QUNLOCK(p);
161 .
162 748c
163 QLOCK(p);
164 .
165 582c
166 QUNLOCK(cv);
167 .
168 561c
169 QUNLOCK(cv);
170 .
171 558c
172 QLOCK(cv);
173 .
174 516c
175 ipremove(Chan* _)
176 .
177 510c
178 ipcreate(Chan* _, char* __, int ___, ulong ____)
179 .
180 494c
181 QUNLOCK(cv);
182 .
183 487c
184 QLOCK(cv);
185 .
186 470c
187 QUNLOCK(cv);
188 .
189 468c
190 QLOCK(cv);
191 .
192 447,448c
193 QUNLOCK(cv);
194 QUNLOCK(p);
195 .
196 431,432c
197 QUNLOCK(cv);
198 QUNLOCK(p);
199 .
200 429c
201 QLOCK(cv);
202 .
203 427c
204 QLOCK(p);
205 .
206 415c
207 QUNLOCK(p);
208 .
209 411c
210 QUNLOCK(p);
211 .
212 409c
213 QLOCK(p);
214 .
215 174c
216 ipgen(Chan *c, char* __ch, Dirtab* __dt, int __i, int s, Dir *dp)
217 .
218 50c
219 #define QID(p, c, y) ( ((uint)(p)<<(Shiftproto)) | ((uint)(c)<<Shiftconv) | (y) )
220 .
221 6,7c
222 #include "error.h"
223 #include "ip/ip.h"
224 .
225 2c
226 #include "lib.h"
227 .
228 diff -e ip.orig/esp.c ip/esp.c
229 1106a
230
231
232 #ifdef notdef
233 enum {
234 RC4forward= 10*1024*1024, /* maximum skip forward */
235 RC4back = 100*1024, /* maximum look back */
236 };
237
238 typedef struct Esprc4 Esprc4;
239 struct Esprc4
240 {
241 ulong cseq; /* current byte sequence number */
242 RC4state current;
243
244 int ovalid; /* old is valid */
245 ulong lgseq; /* last good sequence */
246 ulong oseq; /* old byte sequence number */
247 RC4state old;
248 };
249
250 static void rc4espinit(Espcb *ecb, char *name, uchar *k, int n);
251
252 static int
253 rc4cipher(Espcb *ecb, uchar *p, int n)
254 {
255 Esprc4 *esprc4;
256 RC4state tmpstate;
257 ulong seq;
258 long d, dd;
259
260 if(n < 4)
261 return 0;
262
263 esprc4 = ecb->espstate;
264 if(ecb->incoming) {
265 seq = nhgetl(p);
266 p += 4;
267 n -= 4;
268 d = seq-esprc4->cseq;
269 if(d == 0) {
270 rc4(&esprc4->current, p, n);
271 esprc4->cseq += n;
272 if(esprc4->ovalid) {
273 dd = esprc4->cseq - esprc4->lgseq;
274 if(dd > RC4back)
275 esprc4->ovalid = 0;
276 }
277 } else if(d > 0) {
278 print("esp rc4cipher: missing packet: %uld %ld\n", seq, d); /* this link is hosed */
279 if(d > RC4forward) {
280 strcpy(up->errstr, "rc4cipher: skipped too much");
281 return 0;
282 }
283 esprc4->lgseq = seq;
284 if(!esprc4->ovalid) {
285 esprc4->ovalid = 1;
286 esprc4->oseq = esprc4->cseq;
287 memmove(&esprc4->old, &esprc4->current,
288 sizeof(RC4state));
289 }
290 rc4skip(&esprc4->current, d);
291 rc4(&esprc4->current, p, n);
292 esprc4->cseq = seq+n;
293 } else {
294 print("esp rc4cipher: reordered packet: %uld %ld\n", seq, d);
295 dd = seq - esprc4->oseq;
296 if(!esprc4->ovalid || -d > RC4back || dd < 0) {
297 strcpy(up->errstr, "rc4cipher: too far back");
298 return 0;
299 }
300 memmove(&tmpstate, &esprc4->old, sizeof(RC4state));
301 rc4skip(&tmpstate, dd);
302 rc4(&tmpstate, p, n);
303 return 1;
304 }
305
306 /* move old state up */
307 if(esprc4->ovalid) {
308 dd = esprc4->cseq - RC4back - esprc4->oseq;
309 if(dd > 0) {
310 rc4skip(&esprc4->old, dd);
311 esprc4->oseq += dd;
312 }
313 }
314 } else {
315 hnputl(p, esprc4->cseq);
316 p += 4;
317 n -= 4;
318 rc4(&esprc4->current, p, n);
319 esprc4->cseq += n;
320 }
321 return 1;
322 }
323
324 static void
325 rc4espinit(Espcb *ecb, char *name, uchar *k, int n)
326 {
327 Esprc4 *esprc4;
328
329 /* bits to bytes */
330 n = (n+7)>>3;
331 esprc4 = smalloc(sizeof(Esprc4));
332 memset(esprc4, 0, sizeof(Esprc4));
333 setupRC4state(&esprc4->current, k, n);
334 ecb->espalg = name;
335 ecb->espblklen = 4;
336 ecb->espivlen = 4;
337 ecb->cipher = rc4cipher;
338 ecb->espstate = esprc4;
339 }
340 #endif
341 .
342 1056,1081d
343 1048,1050c
344 ecb->espblklen = 8;
345 ecb->espivlen = 8;
346 .
347 1045c
348 for(i=0; i<8; i++)
349 .
350 1040,1042c
351 /* bits to bytes */
352 n = (n+7)>>3;
353 if(n > 8)
354 n = 8;
355 .
356 1037c
357 uchar key[8], ivec[8];
358 .
359 1035c
360 desespinit(Espcb *ecb, char *name, uchar *k, int n)
361 .
362 1019,1033d
363 1013,1014c
364 memmove(p, ds->ivec, 8);
365 for(p += 8; p < ep; p += 8){
366 pp = p;
367 ip = ds->ivec;
368 for(eip = ip+8; ip < eip; )
369 *pp++ ^= *ip++;
370 block_cipher(ds->expanded, p, 0);
371 memmove(ds->ivec, p, 8);
372 }
373 .
374 1010,1011c
375 memmove(ds->ivec, p, 8);
376 p += 8;
377 while(p < ep){
378 memmove(tmp, p, 8);
379 block_cipher(ds->expanded, p, 1);
380 tp = tmp;
381 ip = ds->ivec;
382 for(eip = ip+8; ip < eip; ){
383 *p++ ^= *ip;
384 *ip++ = *tp++;
385 }
386 }
387 .
388 1008a
389 ep = p + n;
390 .
391 1006a
392 uchar tmp[8];
393 uchar *pp, *tp, *ip, *eip, *ep;
394 .
395 999,1003d
396 993c
397 ecb->ahlen = 12;
398 .
399 990c
400 klen >>= 3; /* convert to bytes */
401
402 .
403 986c
404 md5ahinit(Espcb *ecb, char *name, uchar *key, int klen)
405 .
406 979c
407 seanq_hmac_md5(hash, t, tlen, (uchar*)ecb->ahstate, 16);
408 .
409 968c
410 digest = md5(opad, 64, nil, nil);
411 .
412 966c
413 digest = md5(ipad, 64, nil, nil);
414 .
415 959,962c
416 for(i=0; i<64; i++){
417 ipad[i] = 0x36;
418 opad[i] = 0x5c;
419 }
420 ipad[64] = opad[64] = 0;
421 for(i=0; i<klen; i++){
422 .
423 957a
424 uchar innerhash[MD5dlen];
425 .
426 956d
427 954a
428 uchar ipad[65], opad[65];
429 .
430 796,952c
431 void
432 .
433 790c
434 ecb->ahlen = 12;
435 .
436 786c
437 klen >>= 8; /* convert to bytes */
438 .
439 782c
440 shaahinit(Espcb *ecb, char *name, uchar *key, int klen)
441 .
442 775c
443 seanq_hmac_sha1(hash, t, tlen, (uchar*)ecb->ahstate, 16);
444 .
445 772a
446 int r;
447 .
448 771d
449 764c
450 digest = sha1(opad, 64, nil, nil);
451 .
452 762c
453 digest = sha1(ipad, 64, nil, nil);
454 .
455 755,758c
456 for(i=0; i<64; i++){
457 ipad[i] = 0x36;
458 opad[i] = 0x5c;
459 }
460 ipad[64] = opad[64] = 0;
461 for(i=0; i<klen; i++){
462 .
463 753a
464 uchar innerhash[SHA1dlen];
465 .
466 752d
467 750a
468 uchar ipad[65], opad[65];
469 .
470 743,748c
471 void
472 .
473 735c
474 nullahinit(Espcb *ecb, char *name, uchar* _, int __)
475 .
476 729c
477 nullauth(Espcb* _, uchar* __, int ___, uchar* ____)
478 .
479 720c
480 nullespinit(Espcb *ecb, char *name, uchar* _, int __)
481 .
482 714c
483 nullcipher(Espcb* _, uchar* __, int ___)
484 .
485 708,712d
486 647c
487 QUNLOCK(c);
488 .
489 642c
490 QLOCK(c);
491 .
492 632c
493 QUNLOCK(c);
494 .
495 627c
496 QLOCK(c);
497 .
498 606c
499 QUNLOCK(esp);
500 .
501 600,601c
502 spi = nhgets(h->espspi);
503 QLOCK(esp);
504 c = convlookup(esp, spi);
505 .
506 597,598c
507 h = (Esp4hdr*)(bp->rp);
508 .
509 595c
510 ulong spi;
511 .
512 593a
513 Esp4hdr *h;
514 .
515 590d
516 568c
517 QUNLOCK(c);
518 .
519 565c
520 qpass(c->rq, bp);
521 .
522 560,561c
523 netlog(f, Logesp, "esp: qfull %I -> %I.%uld\n", raddr,
524 laddr, spi);
525 .
526 557,558d
527 547c
528 bp->rp += hdrlen + ecb->espivlen;
529 .
530 539,541c
531 QUNLOCK(c);
532 netlog(f, Logesp, "esp: short packet after decrypt %I -> %I!%d\n",
533 raddr, laddr, spi);
534 .
535 535c
536 et = (Esptail*)(bp->rp + hdrlen + payload);
537 .
538 523,529c
539 if(!ecb->cipher(ecb, bp->rp + hdrlen, payload)) {
540 QUNLOCK(c);
541 print("esp: cipher failed %I -> %I!%ld: %s\n", raddr, laddr, spi, up->errstr);
542 netlog(f, Logesp, "esp: cipher failed %I -> %I!%d: %s\n", raddr,
543 laddr, spi, up->errstr);
544 .
545 517,519c
546 QUNLOCK(c);
547 netlog(f, Logesp, "esp: bad length %I -> %I!%d payload=%d BLEN=%d\n",
548 raddr, laddr, spi, payload, BLEN(bp));
549 .
550 515c
551 payload = BLEN(bp) - hdrlen - ecb->ahlen;
552 .
553 507,510c
554 QUNLOCK(c);
555 print("esp: bad auth %I -> %I!%ld\n", raddr, laddr, spi);
556 netlog(f, Logesp, "esp: bad auth %I -> %I!%d\n", raddr,
557 laddr, spi);
558 .
559 502,505c
560 espspi = version == V4? ((Esp4hdr*)bp->rp)->espspi:
561 ((Esp6hdr*)bp->rp)->espspi;
562 .
563 493,496c
564 if(BLEN(bp) < hdrlen + ecb->espivlen + Esptaillen + ecb->ahlen) {
565 QUNLOCK(c);
566 netlog(f, Logesp, "esp: short block %I -> %I!%d\n", raddr,
567 laddr, spi);
568 .
569 485,486c
570 QLOCK(c);
571 QUNLOCK(esp);
572 .
573 477,479c
574 QUNLOCK(esp);
575 netlog(f, Logesp, "esp: no conv %I -> %I!%d\n", raddr,
576 laddr, spi);
577 .
578 475c
579 c = convlookup(esp, spi);
580 .
581 473c
582 if (version == V4) {
583 eh4 = (Esp4hdr*)bp->rp;
584 spi = nhgetl(eh4->espspi);
585 v4tov6(raddr, eh4->espsrc);
586 v4tov6(laddr, eh4->espdst);
587 } else {
588 eh6 = (Esp6hdr*)bp->rp;
589 spi = nhgetl(eh6->espspi);
590 ipmove(raddr, eh6->src);
591 ipmove(laddr, eh6->dst);
592 }
593
594 QLOCK(esp);
595 .
596 471d
597 464,466c
598 bp = pullupblock(bp, hdrlen + Esptaillen);
599 .
600 462a
601 if (bp == nil || BLEN(bp) == 0) {
602 /* get enough to identify the IP version */
603 bp = pullupblock(bp, IP4HDR);
604 if(bp == nil) {
605 netlog(f, Logesp, "esp: short packet\n");
606 return;
607 }
608 }
609 eh4 = (Esp4hdr*)bp->rp;
610 version = ((eh4->vihl & 0xf0) == IP_VER4? V4: V6);
611 hdrlen = version == V4? Esp4hdrlen: Esp6hdrlen;
612 .
613 459,460c
614 uchar *auth, *espspi;
615 ulong spi;
616 int payload, nexthdr, version, hdrlen;
617 .
618 457c
619 uchar raddr[IPaddrlen], laddr[IPaddrlen];
620 .
621 453,454c
622 Esp4hdr *eh4;
623 Esp6hdr *eh6;
624 Esptail *et;
625 Userhdr *uh;
626 .
627 451c
628 espiput(Proto *esp, Ipifc* _, Block *bp)
629 .
630 446,449d
631 440c
632 if (version == V4)
633 .
634 438c
635 QUNLOCK(c);
636 .
637 434,435c
638 ecb->auth(ecb, bp->rp + iphdrlen, (hdrlen - iphdrlen) +
639 .
640 429,431d
641 425a
642 hnputl(eh6->espspi, ecb->spi);
643 hnputl(eh6->espseq, ++ecb->seq);
644 .
645 424d
646 420,422d
647 414a
648 hnputl(eh4->espspi, ecb->spi);
649 hnputl(eh4->espseq, ++ecb->seq);
650 .
651 411,413c
652 /* fill in head */
653 if (version == V4) {
654 .
655 407,409c
656 ecb->cipher(ecb, bp->rp + hdrlen, payload + pad + Esptaillen);
657 auth = bp->rp + hdrlen + payload + pad + Esptaillen;
658 .
659 401c
660 eh4 = (Esp4hdr *)bp->rp;
661 eh6 = (Esp6hdr *)bp->rp;
662 et = (Esptail*)(bp->rp + hdrlen + payload + pad);
663 .
664 383,384c
665 bp = padblock(bp, hdrlen + ecb->espivlen);
666 .
667 370c
668 QUNLOCK(c);
669 .
670 363c
671 QLOCK(c);
672 .
673 358c
674 version = ipvers(c);
675 iphdrlen = version == V4? IP4HDR: IP6HDR;
676 hdrlen = version == V4? Esp4hdrlen: Esp6hdrlen;
677
678 .
679 356c
680 Espcb *ecb;
681 Block *bp;
682 int nexthdr, payload, pad, align, version, hdrlen, iphdrlen;
683 uchar *auth;
684 .
685 353d
686 347,349d
687 299,344d
688 284,297d
689 274c
690 ipvers(Conv *c)
691 .
692 221c
693 QUNLOCK(c->p);
694 .
695 215c
696 QLOCK(c->p);
697 .
698 207,210c
699 parseip(c->raddr, argv[1]);
700 .
701 192c
702 char *p, *pp;
703 char *e = nil;
704 .
705 182,186c
706 "null", 0, nullahinit,
707 "hmac_sha1_96", 128, shaahinit, /* rfc2404 */
708 // "aes_xcbc_mac_96", 128, aesahinit, /* rfc3566 */
709 "hmac_md5_96", 128, md5ahinit, /* rfc2403 */
710 nil, 0, nil,
711 .
712 170,177c
713 "null", 0, nullespinit,
714 // "des3_cbc", 192, des3espinit, /* rfc2451 */
715 // "aes_128_cbc", 128, aescbcespinit, /* rfc3602 */
716 // "aes_ctr", 128, aesctrespinit, /* rfc3686 */
717 "des_56_cbc", 64, desespinit, /* rfc2405, deprecated */
718 // "rc4_128", 128, rc4espinit, /* gone in rfc4305 */
719 nil, 0, nil,
720 .
721 163,166c
722 static void nullahinit(Espcb*, char*, uchar *key, int keylen);
723 static void shaahinit(Espcb*, char*, uchar *key, int keylen);
724 static void md5ahinit(Espcb*, char*, uchar *key, int keylen);
725 .
726 157,161c
727 static void nullespinit(Espcb*, char*, uchar *key, int keylen);
728 static void desespinit(Espcb *ecb, char *name, uchar *k, int n);
729 .
730 150c
731 void (*init)(Espcb*, char* name, uchar *key, int keylen);
732 .
733 143d
734 137d
735 131d
736 127c
737 int header; /* user user level header */
738 .
739 96,107d
740 86,87c
741 /* Ip6hdr; */
742 uchar vcf[4]; /* version:4, traffic class:8, flow label:20 */
743 uchar ploadlen[2]; /* payload length: packet length - 40 */
744 uchar proto; /* next header type */
745 uchar ttl; /* hop limit */
746 uchar src[IPaddrlen];
747 uchar dst[IPaddrlen];
748
749 /* Esphdr; */
750 uchar espspi[4]; /* Security parameter index */
751 uchar espseq[4]; /* Sequence number */
752 .
753 80c
754 /* Esphdr; */
755 uchar espspi[4]; /* Security parameter index */
756 uchar espseq[4]; /* Sequence number */
757 .
758 58,64c
759 * tunnel-mode layout: IP | ESP | TCP/UDP | user data.
760 * transport-mode layout is: ESP | IP | TCP/UDP | user data.
761 .
762 54d
763 42,47d
764 32,35c
765 enum
766 {
767 .
768 30a
769 typedef struct Esppriv Esppriv;
770 typedef struct Espcb Espcb;
771 typedef struct Algorithm Algorithm;
772 .
773 26,28d
774 20,23c
775 typedef struct Esphdr Esphdr;
776 .
777 14c
778 #include "error.h"
779 .
780 10c
781 #include "lib.h"
782 .
783 6,7c
784 * TODO: update to match rfc4303.
785 .
786 3,4d
787 diff -e ip.orig/ethermedium.c ip/ethermedium.c
788 536c
789 if((sflag = ipv6anylocal(ifc, ipsrc)) != 0)
790 .
791 429c
792 etherremmulti(Ipifc *ifc, uchar *a, uchar *_)
793 .
794 407c
795 etheraddmulti(Ipifc *ifc, uchar *a, uchar *_)
796 .
797 401c
798 RUNLOCK(ifc);
799 .
800 392c
801 RUNLOCK(ifc);
802 .
803 387c
804 if(!CANRLOCK(ifc)){
805 .
806 362c
807 RUNLOCK(ifc);
808 .
809 353c
810 RUNLOCK(ifc);
811 .
812 348c
813 if(!CANRLOCK(ifc)){
814 .
815 269c
816 * called by ipoput with a single block to write with ifc RLOCK'd
817 .
818 123a
819
820 .
821 8c
822 #include "netif.h"
823 .
824 6c
825 #include "error.h"
826 .
827 2c
828 #include "lib.h"
829 .
830 diff -e ip.orig/gre.c ip/gre.c
831 968c
832 gre->ptclsize = 0;
833 .
834 919,948d
835 894,916c
836 return "unknown control request";
837 .
838 885,892d
839 881,883c
840 else if(strcmp(f[0], "cooked") == 0){
841 gpriv->raw = 0;
842 return nil;
843 .
844 696,879c
845 gpriv = c->p->priv;
846 if(n == 1){
847 if(strcmp(f[0], "raw") == 0){
848 gpriv->raw = 1;
849 return nil;
850 .
851 694c
852 GREpriv *gpriv;
853 .
854 691,692c
855 char*
856 grectl(Conv *c, char **f, int n)
857 .
858 681,688c
859 return snprint(buf, len, "gre: len %lud\n", gpriv->lenerr);
860 .
861 675,679d
862 659,660c
863 if(qlen(c->rq) > 64*1024)
864 freeblist(bp);
865 .
866 651d
867 648d
868 645c
869 freeblist(bp);
870 .
871 643c
872 len = nhgets(ghp->len) - GRE_IPONLY;
873 .
874 639a
875 QUNLOCK(gre);
876
877 .
878 633,636c
879 if(*p == nil) {
880 QUNLOCK(gre);
881 freeblist(bp);
882 .
883 590,629c
884 if(c->rport == eproto &&
885 (gpriv->raw || ipcmp(c->raddr, raddr) == 0))
886 .
887 587d
888 553,585c
889 /* Look for a conversation structure for this port and address */
890 c = nil;
891 for(p = gre->conv; *p; p++) {
892 .
893 547,551c
894 v4tov6(raddr, ghp->src);
895 eproto = nhgets(ghp->eproto);
896 QLOCK(gre);
897 .
898 536,545c
899 gpriv = gre->priv;
900 ghp = (GREhdr*)(bp->rp);
901 .
902 534d
903 531,532c
904 ushort eproto;
905 uchar raddr[IPaddrlen];
906 .
907 336,529c
908 int len;
909 GREhdr *ghp;
910 .
911 334c
912 greiput(Proto *gre, Ipifc* __, Block *bp)
913 .
914 328,329d
915 325,326c
916 ghp->proto = IP_GREPROTO;
917 ghp->frag[0] = 0;
918 ghp->frag[1] = 0;
919 .
920 322c
921 hnputs(ghp->eproto, c->rport);
922 .
923 318,320c
924 findlocalip(c->p->f, c->laddr, raddr); /* pick interface closest to dest */
925 memmove(ghp->src, c->laddr + IPv4off, IPv4addrlen);
926 .
927 314,315c
928 memmove(ghp->dst, c->raddr + IPv4off, IPv4addrlen);
929 v4tov6(laddr, ghp->src);
930 .
931 311,312c
932 if(!((GREpriv*)c->p->priv)->raw){
933 v4tov6(raddr, ghp->dst);
934 .
935 308,309c
936 ghp = (GREhdr *)(bp->rp);
937 ghp->vihl = IP_VER4;
938 .
939 295,297d
940 287,289c
941 Conv *c = x;
942 GREhdr *ghp;
943 .
944 283a
945 int drop;
946
947 .
948 281c
949 c->lport = 0;
950 c->rport = 0;
951 .
952 247,278c
953 qclose(c->rq);
954 qclose(c->wq);
955 qclose(c->eq);
956 .
957 241c
958 return "pktifc does not support announce";
959 .
960 239c
961 greannounce(Conv* _, char** __, int ___)
962 .
963 218,235c
964 USED(c);
965 return snprint(state, n, "%s\n", "Datagram");
966 .
967 211c
968 c->rq = qopen(64*1024, Qmsg, 0, c);
969 .
970 199c
971 QUNLOCK(p);
972 .
973 184c
974 QLOCK(p);
975 .
976 138,171c
977 static char*
978 .
979 136d
980 71,134d
981 68c
982 ulong csumerr; /* checksum errors */
983 ulong lenerr; /* short packet */
984 .
985 66c
986 struct GREpriv
987 {
988 int raw; /* Raw GRE mode */
989
990 .
991 63c
992 } GREhdr;
993 .
994 54c
995 uchar Unused;
996 .
997 46,47c
998 typedef struct GREhdr
999 {
1000 .
1001 21,43d
1002 13c
1003 enum
1004 {
1005 .
1006 9c
1007 #include "error.h"
1008 .
1009 5c
1010 #include "lib.h"
1011 .
1012 diff -e ip.orig/icmp.c ip/icmp.c
1013 350c
1014 if(iplen > n || ((uint)iplen % 1)){
1015 .
1016 339,341c
1017 netlog(icmp->f, Logicmp, "icmpiput %d %d\n", p->type, p->code);
1018 .
1019 324c
1020 icmpiput(Proto *icmp, Ipifc* __, Block *bp)
1021 .
1022 6c
1023 #include "error.h"
1024 .
1025 2c
1026 #include "lib.h"
1027 .
1028 diff -e ip.orig/icmp6.c ip/icmp6.c
1029 781c
1030 bp->rp -= sizeof(IPICMP);
1031 .
1032 770c
1033 bp->rp += sizeof(IPICMP);
1034 .
1035 762c
1036 bp->rp -= sizeof(IPICMP);
1037 .
1038 750c
1039 bp->rp += sizeof(IPICMP);
1040 .
1041 711c
1042 RUNLOCK(ifc);
1043 .
1044 707c
1045 RUNLOCK(ifc);
1046 .
1047 700c
1048 RUNLOCK(ifc);
1049 .
1050 698c
1051 RLOCK(ifc);
1052 .
1053 666c
1054 sz = sizeof(IPICMP) + 8;
1055 .
1056 661c
1057 if(pktsz - sizeof(Ip6hdr) < 8) {
1058 .
1059 649c
1060 sz = sizeof(IPICMP) + 8;
1061 .
1062 641c
1063 if(pktsz - sizeof(Ip6hdr) < 16) {
1064 .
1065 575c
1066 if(iplen > n - IP6HDR || ((uint)iplen % 1) != 0) {
1067 .
1068 568c
1069 if(n < sizeof(IPICMP)) {
1070 .
1071 546c
1072 memmove(nbp->rp + sizeof(IPICMP), bp->rp, sz - sizeof(IPICMP));
1073 .
1074 537c
1075 netlog(f, Logicmp, "icmppkttoobig6 fail -> s%I d%I\n",
1076 .
1077 534c
1078 netlog(f, Logicmp, "send icmppkttoobig6 -> s%I d%I\n",
1079 .
1080 518c
1081 int sz = MIN(sizeof(IPICMP) + osz, v6MINTU);
1082 .
1083 506c
1084 memmove(nbp->rp + sizeof(IPICMP), bp->rp, sz - sizeof(IPICMP));
1085 .
1086 498c
1087 netlog(f, Logicmp, "icmpttlexceeded6 fail -> s%I d%I\n",
1088 .
1089 495c
1090 netlog(f, Logicmp, "send icmpttlexceeded6 -> s%I d%I\n",
1091 .
1092 479c
1093 int sz = MIN(sizeof(IPICMP) + osz, v6MINTU);
1094 .
1095 471c
1096 RUNLOCK(ifc);
1097 .
1098 457c
1099 memmove(nbp->rp + sizeof(IPICMP), bp->rp, sz - sizeof(IPICMP));
1100 .
1101 445c
1102 netlog(f, Logicmp, "icmphostunr fail -> s%I d%I\n",
1103 .
1104 442c
1105 netlog(f, Logicmp, "send icmphostunr -> s%I d%I\n",
1106 .
1107 440c
1108 RLOCK(ifc);
1109 .
1110 425c
1111 int sz = MIN(sizeof(IPICMP) + osz, v6MINTU);
1112 .
1113 397c
1114 nbp = newIPICMP(sizeof(Ndpkt));
1115 .
1116 375c
1117 nbp->wp -= sizeof(Ndpkt) - sizeof(NdiscC);
1118 .
1119 354c
1120 nbp = newIPICMP(sizeof(Ndpkt));
1121 .
1122 260c
1123 if(blocklen(bp) < sizeof(IPICMP)){
1124 .
1125 257c
1126 bp = padblock(bp, sizeof(Ip6hdr));
1127 .
1128 122c
1129 QLock qlock;
1130 .
1131 109,110d
1132 106d
1133 101a
1134
1135 .
1136 99,100c
1137 /* ICMPpkt; */
1138 uchar type;
1139 uchar code;
1140 uchar cksum[2];
1141 uchar icmpid[2];
1142 uchar seq[2];
1143
1144 .
1145 97c
1146 struct Ndpkt
1147 {
1148 /* NdiscC; */
1149 /* IPICMP; */
1150 /* Ip6hdr; */
1151 uchar vcf[4]; /* version:4, traffic class:8, flow label:20 */
1152 uchar ploadlen[2]; /* payload length: packet length - 40 */
1153 uchar proto; /* next header type */
1154 uchar ttl; /* hop limit */
1155 uchar src[IPaddrlen];
1156 uchar dst[IPaddrlen];
1157 .
1158 94d
1159 91,92c
1160 /* ICMPpkt; */
1161 uchar type;
1162 uchar code;
1163 uchar cksum[2];
1164 uchar icmpid[2];
1165 uchar seq[2];
1166
1167 .
1168 89c
1169 struct NdiscC
1170 {
1171 /* IPICMP; */
1172 /* Ip6hdr; */
1173 uchar vcf[4]; /* version:4, traffic class:8, flow label:20 */
1174 uchar ploadlen[2]; /* payload length: packet length - 40 */
1175 uchar proto; /* next header type */
1176 uchar ttl; /* hop limit */
1177 uchar src[IPaddrlen];
1178 uchar dst[IPaddrlen];
1179 .
1180 85,86c
1181 /* Ip6hdr; */
1182 uchar vcf[4]; /* version:4, traffic class:8, flow label:20 */
1183 uchar ploadlen[2]; /* payload length: packet length - 40 */
1184 uchar proto; /* next header type */
1185 uchar ttl; /* hop limit */
1186 uchar src[IPaddrlen];
1187 uchar dst[IPaddrlen];
1188
1189 /* ICMPpkt; */
1190 uchar type;
1191 uchar code;
1192 uchar cksum[2];
1193 uchar icmpid[2];
1194 uchar seq[2];
1195 .
1196 75,82c
1197 struct ICMPpkt {
1198 uchar type;
1199 uchar code;
1200 uchar cksum[2];
1201 uchar icmpid[2];
1202 uchar seq[2];
1203 };
1204 .
1205 70c
1206 typedef struct ICMPpkt ICMPpkt;
1207 .
1208 9c
1209 #include "error.h"
1210 .
1211 5c
1212 #include "lib.h"
1213 .
1214 diff -e ip.orig/igmp.c ip/igmp.c
1215 217c
1216 mp = Mediacopymulti(m);
1217 .
1218 177c
1219 igmpiput(Media *m, Ipifc *, Block *bp)
1220 .
1221 123c
1222 byte ip[IPaddrlen];
1223 .
1224 97,99c
1225 bp->wp += sizeof(IGMPpkt);
1226 memset(bp->rp, 0, sizeof(IGMPpkt));
1227 hnputl(p->src, Mediagetaddr(m));
1228 .
1229 87c
1230 igmpsendreport(Media *m, byte *addr)
1231 .
1232 68c
1233 Lock lk;
1234
1235 .
1236 60c
1237 Media *m;
1238 .
1239 51,52d
1240 43,48c
1241 byte vertype; /* version and type */
1242 byte unused;
1243 byte igmpcksum[2]; /* checksum of igmp portion */
1244 byte group[IPaddrlen]; /* multicast group */
1245 .
1246 31,40c
1247 byte vihl; /* Version and header length */
1248 byte tos; /* Type of service */
1249 byte len[2]; /* packet length (including headers) */
1250 byte id[2]; /* Identification */
1251 byte frag[2]; /* Fragment information */
1252 byte Unused;
1253 byte proto; /* Protocol */
1254 byte cksum[2]; /* checksum of ip portion */
1255 byte src[IPaddrlen]; /* Ip source */
1256 byte dst[IPaddrlen]; /* Ip destination */
1257 .
1258 27a
1259 typedef char byte;
1260
1261 .
1262 10c
1263 #include "error.h"
1264 .
1265 6c
1266 #include "lib.h"
1267 .
1268 1,4d
1269 diff -e ip.orig/inferno.c ip/inferno.c
1270 28a
1271
1272 Medium tripmedium =
1273 {
1274 "trip",
1275 };
1276 .
1277 25c
1278 bootpread(char* _, ulong __, int ___)
1279 .
1280 23a
1281 char*
1282 bootp(Ipifc* _)
1283 {
1284 return "unimplmented";
1285 }
1286
1287 .
1288 17a
1289 Chan*
1290 commonfdtochan(int fd, int mode, int a, int b)
1291 {
1292 return fdtochan(fd, mode, a, b);
1293 }
1294
1295 .
1296 6c
1297 #include "error.h"
1298 #include "ip.h"
1299 .
1300 2c
1301 #include "lib.h"
1302 .
1303 diff -e ip.orig/ip.c ip/ip.c
1304 522,524c
1305 if(bp->base+sizeof(Ipfrag) >= bp->rp){
1306 bp = padblock(bp, sizeof(Ipfrag));
1307 bp->rp += sizeof(Ipfrag);
1308 .
1309 466,467c
1310 for(i = 0; i < Nstats; i++)
1311 p = seprint(p, e, "%s: %lud\n", statnames[i], ip->stats[i]);
1312 .
1313 383c
1314 freeb(bp);
1315 .
1316 381a
1317 Conv conv;
1318
1319 .
1320 322d
1321 320d
1322 301c
1323 RUNLOCK(ifc);
1324 .
1325 213c
1326 RUNLOCK(ifc);
1327 .
1328 211d
1329 196,199c
1330 medialen = ifc->maxtu - ifc->m->hsize;
1331 .
1332 189c
1333 RUNLOCK(ifc);
1334 .
1335 186c
1336 if(!CANRLOCK(ifc))
1337 .
1338 11a
1339 /* MIB II counters */
1340 enum
1341 {
1342 Forwarding,
1343 DefaultTTL,
1344 InReceives,
1345 InHdrErrors,
1346 InAddrErrors,
1347 ForwDatagrams,
1348 InUnknownProtos,
1349 InDiscards,
1350 InDelivers,
1351 OutRequests,
1352 OutDiscards,
1353 OutNoRoutes,
1354 ReasmTimeout,
1355 ReasmReqds,
1356 ReasmOKs,
1357 ReasmFails,
1358 FragOKs,
1359 FragFails,
1360 FragCreates,
1361
1362 Nstats,
1363 };
1364
1365 struct Fragment4
1366 {
1367 Block* blist;
1368 Fragment4* next;
1369 ulong src;
1370 ulong dst;
1371 ushort id;
1372 ulong age;
1373 };
1374
1375 struct Fragment6
1376 {
1377 Block* blist;
1378 Fragment6* next;
1379 uchar src[IPaddrlen];
1380 uchar dst[IPaddrlen];
1381 uint id;
1382 ulong age;
1383 };
1384
1385 struct Ipfrag
1386 {
1387 ushort foff;
1388 ushort flen;
1389 };
1390
1391 /* an instance of IP */
1392 struct IP
1393 {
1394 ulong stats[Nstats];
1395
1396 QLock fraglock4;
1397 Fragment4* flisthead4;
1398 Fragment4* fragfree4;
1399 Ref id4;
1400
1401 QLock fraglock6;
1402 Fragment6* flisthead6;
1403 Fragment6* fragfree6;
1404 Ref id6;
1405
1406 int iprouting; /* true if we route like a gateway */
1407 };
1408
1409 .
1410 9a
1411 typedef struct Fragment4 Fragment4;
1412 typedef struct Fragment6 Fragment6;
1413 typedef struct Ipfrag Ipfrag;
1414
1415 .
1416 6c
1417 #include "error.h"
1418 .
1419 2c
1420 #include "lib.h"
1421 .
1422 diff -e ip.orig/ip.h ip/ip.h
1423 732a
1424 Chan* commonfdtochan(int, int, int, int);
1425 .
1426 727a
1427 extern char* bootp(Ipifc*);
1428 .
1429 676a
1430 extern Medium tripmedium;
1431 .
1432 669c
1433 #define NOW msec()
1434 .
1435 578c
1436 /* RouteTree; */
1437 Route* right;
1438 Route* left;
1439 Route* mid;
1440 uchar depth;
1441 uchar type;
1442 uchar ifcid; /* must match ifc->id */
1443 Ipifc *ifc;
1444 char tag[4];
1445 int ref;
1446 .
1447 516,517d
1448 491a
1449 Logilmsg= 1<<8,
1450 .
1451 488a
1452 Logil= 1<<4,
1453 .
1454 423c
1455 RWlock rwlock;
1456
1457 Conv *conv; /* link to its conversation structure */
1458 .
1459 386c
1460 QLock qlock;
1461
1462 .
1463 374c
1464 Lock lk;
1465
1466 .
1467 312c
1468 RWlock rwlock;
1469 .
1470 173c
1471 QLock qlock;
1472 .
1473 153a
1474 typedef struct Ip4hdr Ip4hdr;
1475 .
1476 79,152d
1477 41c
1478 Maxincall= 5,
1479 .
1480 30,35d
1481 8,9d
1482 2,3d
1483 diff -e ip.orig/ipaux.c ip/ipaux.c
1484 366c
1485 UNLOCK(ht);
1486 .
1487 363c
1488 UNLOCK(ht);
1489 .
1490 352c
1491 UNLOCK(ht);
1492 .
1493 340c
1494 UNLOCK(ht);
1495 .
1496 328c
1497 UNLOCK(ht);
1498 .
1499 316c
1500 UNLOCK(ht);
1501 .
1502 309c
1503 LOCK(ht);
1504 .
1505 290c
1506 UNLOCK(ht);
1507 .
1508 282c
1509 LOCK(ht);
1510 .
1511 272c
1512 UNLOCK(ht);
1513 .
1514 269c
1515 LOCK(ht);
1516 .
1517 241c
1518 return (ulong)(sa[IPaddrlen-1]<<24 ^ sp<< 16 ^ da[IPaddrlen-1]<<8 ^ dp) % Nhash;
1519 .
1520 6c
1521 #include "error.h"
1522 .
1523 2c
1524 #include "lib.h"
1525 .
1526 diff -e ip.orig/ipifc.c ip/ipifc.c
1527 1575c
1528 RUNLOCK(nifc);
1529 .
1530 1565c
1531 RUNLOCK(nifc);
1532 .
1533 1562c
1534 RLOCK(nifc);
1535 .
1536 1555c
1537 RUNLOCK(nifc);
1538 .
1539 1541c
1540 RUNLOCK(nifc);
1541 .
1542 1538c
1543 RLOCK(nifc);
1544 .
1545 1518d
1546 1511d
1547 1498c
1548 WUNLOCK(ifc);
1549 .
1550 1494c
1551 WLOCK(ifc);
1552 .
1553 1491c
1554 WUNLOCK(ifc);
1555 .
1556 1455c
1557 WUNLOCK(ifc);
1558 .
1559 1451c
1560 WLOCK(ifc);
1561 .
1562 1448c
1563 WUNLOCK(ifc);
1564 .
1565 1301c
1566 QUNLOCK(f->ipifc);
1567 .
1568 1265,1266c
1569 if((atypel > atype && atype < atyper) ||
1570 (atypel < atype && atype > atyper)){
1571 .
1572 1232,1234c
1573 QLOCK(f->ipifc);
1574 .
1575 1154c
1576 (isv6mcast(addr) && (addr[1] & 0xF) <= Link_local_scop))
1577 .
1578 1054c
1579 QUNLOCK(f->self);
1580 .
1581 1040c
1582 QLOCK(f->self);
1583 .
1584 1021c
1585 QUNLOCK(f->self);
1586 .
1587 951c
1588 QLOCK(f->self);
1589 .
1590 888c
1591 QUNLOCK(f->self);
1592 .
1593 839c
1594 QLOCK(f->self);
1595 .
1596 689c
1597 WUNLOCK(ifc);
1598 .
1599 683c
1600 WLOCK(ifc);
1601 .
1602 680c
1603 WUNLOCK(ifc);
1604 .
1605 619c
1606 WUNLOCK(ifc);
1607 .
1608 604c
1609 WLOCK(ifc);
1610 .
1611 539c
1612 * always called with ifc WLOCK'd
1613 .
1614 531c
1615 WUNLOCK(ifc);
1616 .
1617 417c
1618 WLOCK(ifc);
1619 .
1620 319c
1621 c->sq = qopen(2*QMAX, 0, 0, 0);
1622 .
1623 306c
1624 RUNLOCK(ifc);
1625 .
1626 299c
1627 RUNLOCK(ifc);
1628 .
1629 294c
1630 if(!CANRLOCK(ifc)){
1631 .
1632 266c
1633 RUNLOCK(ifc);
1634 .
1635 259c
1636 RLOCK(ifc);
1637 .
1638 244c
1639 RUNLOCK(ifc);
1640 .
1641 238c
1642 RLOCK(ifc);
1643 .
1644 212c
1645 WUNLOCK(ifc);
1646 .
1647 181c
1648 WLOCK(ifc);
1649 .
1650 178c
1651 WUNLOCK(ifc);
1652 .
1653 162c
1654 WUNLOCK(ifc);
1655 .
1656 124c
1657 WUNLOCK(ifc);
1658 .
1659 120c
1660 WUNLOCK(ifc);
1661 .
1662 118c
1663 WLOCK(ifc);
1664 .
1665 58c
1666 #define hashipa(a) ( (ulong)(((a)[IPaddrlen-2]<<8) | (a)[IPaddrlen-1])%NHASH )
1667 .
1668 39c
1669 QLock qlock;
1670 .
1671 18c
1672 QMAX = 64*1024-1,
1673 .
1674 6c
1675 #include "error.h"
1676 .
1677 2c
1678 #include "lib.h"
1679 .
1680 diff -e ip.orig/ipmux.c ip/ipmux.c
1681 811c
1682 RUNLOCK(f);
1683 .
1684 809c
1685 RLOCK(f);
1686 .
1687 742c
1688 RUNLOCK(f);
1689 .
1690 680c
1691 RLOCK(f);
1692 .
1693 631,633c
1694 WLOCK(f);
1695 i = (Ipmux *)c->p->priv;
1696 ipmuxremove(&i, r->chain);
1697 WUNLOCK(f);
1698 .
1699 617a
1700 Ipmux *i;
1701 .
1702 610c
1703 ipmuxannounce(Conv* _, char** __, int ___)
1704 .
1705 583c
1706 WUNLOCK(f);
1707 .
1708 581c
1709 WLOCK(f);
1710 .
1711 9c
1712 #include "error.h"
1713 .
1714 5c
1715 #include "lib.h"
1716 .
1717 diff -e ip.orig/iproute.c ip/iproute.c
1718 469c
1719 while((p = f->queue) != nil) {
1720 .
1721 425c
1722 while((p = f->queue) != nil) {
1723 .
1724 359c
1725 while((p = f->queue) != nil) {
1726 .
1727 313c
1728 while((p = f->queue) != nil) {
1729 .
1730 213,214c
1731 dl = 0; if((l = p->left) != nil) dl = l->depth;
1732 dr = 0; if((r = p->right) != nil) dr = r->depth;
1733 .
1734 6c
1735 #include "error.h"
1736 .
1737 2c
1738 #include "lib.h"
1739 .
1740 diff -e ip.orig/ipv6.c ip/ipv6.c
1741 506,508c
1742 if(bp->base+sizeof(Ipfrag) >= bp->rp){
1743 bp = padblock(bp, sizeof(Ipfrag));
1744 bp->rp += sizeof(Ipfrag);
1745 .
1746 218c
1747 RUNLOCK(ifc);
1748 .
1749 122c
1750 RUNLOCK(ifc);
1751 .
1752 110c
1753 RUNLOCK(ifc);
1754 .
1755 106c
1756 if(!CANRLOCK(ifc))
1757 .
1758 29a
1759 /* MIB II counters */
1760 enum
1761 {
1762 Forwarding,
1763 DefaultTTL,
1764 InReceives,
1765 InHdrErrors,
1766 InAddrErrors,
1767 ForwDatagrams,
1768 InUnknownProtos,
1769 InDiscards,
1770 InDelivers,
1771 OutRequests,
1772 OutDiscards,
1773 OutNoRoutes,
1774 ReasmTimeout,
1775 ReasmReqds,
1776 ReasmOKs,
1777 ReasmFails,
1778 FragOKs,
1779 FragFails,
1780 FragCreates,
1781
1782 Nstats,
1783 };
1784
1785 static char *statnames[] =
1786 {
1787 [Forwarding] "Forwarding",
1788 [DefaultTTL] "DefaultTTL",
1789 [InReceives] "InReceives",
1790 [InHdrErrors] "InHdrErrors",
1791 [InAddrErrors] "InAddrErrors",
1792 [ForwDatagrams] "ForwDatagrams",
1793 [InUnknownProtos] "InUnknownProtos",
1794 [InDiscards] "InDiscards",
1795 [InDelivers] "InDelivers",
1796 [OutRequests] "OutRequests",
1797 [OutDiscards] "OutDiscards",
1798 [OutNoRoutes] "OutNoRoutes",
1799 [ReasmTimeout] "ReasmTimeout",
1800 [ReasmReqds] "ReasmReqds",
1801 [ReasmOKs] "ReasmOKs",
1802 [ReasmFails] "ReasmFails",
1803 [FragOKs] "FragOKs",
1804 [FragFails] "FragFails",
1805 [FragCreates] "FragCreates",
1806 };
1807
1808 struct Fragment4
1809 {
1810 Block* blist;
1811 Fragment4* next;
1812 ulong src;
1813 ulong dst;
1814 ushort id;
1815 ulong age;
1816 };
1817
1818 struct Fragment6
1819 {
1820 Block* blist;
1821 Fragment6* next;
1822 uchar src[IPaddrlen];
1823 uchar dst[IPaddrlen];
1824 uint id;
1825 ulong age;
1826 };
1827
1828 struct Ipfrag
1829 {
1830 ushort foff;
1831 ushort flen;
1832 };
1833
1834 /* an instance of IP */
1835 struct IP
1836 {
1837 ulong stats[Nstats];
1838
1839 QLock fraglock4;
1840 Fragment4* flisthead4;
1841 Fragment4* fragfree4;
1842 Ref id4;
1843
1844 QLock fraglock6;
1845 Fragment6* flisthead6;
1846 Fragment6* fragfree6;
1847 Ref id6;
1848
1849 int iprouting; /* true if we route like a gateway */
1850 };
1851
1852 .
1853 22a
1854 typedef struct Fragment4 Fragment4;
1855 typedef struct Fragment6 Fragment6;
1856 typedef struct Ipfrag Ipfrag;
1857
1858 .
1859 6c
1860 #include "error.h"
1861 .
1862 2c
1863 #include "lib.h"
1864 .
1865 diff -e ip.orig/ipv6.h ip/ipv6.h
1866 145c
1867 struct Routinghdr {
1868 .
1869 134c
1870 struct Opthdr {
1871 .
1872 130,131c
1873 uchar vcf[4]; /* version:4, traffic class:8, flow label:20 */
1874 uchar ploadlen[2]; /* payload length: packet length - 40 */
1875 uchar proto; /* next header type */
1876 uchar ttl; /* hop limit */
1877 uchar src[IPaddrlen];
1878 uchar dst[IPaddrlen];
1879 .
1880 120,128d
1881 81c
1882 IP6HDR = 20, /* sizeof(Ip6hdr) */
1883 .
1884 26a
1885 #undef ESP
1886
1887 .
1888 diff -e ip.orig/loopbackmedium.c ip/loopbackmedium.c
1889 99c
1890 RUNLOCK(ifc);
1891 .
1892 92c
1893 RUNLOCK(ifc);
1894 .
1895 87c
1896 if(!CANRLOCK(ifc)){
1897 .
1898 58c
1899 loopbackbwrite(Ipifc *ifc, Block *bp, int _, uchar* __)
1900 .
1901 26c
1902 loopbackbind(Ipifc *ifc, int _, char** __)
1903 .
1904 6c
1905 #include "error.h"
1906 .
1907 2c
1908 #include "lib.h"
1909 .
1910 diff -e ip.orig/netdevmedium.c ip/netdevmedium.c
1911 144c
1912 RUNLOCK(ifc);
1913 .
1914 136c
1915 RUNLOCK(ifc);
1916 .
1917 131c
1918 if(!CANRLOCK(ifc)){
1919 .
1920 85c
1921 netdevbwrite(Ipifc *ifc, Block *bp, int _, uchar* __)
1922 .
1923 6c
1924 #include "error.h"
1925 .
1926 2c
1927 #include "lib.h"
1928 .
1929 diff -e ip.orig/netlog.c ip/netlog.c
1930 260c
1931 wakeup(&f->alog->rendez);
1932 .
1933 258c
1934 UNLOCK(f->alog);
1935 .
1936 242c
1937 LOCK(f->alog);
1938 .
1939 228c
1940 char buf[128], *t, *fp;
1941 .
1942 185c
1943 set = 1;
1944 .
1945 160c
1946 QUNLOCK(f->alog);
1947 .
1948 157c
1949 sleep(&f->alog->rendez, netlogready, f);
1950 .
1951 155c
1952 UNLOCK(f->alog);
1953 .
1954 146c
1955 UNLOCK(f->alog);
1956 .
1957 134c
1958 LOCK(f->alog);
1959 .
1960 129c
1961 QUNLOCK(f->alog);
1962 .
1963 127c
1964 QLOCK(f->alog);
1965 .
1966 122c
1967 netlogread(Fs *f, void *a, ulong _, long n)
1968 .
1969 109c
1970 UNLOCK(f->alog);
1971 .
1972 101c
1973 UNLOCK(f->alog);
1974 .
1975 99c
1976 LOCK(f->alog);
1977 .
1978 92c
1979 UNLOCK(f->alog);
1980 .
1981 82c
1982 UNLOCK(f->alog);
1983 .
1984 80c
1985 LOCK(f->alog);
1986 .
1987 28,29c
1988 QLock qlock;
1989 Rendez rendez;
1990 .
1991 17c
1992 Lock lk;
1993 .
1994 6,7c
1995 #include "error.h"
1996 #include "ip/ip.h"
1997 .
1998 2c
1999 #include "lib.h"
2000 .
2001 diff -e ip.orig/nullmedium.c ip/nullmedium.c
2002 22c
2003 nullbwrite(Ipifc* _, Block* __, int ___, uchar* ____)
2004 .
2005 17c
2006 nullunbind(Ipifc* _)
2007 .
2008 11c
2009 nullbind(Ipifc* _, int __, char** ___)
2010 .
2011 6c
2012 #include "error.h"
2013 .
2014 2c
2015 #include "lib.h"
2016 .
2017 diff -e ip.orig/pktmedium.c ip/pktmedium.c
2018 51c
2019 pktbwrite(Ipifc *ifc, Block *bp, int _, uchar* __)
2020 .
2021 43c
2022 pktunbind(Ipifc* _)
2023 .
2024 36d
2025 34c
2026 pktbind(Ipifc* _, int argc, char **argv)
2027 .
2028 6c
2029 #include "error.h"
2030 .
2031 2c
2032 #include "lib.h"
2033 .
2034 diff -e ip.orig/ptclbsum.c ip/ptclbsum.c
2035 68c
2036 while((hisum = losum>>16))
2037 .
2038 6c
2039 #include "error.h"
2040 .
2041 2c
2042 #include "lib.h"
2043 .
2044 diff -e ip.orig/rudp.c ip/rudp.c
2045 693c
2046 rudp->nc = 16;
2047 .
2048 11c
2049 #include "error.h"
2050 .
2051 7c
2052 #include "lib.h"
2053 .
2054 diff -e ip.orig/tcp.c ip/tcp.c
2055 3171c
2056 QUNLOCK(c);
2057 .
2058 3154c
2059 if(!CANQLOCK(c))
2060 .
2061 3127c
2062 p = seprint(p, e, "%s: %lud\n", statnames[i], priv->stats[i]);
2063 .
2064 3101c
2065 /* called with c QLOCKed */
2066 .
2067 3085c
2068 QUNLOCK(tcp);
2069 .
2070 3080c
2071 QUNLOCK(s);
2072 .
2073 3073,3074c
2074 QLOCK(s);
2075 QUNLOCK(tcp);
2076 .
2077 3064c
2078 QLOCK(tcp);
2079 .
2080 2871,2873d
2081 2869c
2082 if(seg->mss != 0 && seg->mss < tcb->mss)
2083 .
2084 2859d
2085 2842c
2086 QUNLOCK(s);
2087 .
2088 2830c
2089 netlog(s->p->f, Logtcprxmt, "timeout rexmit 0x%lux %d/%d\n", tcb->snd.una, tcb->timer.start, NOW);
2090 .
2091 2817c
2092 QLOCK(s);
2093 .
2094 2814c
2095 QUNLOCK(s);
2096 .
2097 2768c
2098 tcpsetchecksum(Conv *s, char **f, int _)
2099 .
2100 2737c
2101 QUNLOCK(s);
2102 .
2103 2728c
2104 QLOCK(s);
2105 .
2106 2725c
2107 QUNLOCK(s);
2108 .
2109 2641c
2110 QLOCK(s);
2111 .
2112 2638,2639c
2113 if((uint)(msgs%4) == 1){
2114 QUNLOCK(s);
2115 .
2116 2563c
2117 netlog(f, Logtcp, "rexmit: %I.%d -> %I.%d ptr %lux nxt %lux\n",
2118 .
2119 2421c
2120 QUNLOCK(s);
2121 .
2122 2417c
2123 QUNLOCK(s);
2124 .
2125 2351c
2126 QUNLOCK(s);
2127 .
2128 2189c
2129 QUNLOCK(s);
2130 .
2131 2172,2174d
2132 2144c
2133 QUNLOCK(s);
2134 .
2135 2095,2096c
2136 QLOCK(s);
2137 QUNLOCK(tcp);
2138 .
2139 2092c
2140 QUNLOCK(s);
2141 .
2142 2072c
2143 QUNLOCK(tcp);
2144 .
2145 2064c
2146 QUNLOCK(tcp);
2147 .
2148 2053c
2149 QUNLOCK(tcp);
2150 .
2151 2050,2051c
2152 netlog(f, Logtcp, "iphtlook failed\n");
2153 .
2154 2045c
2155 QLOCK(tcp);
2156 .
2157 1942c
2158 tcpiput(Proto *tcp, Ipifc* _, Block *bp)
2159 .
2160 1862c
2161 netlog(s->p->f, Logtcp, "rxt next %lud, cwin %ud\n", seg->ack, tcb->cwind);
2162 .
2163 1817c
2164 netlog(s->p->f, Logtcprxmt, "dupack %lud ack %lud sndwnd %d advwin %d\n",
2165 .
2166 1685,1686d
2167 1683c
2168 if(lp->mss != 0 && lp->mss < tcb->mss)
2169 .
2170 1626c
2171 netlog(s->p->f, Logtcp, "tcpincoming s %I,%ux/%I,%ux d %I,%ux/%I,%ux v %d/%d\n",
2172 .
2173 1562c
2174 QUNLOCK(tcp);
2175 .
2176 1529c
2177 if(!CANQLOCK(tcp))
2178 .
2179 1421,1422d
2180 1334c
2181 * called with s QLOCKed
2182 .
2183 1245,1246d
2184 1231,1232d
2185 1210,1211d
2186 1208c
2187 if(optlen == MSS_LENGTH)
2188 .
2189 995d
2190 873c
2191 * called with s QLOCKed
2192 .
2193 861,862d
2194 805d
2195 609c
2196 QUNLOCK(s);
2197 .
2198 603c
2199 QLOCK(s);
2200 .
2201 600c
2202 QUNLOCK(s);
2203 .
2204 583,584d
2205 569c
2206 QUNLOCK(s);
2207 .
2208 551c
2209 QLOCK(s);
2210 .
2211 548c
2212 QUNLOCK(s);
2213 .
2214 352c
2215 ulong stats[Nstats];
2216 .
2217 317d
2218 293d
2219 231c
2220 ulong window; /* Recevive window */
2221 .
2222 229c
2223 ushort mss; /* Mean segment size */
2224 .
2225 193c
2226 * the QLOCK in the Conv locks this structure
2227 .
2228 49,50c
2229 DEF_MSS = 1460, /* Default mean segment */
2230 DEF_MSS6 = 1280, /* Default mean segment (min) for v6 */
2231 .
2232 44c
2233 MSS_LENGTH = 4, /* Mean segment size */
2234 .
2235 6c
2236 #include "error.h"
2237 .
2238 2c
2239 #include "lib.h"
2240 .
2241 diff -e ip.orig/udp.c ip/udp.c
2242 590,591c
2243 return snprint(buf, len, "InDatagrams: %lud\nNoPorts: %lud\nInErrors: %lud\nOutDatagrams: %lud\n",
2244 .
2245 580c
2246 QUNLOCK(udp);
2247 .
2248 575c
2249 QUNLOCK(s);
2250 .
2251 571,572c
2252 QLOCK(s);
2253 QUNLOCK(udp);
2254 .
2255 562c
2256 QLOCK(udp);
2257 .
2258 510c
2259 QUNLOCK(c);
2260 .
2261 502c
2262 QUNLOCK(c);
2263 .
2264 475c
2265 QUNLOCK(c);
2266 .
2267 456,457c
2268 QLOCK(c);
2269 QUNLOCK(udp);
2270 .
2271 447c
2272 QUNLOCK(udp);
2273 .
2274 410c
2275 QUNLOCK(udp);
2276 .
2277 404c
2278 QLOCK(udp);
2279 .
2280 197c
2281 netlog(c->p->f, Logudp, "udp: kick\n");
2282 .
2283 103c
2284 QLock qlock;
2285 .
2286 78c
2287 ulong udpOutDatagrams;
2288 .
2289 75c
2290 ulong udpInDatagrams;
2291 .
2292 6c
2293 #include "error.h"
2294 .
2295 2c
2296 #include "lib.h"
2297 .