- frm_len=$(wc -c $tmpdir/block.$frame | awk '{ print $1 }')
- cut_len=$((frm_len-2*tcp_len))
- cat $tmpdir/block.$frame | cut -c${cut_len}- > $RESULTS_DIR/$frame.hex
+ dia_len=$(echo $frame_info | cut -d\| -f16)
+ protocol=$(echo $frame_info | cut -d\| -f17)
+
+ # TCP and SCTP supported:
+ transport=$(echo $protocol | grep -ow tcp)
+ [ -z "$transport" ] && transport=$(echo $protocol | grep -ow sctp)
+
+ case $transport in
+ sctp)
+ cut_len=$((2*dia_len))
+ cat $tmpdir/block.$frame | rev | cut -c-${cut_len} | rev > $RESULTS_DIR/$frame.hex
+ ;;
+
+ tcp)
+ cut_len=$((frm_len-tcp_len))
+ defi=$((2*cut_len + 1))
+ cat $tmpdir/block.$frame | cut -c${defi}- > $RESULTS_DIR/$frame.hex
+ cp $tmpdir/block.$frame /tmp/block
+ ;;
+
+ *) _exit "Only TCP and SCTP transports supported !!"
+ ;;
+ esac
+ ##########################################################################################
+