diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-07-29 17:46:58 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-30 13:28:39 -0400 |
commit | 84ca5e036f41bb2d08accbd3cfd293f0bd955573 (patch) | |
tree | 2adeaaecb108728cf80bfeab75c3158cb7dbb96a /net | |
parent | 616d55be4c754dc7e1e1b7df59fb6cc5aee19ddd (diff) |
6lowpan: iphc: rename hc06_ptr pointer to hc_ptr
The hc06_ptr pointer variable stands for header compression draft-06. We
are mostly rfc complaint. This patch rename the variable to normal hc_ptr.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/6lowpan/iphc.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c index 211b5686d719..a13eae52e590 100644 --- a/net/6lowpan/iphc.c +++ b/net/6lowpan/iphc.c | |||
@@ -515,9 +515,9 @@ drop: | |||
515 | } | 515 | } |
516 | EXPORT_SYMBOL_GPL(lowpan_process_data); | 516 | EXPORT_SYMBOL_GPL(lowpan_process_data); |
517 | 517 | ||
518 | static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, | 518 | static u8 lowpan_compress_addr_64(u8 **hc_ptr, u8 shift, |
519 | const struct in6_addr *ipaddr, | 519 | const struct in6_addr *ipaddr, |
520 | const unsigned char *lladdr) | 520 | const unsigned char *lladdr) |
521 | { | 521 | { |
522 | u8 val = 0; | 522 | u8 val = 0; |
523 | 523 | ||
@@ -526,24 +526,24 @@ static u8 lowpan_compress_addr_64(u8 **hc06_ptr, u8 shift, | |||
526 | pr_debug("address compression 0 bits\n"); | 526 | pr_debug("address compression 0 bits\n"); |
527 | } else if (lowpan_is_iid_16_bit_compressable(ipaddr)) { | 527 | } else if (lowpan_is_iid_16_bit_compressable(ipaddr)) { |
528 | /* compress IID to 16 bits xxxx::XXXX */ | 528 | /* compress IID to 16 bits xxxx::XXXX */ |
529 | memcpy(*hc06_ptr, &ipaddr->s6_addr16[7], 2); | 529 | memcpy(*hc_ptr, &ipaddr->s6_addr16[7], 2); |
530 | *hc06_ptr += 2; | 530 | *hc_ptr += 2; |
531 | val = 2; /* 16-bits */ | 531 | val = 2; /* 16-bits */ |
532 | raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)", | 532 | raw_dump_inline(NULL, "Compressed ipv6 addr is (16 bits)", |
533 | *hc06_ptr - 2, 2); | 533 | *hc_ptr - 2, 2); |
534 | } else { | 534 | } else { |
535 | /* do not compress IID => xxxx::IID */ | 535 | /* do not compress IID => xxxx::IID */ |
536 | memcpy(*hc06_ptr, &ipaddr->s6_addr16[4], 8); | 536 | memcpy(*hc_ptr, &ipaddr->s6_addr16[4], 8); |
537 | *hc06_ptr += 8; | 537 | *hc_ptr += 8; |
538 | val = 1; /* 64-bits */ | 538 | val = 1; /* 64-bits */ |
539 | raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)", | 539 | raw_dump_inline(NULL, "Compressed ipv6 addr is (64 bits)", |
540 | *hc06_ptr - 8, 8); | 540 | *hc_ptr - 8, 8); |
541 | } | 541 | } |
542 | 542 | ||
543 | return rol8(val, shift); | 543 | return rol8(val, shift); |
544 | } | 544 | } |
545 | 545 | ||
546 | static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) | 546 | static void compress_udp_header(u8 **hc_ptr, struct sk_buff *skb) |
547 | { | 547 | { |
548 | struct udphdr *uh = udp_hdr(skb); | 548 | struct udphdr *uh = udp_hdr(skb); |
549 | u8 tmp; | 549 | u8 tmp; |
@@ -555,46 +555,46 @@ static void compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) | |||
555 | pr_debug("UDP header: both ports compression to 4 bits\n"); | 555 | pr_debug("UDP header: both ports compression to 4 bits\n"); |
556 | /* compression value */ | 556 | /* compression value */ |
557 | tmp = LOWPAN_NHC_UDP_CS_P_11; | 557 | tmp = LOWPAN_NHC_UDP_CS_P_11; |
558 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 558 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
559 | /* source and destination port */ | 559 | /* source and destination port */ |
560 | tmp = ntohs(uh->dest) - LOWPAN_NHC_UDP_4BIT_PORT + | 560 | tmp = ntohs(uh->dest) - LOWPAN_NHC_UDP_4BIT_PORT + |
561 | ((ntohs(uh->source) - LOWPAN_NHC_UDP_4BIT_PORT) << 4); | 561 | ((ntohs(uh->source) - LOWPAN_NHC_UDP_4BIT_PORT) << 4); |
562 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 562 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
563 | } else if ((ntohs(uh->dest) & LOWPAN_NHC_UDP_8BIT_MASK) == | 563 | } else if ((ntohs(uh->dest) & LOWPAN_NHC_UDP_8BIT_MASK) == |
564 | LOWPAN_NHC_UDP_8BIT_PORT) { | 564 | LOWPAN_NHC_UDP_8BIT_PORT) { |
565 | pr_debug("UDP header: remove 8 bits of dest\n"); | 565 | pr_debug("UDP header: remove 8 bits of dest\n"); |
566 | /* compression value */ | 566 | /* compression value */ |
567 | tmp = LOWPAN_NHC_UDP_CS_P_01; | 567 | tmp = LOWPAN_NHC_UDP_CS_P_01; |
568 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 568 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
569 | /* source port */ | 569 | /* source port */ |
570 | lowpan_push_hc_data(hc06_ptr, &uh->source, sizeof(uh->source)); | 570 | lowpan_push_hc_data(hc_ptr, &uh->source, sizeof(uh->source)); |
571 | /* destination port */ | 571 | /* destination port */ |
572 | tmp = ntohs(uh->dest) - LOWPAN_NHC_UDP_8BIT_PORT; | 572 | tmp = ntohs(uh->dest) - LOWPAN_NHC_UDP_8BIT_PORT; |
573 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 573 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
574 | } else if ((ntohs(uh->source) & LOWPAN_NHC_UDP_8BIT_MASK) == | 574 | } else if ((ntohs(uh->source) & LOWPAN_NHC_UDP_8BIT_MASK) == |
575 | LOWPAN_NHC_UDP_8BIT_PORT) { | 575 | LOWPAN_NHC_UDP_8BIT_PORT) { |
576 | pr_debug("UDP header: remove 8 bits of source\n"); | 576 | pr_debug("UDP header: remove 8 bits of source\n"); |
577 | /* compression value */ | 577 | /* compression value */ |
578 | tmp = LOWPAN_NHC_UDP_CS_P_10; | 578 | tmp = LOWPAN_NHC_UDP_CS_P_10; |
579 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 579 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
580 | /* source port */ | 580 | /* source port */ |
581 | tmp = ntohs(uh->source) - LOWPAN_NHC_UDP_8BIT_PORT; | 581 | tmp = ntohs(uh->source) - LOWPAN_NHC_UDP_8BIT_PORT; |
582 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 582 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
583 | /* destination port */ | 583 | /* destination port */ |
584 | lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest)); | 584 | lowpan_push_hc_data(hc_ptr, &uh->dest, sizeof(uh->dest)); |
585 | } else { | 585 | } else { |
586 | pr_debug("UDP header: can't compress\n"); | 586 | pr_debug("UDP header: can't compress\n"); |
587 | /* compression value */ | 587 | /* compression value */ |
588 | tmp = LOWPAN_NHC_UDP_CS_P_00; | 588 | tmp = LOWPAN_NHC_UDP_CS_P_00; |
589 | lowpan_push_hc_data(hc06_ptr, &tmp, sizeof(tmp)); | 589 | lowpan_push_hc_data(hc_ptr, &tmp, sizeof(tmp)); |
590 | /* source port */ | 590 | /* source port */ |
591 | lowpan_push_hc_data(hc06_ptr, &uh->source, sizeof(uh->source)); | 591 | lowpan_push_hc_data(hc_ptr, &uh->source, sizeof(uh->source)); |
592 | /* destination port */ | 592 | /* destination port */ |
593 | lowpan_push_hc_data(hc06_ptr, &uh->dest, sizeof(uh->dest)); | 593 | lowpan_push_hc_data(hc_ptr, &uh->dest, sizeof(uh->dest)); |
594 | } | 594 | } |
595 | 595 | ||
596 | /* checksum is always inline */ | 596 | /* checksum is always inline */ |
597 | lowpan_push_hc_data(hc06_ptr, &uh->check, sizeof(uh->check)); | 597 | lowpan_push_hc_data(hc_ptr, &uh->check, sizeof(uh->check)); |
598 | 598 | ||
599 | /* skip the UDP header */ | 599 | /* skip the UDP header */ |
600 | skb_pull(skb, sizeof(struct udphdr)); | 600 | skb_pull(skb, sizeof(struct udphdr)); |
@@ -604,7 +604,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
604 | unsigned short type, const void *_daddr, | 604 | unsigned short type, const void *_daddr, |
605 | const void *_saddr, unsigned int len) | 605 | const void *_saddr, unsigned int len) |
606 | { | 606 | { |
607 | u8 tmp, iphc0, iphc1, *hc06_ptr; | 607 | u8 tmp, iphc0, iphc1, *hc_ptr; |
608 | struct ipv6hdr *hdr; | 608 | struct ipv6hdr *hdr; |
609 | u8 head[100] = {}; | 609 | u8 head[100] = {}; |
610 | 610 | ||
@@ -612,7 +612,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
612 | return -EINVAL; | 612 | return -EINVAL; |
613 | 613 | ||
614 | hdr = ipv6_hdr(skb); | 614 | hdr = ipv6_hdr(skb); |
615 | hc06_ptr = head + 2; | 615 | hc_ptr = head + 2; |
616 | 616 | ||
617 | pr_debug("IPv6 header dump:\n\tversion = %d\n\tlength = %d\n" | 617 | pr_debug("IPv6 header dump:\n\tversion = %d\n\tlength = %d\n" |
618 | "\tnexthdr = 0x%02x\n\thop_lim = %d\n\tdest = %pI6c\n", | 618 | "\tnexthdr = 0x%02x\n\thop_lim = %d\n\tdest = %pI6c\n", |
@@ -649,7 +649,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
649 | * class depends on the presence of version and flow label | 649 | * class depends on the presence of version and flow label |
650 | */ | 650 | */ |
651 | 651 | ||
652 | /* hc06 format of TC is ECN | DSCP , original one is DSCP | ECN */ | 652 | /* hc format of TC is ECN | DSCP , original one is DSCP | ECN */ |
653 | tmp = (hdr->priority << 4) | (hdr->flow_lbl[0] >> 4); | 653 | tmp = (hdr->priority << 4) | (hdr->flow_lbl[0] >> 4); |
654 | tmp = ((tmp & 0x03) << 6) | (tmp >> 2); | 654 | tmp = ((tmp & 0x03) << 6) | (tmp >> 2); |
655 | 655 | ||
@@ -663,8 +663,8 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
663 | iphc0 |= LOWPAN_IPHC_TC_C; | 663 | iphc0 |= LOWPAN_IPHC_TC_C; |
664 | } else { | 664 | } else { |
665 | /* compress only the flow label */ | 665 | /* compress only the flow label */ |
666 | *hc06_ptr = tmp; | 666 | *hc_ptr = tmp; |
667 | hc06_ptr += 1; | 667 | hc_ptr += 1; |
668 | } | 668 | } |
669 | } else { | 669 | } else { |
670 | /* Flow label cannot be compressed */ | 670 | /* Flow label cannot be compressed */ |
@@ -672,15 +672,15 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
672 | ((hdr->flow_lbl[0] & 0xF0) == 0)) { | 672 | ((hdr->flow_lbl[0] & 0xF0) == 0)) { |
673 | /* compress only traffic class */ | 673 | /* compress only traffic class */ |
674 | iphc0 |= LOWPAN_IPHC_TC_C; | 674 | iphc0 |= LOWPAN_IPHC_TC_C; |
675 | *hc06_ptr = (tmp & 0xc0) | (hdr->flow_lbl[0] & 0x0F); | 675 | *hc_ptr = (tmp & 0xc0) | (hdr->flow_lbl[0] & 0x0F); |
676 | memcpy(hc06_ptr + 1, &hdr->flow_lbl[1], 2); | 676 | memcpy(hc_ptr + 1, &hdr->flow_lbl[1], 2); |
677 | hc06_ptr += 3; | 677 | hc_ptr += 3; |
678 | } else { | 678 | } else { |
679 | /* compress nothing */ | 679 | /* compress nothing */ |
680 | memcpy(hc06_ptr, hdr, 4); | 680 | memcpy(hc_ptr, hdr, 4); |
681 | /* replace the top byte with new ECN | DSCP format */ | 681 | /* replace the top byte with new ECN | DSCP format */ |
682 | *hc06_ptr = tmp; | 682 | *hc_ptr = tmp; |
683 | hc06_ptr += 4; | 683 | hc_ptr += 4; |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
@@ -691,8 +691,8 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
691 | iphc0 |= LOWPAN_IPHC_NH_C; | 691 | iphc0 |= LOWPAN_IPHC_NH_C; |
692 | 692 | ||
693 | if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) { | 693 | if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) { |
694 | *hc06_ptr = hdr->nexthdr; | 694 | *hc_ptr = hdr->nexthdr; |
695 | hc06_ptr += 1; | 695 | hc_ptr += 1; |
696 | } | 696 | } |
697 | 697 | ||
698 | /* | 698 | /* |
@@ -713,8 +713,8 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
713 | iphc0 |= LOWPAN_IPHC_TTL_255; | 713 | iphc0 |= LOWPAN_IPHC_TTL_255; |
714 | break; | 714 | break; |
715 | default: | 715 | default: |
716 | *hc06_ptr = hdr->hop_limit; | 716 | *hc_ptr = hdr->hop_limit; |
717 | hc06_ptr += 1; | 717 | hc_ptr += 1; |
718 | break; | 718 | break; |
719 | } | 719 | } |
720 | 720 | ||
@@ -724,14 +724,14 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
724 | iphc1 |= LOWPAN_IPHC_SAC; | 724 | iphc1 |= LOWPAN_IPHC_SAC; |
725 | /* TODO: context lookup */ | 725 | /* TODO: context lookup */ |
726 | } else if (is_addr_link_local(&hdr->saddr)) { | 726 | } else if (is_addr_link_local(&hdr->saddr)) { |
727 | iphc1 |= lowpan_compress_addr_64(&hc06_ptr, | 727 | iphc1 |= lowpan_compress_addr_64(&hc_ptr, |
728 | LOWPAN_IPHC_SAM_BIT, &hdr->saddr, _saddr); | 728 | LOWPAN_IPHC_SAM_BIT, &hdr->saddr, _saddr); |
729 | pr_debug("source address unicast link-local %pI6c " | 729 | pr_debug("source address unicast link-local %pI6c " |
730 | "iphc1 0x%02x\n", &hdr->saddr, iphc1); | 730 | "iphc1 0x%02x\n", &hdr->saddr, iphc1); |
731 | } else { | 731 | } else { |
732 | pr_debug("send the full source address\n"); | 732 | pr_debug("send the full source address\n"); |
733 | memcpy(hc06_ptr, &hdr->saddr.s6_addr16[0], 16); | 733 | memcpy(hc_ptr, &hdr->saddr.s6_addr16[0], 16); |
734 | hc06_ptr += 16; | 734 | hc_ptr += 16; |
735 | } | 735 | } |
736 | 736 | ||
737 | /* destination address compression */ | 737 | /* destination address compression */ |
@@ -742,55 +742,55 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev, | |||
742 | pr_debug("compressed to 1 octet\n"); | 742 | pr_debug("compressed to 1 octet\n"); |
743 | iphc1 |= LOWPAN_IPHC_DAM_11; | 743 | iphc1 |= LOWPAN_IPHC_DAM_11; |
744 | /* use last byte */ | 744 | /* use last byte */ |
745 | *hc06_ptr = hdr->daddr.s6_addr[15]; | 745 | *hc_ptr = hdr->daddr.s6_addr[15]; |
746 | hc06_ptr += 1; | 746 | hc_ptr += 1; |
747 | } else if (lowpan_is_mcast_addr_compressable32(&hdr->daddr)) { | 747 | } else if (lowpan_is_mcast_addr_compressable32(&hdr->daddr)) { |
748 | pr_debug("compressed to 4 octets\n"); | 748 | pr_debug("compressed to 4 octets\n"); |
749 | iphc1 |= LOWPAN_IPHC_DAM_10; | 749 | iphc1 |= LOWPAN_IPHC_DAM_10; |
750 | /* second byte + the last three */ | 750 | /* second byte + the last three */ |
751 | *hc06_ptr = hdr->daddr.s6_addr[1]; | 751 | *hc_ptr = hdr->daddr.s6_addr[1]; |
752 | memcpy(hc06_ptr + 1, &hdr->daddr.s6_addr[13], 3); | 752 | memcpy(hc_ptr + 1, &hdr->daddr.s6_addr[13], 3); |
753 | hc06_ptr += 4; | 753 | hc_ptr += 4; |
754 | } else if (lowpan_is_mcast_addr_compressable48(&hdr->daddr)) { | 754 | } else if (lowpan_is_mcast_addr_compressable48(&hdr->daddr)) { |
755 | pr_debug("compressed to 6 octets\n"); | 755 | pr_debug("compressed to 6 octets\n"); |
756 | iphc1 |= LOWPAN_IPHC_DAM_01; | 756 | iphc1 |= LOWPAN_IPHC_DAM_01; |
757 | /* second byte + the last five */ | 757 | /* second byte + the last five */ |
758 | *hc06_ptr = hdr->daddr.s6_addr[1]; | 758 | *hc_ptr = hdr->daddr.s6_addr[1]; |
759 | memcpy(hc06_ptr + 1, &hdr->daddr.s6_addr[11], 5); | 759 | memcpy(hc_ptr + 1, &hdr->daddr.s6_addr[11], 5); |
760 | hc06_ptr += 6; | 760 | hc_ptr += 6; |
761 | } else { | 761 | } else { |
762 | pr_debug("using full address\n"); | 762 | pr_debug("using full address\n"); |
763 | iphc1 |= LOWPAN_IPHC_DAM_00; | 763 | iphc1 |= LOWPAN_IPHC_DAM_00; |
764 | memcpy(hc06_ptr, &hdr->daddr.s6_addr[0], 16); | 764 | memcpy(hc_ptr, &hdr->daddr.s6_addr[0], 16); |
765 | hc06_ptr += 16; | 765 | hc_ptr += 16; |
766 | } | 766 | } |
767 | } else { | 767 | } else { |
768 | /* TODO: context lookup */ | 768 | /* TODO: context lookup */ |
769 | if (is_addr_link_local(&hdr->daddr)) { | 769 | if (is_addr_link_local(&hdr->daddr)) { |
770 | iphc1 |= lowpan_compress_addr_64(&hc06_ptr, | 770 | iphc1 |= lowpan_compress_addr_64(&hc_ptr, |
771 | LOWPAN_IPHC_DAM_BIT, &hdr->daddr, _daddr); | 771 | LOWPAN_IPHC_DAM_BIT, &hdr->daddr, _daddr); |
772 | pr_debug("dest address unicast link-local %pI6c " | 772 | pr_debug("dest address unicast link-local %pI6c " |
773 | "iphc1 0x%02x\n", &hdr->daddr, iphc1); | 773 | "iphc1 0x%02x\n", &hdr->daddr, iphc1); |
774 | } else { | 774 | } else { |
775 | pr_debug("dest address unicast %pI6c\n", &hdr->daddr); | 775 | pr_debug("dest address unicast %pI6c\n", &hdr->daddr); |
776 | memcpy(hc06_ptr, &hdr->daddr.s6_addr16[0], 16); | 776 | memcpy(hc_ptr, &hdr->daddr.s6_addr16[0], 16); |
777 | hc06_ptr += 16; | 777 | hc_ptr += 16; |
778 | } | 778 | } |
779 | } | 779 | } |
780 | 780 | ||
781 | /* UDP header compression */ | 781 | /* UDP header compression */ |
782 | if (hdr->nexthdr == UIP_PROTO_UDP) | 782 | if (hdr->nexthdr == UIP_PROTO_UDP) |
783 | compress_udp_header(&hc06_ptr, skb); | 783 | compress_udp_header(&hc_ptr, skb); |
784 | 784 | ||
785 | head[0] = iphc0; | 785 | head[0] = iphc0; |
786 | head[1] = iphc1; | 786 | head[1] = iphc1; |
787 | 787 | ||
788 | skb_pull(skb, sizeof(struct ipv6hdr)); | 788 | skb_pull(skb, sizeof(struct ipv6hdr)); |
789 | skb_reset_transport_header(skb); | 789 | skb_reset_transport_header(skb); |
790 | memcpy(skb_push(skb, hc06_ptr - head), head, hc06_ptr - head); | 790 | memcpy(skb_push(skb, hc_ptr - head), head, hc_ptr - head); |
791 | skb_reset_network_header(skb); | 791 | skb_reset_network_header(skb); |
792 | 792 | ||
793 | pr_debug("header len %d skb %u\n", (int)(hc06_ptr - head), skb->len); | 793 | pr_debug("header len %d skb %u\n", (int)(hc_ptr - head), skb->len); |
794 | 794 | ||
795 | raw_dump_table(__func__, "raw skb data dump compressed", | 795 | raw_dump_table(__func__, "raw skb data dump compressed", |
796 | skb->data, skb->len); | 796 | skb->data, skb->len); |