--- /dev/null
+varnishtest "net_helper converters Test"
+
+feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(3.4-dev0)'"
+feature ignore_unknown_macro
+
+haproxy h1 -conf {
+ global
+ .if feature(THREAD)
+ thread-groups 1
+ .endif
+
+ defaults
+ mode http
+ timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
+
+ frontend fe
+ bind "fd@${fe}"
+
+ # 24-byte TCP headers: 20 bytes followed by 4 bytes of options,
+ # then possibly some payload.
+ http-request return status 200
+ http-after-response set-header mss-ok "%[bin(00010050000000000000000060020000ffff000002040578),tcp.options.mss]"
+ http-after-response set-header mss-len2 "%[bin(00010050000000000000000060020000ffff0000010102021234),tcp.options.mss]"
+ http-after-response set-header ws-ok "%[bin(00010050000000000000000060020000ffff000001030307),tcp.options.wscale]"
+ http-after-response set-header ws-len2 "%[bin(00010050000000000000000060020000ffff000001010302aa),tcp.options.wscale]"
+ http-after-response set-header tsval-len2 "%[bin(00010050000000000000000060020000ffff00000101080212345678),tcp.options.tsval]"
+} -start
+
+client c1 -connect ${h1_fe_sock} {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.mss-ok == "1400"
+ expect resp.http.mss-len2 == "0"
+ expect resp.http.ws-ok == "7"
+ expect resp.http.ws-len2 == "0"
+ expect resp.http.tsval-len2 == "0"
+} -run
if (!len)
return 0;
+ /* the MSS option is always 4 bytes long */
+ if (ofs && (uchar)smp->data.u.str.area[ofs + 1] != 4)
+ ofs = 0;
+
smp->data.u.sint = ofs ? read_n16(smp->data.u.str.area + ofs + 2) : 0;
smp->data.type = SMP_T_SINT;
smp->flags &= ~SMP_F_CONST;
if (!len)
return 0;
+ /* the TimeStamp option is always 10 bytes long */
+ if (ofs && (uchar)smp->data.u.str.area[ofs + 1] != 10)
+ ofs = 0;
+
smp->data.u.sint = ofs ? read_n32(smp->data.u.str.area + ofs + 2) : 0;
smp->data.type = SMP_T_SINT;
smp->flags &= ~SMP_F_CONST;
if (!len)
return 0;
+ /* the Window Scale option is always 3 bytes long */
+ if (ofs && (uchar)smp->data.u.str.area[ofs + 1] != 3)
+ ofs = 0;
+
smp->data.u.sint = ofs ? (uchar)smp->data.u.str.area[ofs + 2] : 0;
smp->data.type = SMP_T_SINT;
smp->flags &= ~SMP_F_CONST;