… | |
… | |
27 | along with this program; if not, write to the Free Software |
27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
29 | */ |
29 | */ |
30 | // The UDP profile in the decompressor |
30 | // The UDP profile in the decompressor |
31 | |
31 | |
32 | #include <asm/byteorder.h> |
|
|
33 | |
|
|
34 | #include "rohc.h" |
32 | #include "rohc.h" |
35 | #include "decomp.h" |
33 | #include "decomp.h" |
36 | |
34 | |
|
|
35 | #include "d_ip.h" |
37 | #include "d_udp.h" |
36 | #include "d_udp.h" |
38 | #include "d_util.h" |
37 | #include "d_util.h" |
39 | #include "comp.h" |
38 | #include "comp.h" |
40 | #include "c_util.h" |
39 | #include "c_util.h" |
41 | |
40 | |
… | |
… | |
316 | |
315 | |
317 | // If checksum == 0 then no checksum availible. |
316 | // If checksum == 0 then no checksum availible. |
318 | pro->udp_checksum_present = active1->udp.check; |
317 | pro->udp_checksum_present = active1->udp.check; |
319 | |
318 | |
320 | // Get and set SN |
319 | // Get and set SN |
321 | sn = ntohs(* ((__u16 *)s)); |
320 | sn = ntohs(* ((u16 *)s)); |
322 | d_lsb_init(&pro->sn, sn, -1); |
321 | d_lsb_init(&pro->sn, sn, -1); |
323 | d_ip_id_init(&pro->ip_id1, ntohs(active1->ip.id), sn); |
322 | d_ip_id_init(&pro->ip_id1, ntohs(active1->ip.id), sn); |
324 | s += 2; |
323 | s += 2; |
325 | |
324 | |
326 | // If multiple-ip-header |
325 | // If multiple-ip-header |
… | |
… | |
806 | } |
805 | } |
807 | |
806 | |
808 | size = d_decode_dynamic_udp(src2, &active1->udp); |
807 | size = d_decode_dynamic_udp(src2, &active1->udp); |
809 | src2 += size; payload_size -= size; |
808 | src2 += size; payload_size -= size; |
810 | |
809 | |
811 | sn = ntohs(* ((__u16 *)src2)); |
810 | sn = ntohs(* ((u16 *)src2)); |
812 | d_lsb_init(&pro->sn, sn, -1); |
811 | d_lsb_init(&pro->sn, sn, -1); |
813 | d_ip_id_init(&pro->ip_id1,ntohs(active1->ip.id), sn); |
812 | d_ip_id_init(&pro->ip_id1,ntohs(active1->ip.id), sn); |
814 | |
813 | |
815 | udp_syncronize(pro); |
814 | udp_syncronize(pro); |
816 | |
815 | |
… | |
… | |
872 | int checksum = 0; |
871 | int checksum = 0; |
873 | |
872 | |
874 | *sn = d_lsb_decode(&pro->sn, sn_bits, number_of_sn_bits); |
873 | *sn = d_lsb_decode(&pro->sn, sn_bits, number_of_sn_bits); |
875 | |
874 | |
876 | if (active1->rnd) { |
875 | if (active1->rnd) { |
877 | *id = ntohs(*((__u16 *)src)); |
876 | *id = ntohs(*((u16 *)src)); |
878 | src += 2; field_counter +=2; *payload_size -= 2; |
877 | src += 2; field_counter +=2; *payload_size -= 2; |
879 | |
878 | |
880 | } else { |
879 | } else { |
881 | if(number_of_id_bits) |
880 | if(number_of_id_bits) |
882 | *id = d_ip_id_decode(&pro->ip_id1, *id, number_of_id_bits, *sn); |
881 | *id = d_ip_id_decode(&pro->ip_id1, *id, number_of_id_bits, *sn); |
… | |
… | |
886 | |
885 | |
887 | // If multiple ip header |
886 | // If multiple ip header |
888 | if (pro->multiple_ip){ |
887 | if (pro->multiple_ip){ |
889 | |
888 | |
890 | if (active2->rnd) { |
889 | if (active2->rnd) { |
891 | *id2 = ntohs(*((__u16 *)src)); |
890 | *id2 = ntohs(*((u16 *)src)); |
892 | |
891 | |
893 | src +=2; field_counter +=2; *payload_size -= 2; |
892 | src +=2; field_counter +=2; *payload_size -= 2; |
894 | } else { |
893 | } else { |
895 | *id2 = d_ip_id_decode(&pro->ip_id2, 0, 0, *sn); |
894 | *id2 = d_ip_id_decode(&pro->ip_id2, 0, 0, *sn); |
896 | } |
895 | } |
897 | } |
896 | } |
898 | // If checksum present |
897 | // If checksum present |
899 | if(pro->udp_checksum_present){ |
898 | if(pro->udp_checksum_present){ |
900 | rohc_debugf(2,"(decompress) upd checksum present\n"); |
899 | rohc_debugf(2,"(decompress) upd checksum present\n"); |
901 | checksum = ntohs(*((__u16 *)src)); |
900 | checksum = ntohs(*((u16 *)src)); |
902 | src +=2; field_counter +=2; *payload_size -= 2; |
901 | src +=2; field_counter +=2; *payload_size -= 2; |
903 | } |
902 | } |
904 | rohc_debugf(2,"(decomp) udp checksum %x payload size = %d\n",checksum,*payload_size); |
903 | rohc_debugf(2,"(decomp) udp checksum %x payload size = %d\n",checksum,*payload_size); |
905 | // Header write |
904 | // Header write |
906 | if (pro->multiple_ip){ |
905 | if (pro->multiple_ip){ |
… | |
… | |
1018 | } |
1017 | } |
1019 | |
1018 | |
1020 | |
1019 | |
1021 | // Random IP ID ? |
1020 | // Random IP ID ? |
1022 | if (active1->rnd) { |
1021 | if (active1->rnd) { |
1023 | *id = ntohs(*((__u16 *)src2)); |
1022 | *id = ntohs(*((u16 *)src2)); |
1024 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1023 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1025 | } |
1024 | } |
1026 | |
1025 | |
1027 | // Multiple ip-header |
1026 | // Multiple ip-header |
1028 | |
1027 | |
1029 | if (( pro->multiple_ip )&&( active2->rnd )){ |
1028 | if (( pro->multiple_ip )&&( active2->rnd )){ |
1030 | *id2 = ntohs(*((__u16 *)src2)); |
1029 | *id2 = ntohs(*((u16 *)src2)); |
1031 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1030 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1032 | } |
1031 | } |
1033 | |
1032 | |
1034 | // If checksum present |
1033 | // If checksum present |
1035 | if(pro->udp_checksum_present){ |
1034 | if(pro->udp_checksum_present){ |
1036 | checksum = ntohs(*((__u16 *)src2)); |
1035 | checksum = ntohs(*((u16 *)src2)); |
1037 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1036 | src2 +=2; field_counter +=2; *payload_size -= 2; |
1038 | } |
1037 | } |
1039 | |
1038 | |
1040 | // Header write |
1039 | // Header write |
1041 | if (pro->multiple_ip){ |
1040 | if (pro->multiple_ip){ |
… | |
… | |
1150 | &active1->rnd, &active1->nbo); |
1149 | &active1->rnd, &active1->nbo); |
1151 | fields += size; |
1150 | fields += size; |
1152 | } |
1151 | } |
1153 | if (I) { |
1152 | if (I) { |
1154 | if(pro->multiple_ip){ |
1153 | if(pro->multiple_ip){ |
1155 | active2->ip.id = *((__u16 *)fields); |
1154 | active2->ip.id = *((u16 *)fields); |
1156 | fields += 2; |
1155 | fields += 2; |
1157 | *update_id2 = 1; |
1156 | *update_id2 = 1; |
1158 | }else{ |
1157 | }else{ |
1159 | active1->ip.id = *((__u16 *)fields); |
1158 | active1->ip.id = *((u16 *)fields); |
1160 | fields += 2; |
1159 | fields += 2; |
1161 | *ip_id_changed = 1; |
1160 | *ip_id_changed = 1; |
1162 | } |
1161 | } |
1163 | } |
1162 | } |
1164 | if (ip2) { |
1163 | if (ip2) { |
… | |
… | |
1287 | } |
1286 | } |
1288 | *nbo = GET_BIT_2(flags); |
1287 | *nbo = GET_BIT_2(flags); |
1289 | *rnd = GET_BIT_1(flags); |
1288 | *rnd = GET_BIT_1(flags); |
1290 | |
1289 | |
1291 | if (GET_BIT_0(flags)) { |
1290 | if (GET_BIT_0(flags)) { |
1292 | ip->id = *((__u16 *)fields); |
1291 | ip->id = *((u16 *)fields); |
1293 | fields += 2; size += 2; |
1292 | fields += 2; size += 2; |
1294 | *updated_id = 1; |
1293 | *updated_id = 1; |
1295 | } |
1294 | } |
1296 | return size; |
1295 | return size; |
1297 | } |
1296 | } |