@@ -44,42 +44,58 @@ static inline uint32_t jmirror_get_interceptid(jmirrorhdr_t *header) {
4444 return (ntohl (header -> interceptid ) & 0x3fffffff );
4545}
4646
47+ uint8_t * decode_jmirror_from_udp_payload (uint8_t * payload , uint32_t plen ,
48+ uint32_t * cin , uint32_t * shimintid , uint32_t * bodylen ) {
49+
50+ jmirrorhdr_t * header ;
51+ uint32_t rem = plen ;
52+ uint8_t * l3 ;
53+
54+ header = (jmirrorhdr_t * )payload ;
55+ if (!header || rem < sizeof (jmirrorhdr_t )) {
56+ return NULL ;
57+ }
58+
59+ * shimintid = jmirror_get_interceptid (header );
60+ * cin = ntohl (header -> sessionid );
61+
62+ rem -= sizeof (jmirrorhdr_t );
63+ l3 = ((uint8_t * )header ) + sizeof (jmirrorhdr_t );
64+
65+ if (rem == 0 ) {
66+ return NULL ;
67+ }
68+ * bodylen = rem ;
69+ return l3 ;
70+ }
71+
4772int check_jmirror_intercept (colthread_local_t * loc ,
4873 libtrace_packet_t * packet , packet_info_t * pinfo ,
4974 coreserver_t * jmirror_sources ,
5075 vendmirror_intercept_list_t * jmirror_ints ) {
5176
5277 coreserver_t * cs ;
53- jmirrorhdr_t * header = NULL ;
54- uint32_t rem = 0 , cept_id , cin ;
78+ uint32_t rem = 0 , cept_id , cin , bodylen ;
5579 vendmirror_intercept_t * cept , * tmp ;
5680 vendmirror_intercept_list_t * vmilist ;
57- char * l3 ;
81+ uint8_t * l3 , * start ;
5882
5983 if ((cs = match_packet_to_coreserver (jmirror_sources , pinfo , 1 )) == NULL ) {
6084 return 0 ;
6185 }
6286
63- header = (jmirrorhdr_t * )get_udp_payload (packet , & rem , NULL , NULL );
64- if (rem < sizeof (jmirrorhdr_t ) || header == NULL ) {
87+ start = get_udp_payload (packet , & rem , NULL , NULL );
88+ l3 = decode_jmirror_from_udp_payload (start , rem , & cin , & cept_id ,
89+ & bodylen );
90+ if (l3 == NULL ) {
6591 return 0 ;
6692 }
6793
68- cept_id = jmirror_get_interceptid (header );
69-
7094 HASH_FIND (hh , jmirror_ints , & cept_id , sizeof (cept_id ), vmilist );
7195 if (vmilist == NULL ) {
7296 return 0 ;
7397 }
7498
75- rem -= sizeof (jmirrorhdr_t );
76- l3 = ((char * )header ) + sizeof (jmirrorhdr_t );
77-
78- if (rem == 0 ) {
79- return 0 ;
80- }
81- cin = ntohl (header -> sessionid );
82-
8399 HASH_ITER (hh , vmilist -> intercepts , cept , tmp ) {
84100 if (pinfo -> tv .tv_sec < cept -> common .tostart_time ) {
85101 continue ;
@@ -89,9 +105,10 @@ int check_jmirror_intercept(colthread_local_t *loc,
89105 continue ;
90106 }
91107 /* Create an appropriate IPCC and export it */
92- if (push_vendor_mirrored_ipcc_job (loc -> zmq_pubsocks [0 ], & (cept -> common ),
108+ if (push_vendor_mirrored_ipcc_job (
109+ loc -> zmq_pubsocks [cept -> common .seqtrackerid ], & (cept -> common ),
93110 trace_get_timeval (packet ), cin , ETSI_DIR_INDETERMINATE ,
94- l3 , rem ) == 0 ) {
111+ l3 , bodylen ) == 0 ) {
95112 /* for some reason, we failed to create or send the IPCC to
96113 * the sequencing thread? */
97114
0 commit comments