TODO: handle generic_static_irregular() encoding missing

Bug #1498940 reported by Klaus Warnke on 2015-09-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Status tracked in Rohc-main
Didier Barvaux
Didier Barvaux

Bug Description

TODO: in what case option_static could be set to 1 ?

I guess if a generic option do not change at all.
Maybe someone have a deeper knowledge which options
are stay unchanged due to the stream lifetime, but
I haven't. I use this, if the option it at the second
occurrence is unchanged. If it changes only once,
I use option_static == 0. There is no way back to
option_static == 1. That is, option_static == 0 is
my default value. This can be improved, if it is
well known, which options are type is static by design.

However, in test ipv4_tcp_afl54-changing-opt-ws-rnd7-2
a generic option is unchanged. To test this, I added this:

diff --git a/src/decomp/d_tcp_opts_list.c b/src/decomp/d_tcp_opts_list.c
index 0fef714..612d84b 100644
--- a/src/decomp/d_tcp_opts_list.c
+++ b/src/decomp/d_tcp_opts_list.c
@@ -1294,12 +1318,13 @@ static int d_tcp_parse_generic_irreg(const struct rohc_decomp_ctxt *const contex

  persist = &tcp_context->tcp_opts.bits[opt_index];

- /* TODO: in what case option_static could be set to 1 ? */
  if(persist->data.generic.option_static == 1)
- /* TODO: handle generic_static_irregular() encoding */
- rohc_decomp_warn(context, "unsupported generic_static_irregular() encoding");
- goto error;
+ const size_t opt_load_len = persist->data.generic.load_len;
+ opt_ctxt->data.generic.load_len = opt_load_len;
+ memcpy(opt_ctxt->data.generic.load, persist->data.generic.load, opt_load_len);
+ rohc_decomp_debug(context, "TCP generic option payload = %zu bytes", opt_load_len);
  else if(persist->data.generic.option_static == 0)

The code is the same as for generic_stable_irregular.
It takes the contents from the context.
Maybe you want to extract it into a function.

Klaus Warnke

Klaus Warnke (k-warnke) wrote :


this patch and the patch regarding the generic_static stuff is incomplete.
If the generic option is static, the option_static flag must be copied
around with the other fields too.
I do something like this there:

 if(persist->data.generic.option_static == 1)
  opt_ctxt->data.generic = persist->data.generic;
  rohc_decomp_debug(context, "TCP generic option payload = %u bytes", persist->data.generic.load_len);

instead of copy each struct element explicit. You prefer memcpy to avoid alignment issues.
Yeah, everything works on a Intel box, but if go to ARM strange things happens...
On a SPARC platform you may receive a SIGBUS, which helps.
But I assume, If there is a alignment problem, then there is a problem using
the "->" operator with this struct at all, not only when coping the whole data.
This option_static problem is the same here:

  if(discriminator == 0xff)
   opt_ctxt->data.generic = persist->data.generic;
   rohc_decomp_debug(context, "TCP generic option payload = %u bytes", persist->data.generic.load_len);

If no data received, the ->option_static flag must be copied too.
Or explicit:

                    const size_t opt_load_len = persist->data.generic.load_len;

                    opt_ctxt->data.generic.option_static = 0;/*persist->data.generic.option_static;*/
                    opt_ctxt->data.generic.load_len = opt_load_len;
                    memcpy(opt_ctxt->data.generic.load, persist->data.generic.load, opt_load_len);
                    rohc_decomp_debug(context, "TCP generic option payload = %zu bytes", opt_load_len);

I guess, in the case

  else if(discriminator == 0x00)
   opt_ctxt->data.generic.option_static = 0;
   opt_ctxt->data.generic.load_len = opt_load_len;
   memcpy(opt_ctxt->data.generic.load, data + read, opt_load_len);
   read += opt_load_len;
   rohc_decomp_debug(context, "TCP generic option payload = %zu bytes", opt_load_len);

Klaus Warnke

Klaus Warnke (k-warnke) wrote :


I found a real cool tool you maybe don't know.

I'm searching a long time for tool simply edit some bytes
in a pcap file. wireshark is not able.
There are some tools out there, but there are not
So I used emcas with hexl-mode, which is pain...
To find a specific packet in a hexdump is not easy.
However WireEdit do the jobs awesome.
Adding new TCP option, checksum recalc and
automatic fixing TCP and so on.
And its free.

Klaus Warnke

Didier Barvaux (didier-barvaux) wrote :


WireEdit looks impressive. Too bad that this is not Open Source and does not run natively under Linux :-/

I used to alter PCAP with Scapy, a Python tool box to manipulate packets:


To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers