@@ -667,6 +667,74 @@ static const struct vdp xyzzy_vdp_awshog = {
667
667
.init = xyzzy_awshog_init
668
668
};
669
669
670
+ /**********************************************************************/
671
+
672
+ static int v_matchproto_ (vdp_init_f )
673
+ xyzzy_vdp_body_prefix_init (VRT_CTX , struct vdp_ctx * vdc , void * * priv )
674
+ {
675
+ struct xyzzy_bp_string * bps ;
676
+ struct xyzzy_bp * bp ;
677
+ struct vmod_priv * task ;
678
+ intmax_t l ;
679
+
680
+ CHECK_OBJ_NOTNULL (ctx , VRT_CTX_MAGIC );
681
+ CHECK_OBJ_NOTNULL (vdc , VDP_CTX_MAGIC );
682
+ AN (vdc -> clen );
683
+
684
+ task = VRT_priv_task_get (ctx , priv_task_id_bp );
685
+ if (task == NULL )
686
+ return (1 );
687
+ CAST_OBJ_NOTNULL (bp , task -> priv , XYZZY_BP_MAGIC );
688
+ AN (priv );
689
+ AZ (* priv );
690
+ * priv = bp ;
691
+
692
+ if (* vdc -> clen < 0 )
693
+ return (0 );
694
+
695
+ l = 0 ;
696
+ VSTAILQ_FOREACH (bps , & bp -> head , list )
697
+ l += strlen (bps -> s );
698
+ * vdc -> clen += l ;
699
+
700
+ return (0 );
701
+ }
702
+
703
+ static int v_matchproto_ (vdp_bytes_f )
704
+ xyzzy_vdp_body_prefix_bytes (struct vdp_ctx * vdc , enum vdp_action act , void * * priv ,
705
+ const void * ptr , ssize_t len )
706
+ {
707
+ struct xyzzy_bp_string * bps ;
708
+ struct xyzzy_bp * bp ;
709
+
710
+ AN (priv );
711
+ CAST_OBJ_NOTNULL (bp , * priv , XYZZY_BP_MAGIC );
712
+
713
+ while ((bps = VSTAILQ_FIRST (& bp -> head )) != NULL) {
714
+ VSTAILQ_REMOVE_HEAD (& bp -> head , list );
715
+ if (VDP_bytes (vdc , VDP_NULL , bps -> s , strlen (bps -> s )))
716
+ return (vdc -> retval );
717
+ }
718
+
719
+ return (VDP_bytes (vdc , act , ptr , len ));
720
+ }
721
+
722
+ static int v_matchproto_ (vdp_fini_f )
723
+ xyzzy_vdp_body_prefix_fini (struct vdp_ctx * vdc , void * * priv )
724
+ {
725
+ (void )vdc ;
726
+ AN (priv );
727
+ * priv = NULL ;
728
+ return (0 );
729
+ }
730
+
731
+ static const struct vdp xyzzy_vdp_body_prefix = {
732
+ .name = "debug.body_prefix" ,
733
+ .init = xyzzy_vdp_body_prefix_init ,
734
+ .bytes = xyzzy_vdp_body_prefix_bytes ,
735
+ .fini = xyzzy_vdp_body_prefix_fini
736
+ };
737
+
670
738
void
671
739
debug_add_filters (VRT_CTX )
672
740
{
@@ -677,6 +745,7 @@ debug_add_filters(VRT_CTX)
677
745
AZ (VRT_AddFilter (ctx , NULL , & xyzzy_vdp_chksha256 ));
678
746
AZ (VRT_AddFilter (ctx , NULL , & xyzzy_vdp_chkcrc32 ));
679
747
AZ (VRT_AddFilter (ctx , NULL , & xyzzy_vdp_awshog ));
748
+ AZ (VRT_AddFilter (ctx , NULL , & xyzzy_vdp_body_prefix ));
680
749
}
681
750
682
751
void
@@ -689,4 +758,5 @@ debug_remove_filters(VRT_CTX)
689
758
VRT_RemoveFilter (ctx , NULL , & xyzzy_vdp_chksha256 );
690
759
VRT_RemoveFilter (ctx , NULL , & xyzzy_vdp_chkcrc32 );
691
760
VRT_RemoveFilter (ctx , NULL , & xyzzy_vdp_awshog );
761
+ VRT_RemoveFilter (ctx , NULL , & xyzzy_vdp_body_prefix );
692
762
}
0 commit comments