Thread Previous • Date Previous • Date Next • Thread Next |
Hello Didier, Attached are the files for RoHC TCP support, to add to the current branch.I need your help, as said earlier, to modify and complete decompression in decomp/d_tcp.c file.
So warning, the code is not yet available for tests... Best regards, FWX.
Attachment:
new_files.tgz
Description: application/compressed-tar
--- ../rohc/src/common/crc.h 2012-10-24 11:46:45.000000000 +0200 +++ ./src/common/crc.h 2012-10-23 10:46:38.000000000 +0200 @@ -130,5 +130,22 @@ const unsigned char *const crc_table) __attribute__((nonnull(1, 3, 6))); +// Begin FWX2 +unsigned int tcp_compute_crc_static(const unsigned char *const ip, + const unsigned char *const ip2, + const unsigned char *const next_header, + const rohc_crc_type_t crc_type, + const unsigned int init_val, + const unsigned char *const crc_table) + __attribute__((nonnull(1, 3, 6))); +unsigned int tcp_compute_crc_dynamic(const unsigned char *const ip, + const unsigned char *const ip2, + const unsigned char *const next_header, + const rohc_crc_type_t crc_type, + const unsigned int init_val, + const unsigned char *const crc_table) + __attribute__((nonnull(1, 3, 6))); +// End FWX2 + #endif --- ../rohc/src/common/crc.c 2012-10-24 11:46:45.000000000 +0200 +++ ./src/common/crc.c 2012-10-24 10:35:36.000000000 +0200 @@ -24,10 +24,12 @@ */ #include "crc.h" -#include "rohc.h" +//#include "rohc.h" #include "protocols/udp.h" #include "protocols/rtp.h" #include "protocols/esp.h" +#include "protocols/tcp.h" +#include "rohc_traces.h" // FWX2 #include <stdlib.h> #include <assert.h> @@ -705,6 +707,103 @@ } +// Begin FWX2 + +/** + * @brief Compute the CRC-STATIC part of an TCP header + * + * Concerned fields are: + * all fields expect those for CRC-DYNAMIC + * - bytes 1-4 in original TCP header + * + * @param ip The outer IP packet + * @param ip2 The inner IP packet if there is 2 IP headers, NULL otherwise + * @param next_header The next header located after the IP header(s) + * @param crc_type The type of CRC + * @param init_val The initial CRC value + * @param crc_table The pre-computed table for fast CRC computation + * @return The checksum + */ +unsigned int tcp_compute_crc_static(const unsigned char *const ip, + const unsigned char *const ip2, + const unsigned char *const next_header, + const rohc_crc_type_t crc_type, + const unsigned int init_val, + const unsigned char *const crc_table) +{ + unsigned int crc; + struct tcphdr *tcp; + + assert(ip != NULL); + assert(next_header != NULL); + assert(crc_table != NULL); + + crc = init_val; + + /* compute the CRC-STATIC value for IP and IP2 headers */ + crc = compute_crc_static(ip, ip2, next_header, crc_type, crc, crc_table); + + /* get the start of TCP header */ + tcp = (struct tcphdr *) next_header; + + /* bytes 1-4 (Source and destination ports) */ + crc = crc_calculate(crc_type, (unsigned char *)(&tcp->src_port), 4, + crc, crc_table); + + rohc_debugf(3, "length 4 crc %Xh\n",crc); + + return crc; +} + + +/** + * @brief Compute the CRC-DYNAMIC part of an TCP header + * + * Concerned fields are: + * - bytes 5-8 in original ESP header + * + * @param ip The outer IP packet + * @param ip2 The inner IP packet if there is 2 IP headers, NULL otherwise + * @param next_header The next header located after the IP header(s) + * @param crc_type The type of CRC + * @param init_val The initial CRC value + * @param crc_table The pre-computed table for fast CRC computation + * @return The checksum + */ +unsigned int tcp_compute_crc_dynamic(const unsigned char *const ip, + const unsigned char *const ip2, + const unsigned char *const next_header, + const rohc_crc_type_t crc_type, + const unsigned int init_val, + const unsigned char *const crc_table) +{ + unsigned int crc; + struct tcphdr *tcp; + + assert(ip != NULL); + assert(next_header != NULL); + assert(crc_table != NULL); + + crc = init_val; + + /* compute the CRC-DYNAMIC value for IP and IP2 headers */ + crc = compute_crc_dynamic(ip, ip2, next_header, crc_type, crc, crc_table); + + /* get the start of TCP header */ + tcp = (struct tcphdr *) next_header; + + /* bytes 5-20 + TCP options */ + crc = crc_calculate(crc_type, (unsigned char *)(&tcp->seq_number), sizeof(struct tcphdr) - 4 + ( tcp->data_offset << 2 ) - sizeof(struct tcphdr), + crc, crc_table); + + rohc_debugf(3, "length %d crc %Xh\n",(int)(sizeof(struct tcphdr) - 4 + ( tcp->data_offset << 2 ) - sizeof(struct tcphdr)),crc); + + return crc; +} + +// End FWX2 + + /** * Private functions */ --- ../rohc/src/common/rohc.h 2012-10-24 11:46:45.000000000 +0200 +++ ./src/common/rohc.h 2012-10-22 19:08:18.000000000 +0200 @@ -245,6 +245,8 @@ #define ROHC_PROFILE_ESP 0x0003 /// The number allocated for the ROHC IP-only profile (see 5 in the RFC 3843) #define ROHC_PROFILE_IP 0x0004 +/// The number allocated for the ROHC TCP profile (see the RFC 4996) +#define ROHC_PROFILE_TCP 0x0006 // FWX2 /// The number allocated for the ROHC UDP-Lite profile (see 7 in the RFC 4019) #define ROHC_PROFILE_UDPLITE 0x0008 --- ../rohc/src/common/Makefile.am 2012-10-24 11:46:45.000000000 +0200 +++ ./src/common/Makefile.am 2012-10-22 18:59:25.000000000 +0200 @@ -15,6 +15,7 @@ rohc_common.c \ rohc_packets.c \ rohc_traces.c \ + trace.c \ crc.c \ decode.c \ ip_id_offset_decode.c \ @@ -26,10 +27,12 @@ ts_sc_comp.c \ ts_sc_decomp.c \ comp_list.c \ - cid.c + cid.c \ + ipproto.c public_headers = \ rohc.h \ + trace.h \ rohc_packets.h private_headers = \ --- ../rohc/src/comp/rohc_comp.c 2012-10-24 11:46:45.000000000 +0200 +++ ./src/comp/rohc_comp.c 2012-10-23 11:14:35.000000000 +0200 @@ -57,6 +57,7 @@ c_udp_lite_profile, c_esp_profile, c_ip_profile, + c_tcp_profile, //FWX2 c_uncompressed_profile; /** @@ -69,6 +70,7 @@ &c_udp_lite_profile, &c_esp_profile, &c_ip_profile, + &c_tcp_profile, // FWX2 &c_uncompressed_profile, }; --- ../rohc/src/comp/rohc_comp_internals.h 2012-10-24 11:46:45.000000000 +0200 +++ ./src/comp/rohc_comp_internals.h 2012-10-23 11:12:05.000000000 +0200 @@ -39,7 +39,7 @@ */ /** The number of ROHC profiles ready to be used */ -#define C_NUM_PROFILES 6 +#define C_NUM_PROFILES 7 // FWX2 /** The maximal number of outgoing feedbacks that can be queued */ #define FEEDBACK_RING_SIZE 10 --- ../rohc/src/comp/Makefile.am 2012-10-24 11:46:45.000000000 +0200 +++ ./src/comp/Makefile.am 2012-10-22 18:52:30.000000000 +0200 @@ -15,7 +15,9 @@ c_udp.c \ c_udp_lite.c \ c_esp.c \ - c_rtp.c + c_rtp.c \ + c_tcp.c \ + rfc4996_encoding.c librohc_comp_la_LIBADD = \ -lrohc_common \ @@ -41,5 +43,7 @@ c_udp.h \ c_udp_lite.h \ c_esp.h \ - c_rtp.h + c_rtp.h \ + c_tcp.h \ + rfc4996_encoding.h --- ../rohc/src/decomp/rohc_decomp.h 2012-10-24 11:46:45.000000000 +0200 +++ ./src/decomp/rohc_decomp.h 2012-10-23 11:13:08.000000000 +0200 @@ -29,7 +29,7 @@ #include "rohc_comp.h" /// The number of ROHC profiles ready to be used -#define D_NUM_PROFILES 6 +#define D_NUM_PROFILES 7 // FWX2 /// ROHC decompressor states (see 4.3.2 in the RFC 3095) --- ../rohc/src/decomp/rohc_decomp.c 2012-10-24 11:46:45.000000000 +0200 +++ ./src/decomp/rohc_decomp.c 2012-10-23 11:16:27.000000000 +0200 @@ -45,7 +45,8 @@ d_ip_profile, d_udplite_profile, d_esp_profile, - d_rtp_profile; + d_rtp_profile, + d_tcp_profile; // FWX2 /** @@ -59,6 +60,7 @@ &d_udplite_profile, &d_esp_profile, &d_rtp_profile, + &d_tcp_profile, // FWX2 }; --- ../rohc/src/decomp/Makefile.am 2012-10-24 11:46:45.000000000 +0200 +++ ./src/decomp/Makefile.am 2012-10-22 18:49:31.000000000 +0200 @@ -16,7 +16,9 @@ d_udp.c \ d_udp_lite.c \ d_esp.c \ - d_rtp.c + d_rtp.c \ + d_tcp.c \ + rfc4996_decoding.c librohc_decomp_la_LIBADD = \ -lrohc_common \ @@ -45,5 +47,7 @@ d_udp.h \ d_udp_lite.h \ d_esp.h \ - d_rtp.h + d_rtp.h \ + d_tcp.h \ + rfc4996_decoding.h --- ../rohc/test/non_regression/test_non_regression.c 2012-10-24 11:46:45.000000000 +0200 +++ ./test/non_regression/test_non_regression.c 2012-10-23 15:43:33.000000000 +0200 @@ -879,6 +879,7 @@ rohc_activate_profile(comp1, ROHC_PROFILE_UDPLITE); rohc_activate_profile(comp1, ROHC_PROFILE_RTP); rohc_activate_profile(comp1, ROHC_PROFILE_ESP); + rohc_activate_profile(comp1, ROHC_PROFILE_TCP); // FWX2 rohc_c_set_large_cid(comp1, use_large_cid); /* set the callback for random numbers on compressor 1 */ @@ -907,6 +908,7 @@ rohc_activate_profile(comp2, ROHC_PROFILE_UDPLITE); rohc_activate_profile(comp2, ROHC_PROFILE_RTP); rohc_activate_profile(comp2, ROHC_PROFILE_ESP); + rohc_activate_profile(comp2, ROHC_PROFILE_TCP); // FWX2 rohc_c_set_large_cid(comp2, use_large_cid); /* set the callback for random numbers on compressor 2 */ --- ../rohc/app/tunnel/tunnel.c 2012-10-24 11:46:45.000000000 +0200 +++ ./app/tunnel/tunnel.c 2012-10-24 11:34:51.000000000 +0200 @@ -528,6 +528,7 @@ rohc_activate_profile(comp, ROHC_PROFILE_UDPLITE); rohc_activate_profile(comp, ROHC_PROFILE_RTP); rohc_activate_profile(comp, ROHC_PROFILE_ESP); + rohc_activate_profile(comp, ROHC_PROFILE_TCP); // FWX2 /* initialize the random generator */ seed = time(NULL);
Thread Previous • Date Previous • Date Next • Thread Next |