3737#include " QUICMultiCertConfigLoader.h"
3838#include " QUICTLS.h"
3939
40- static constexpr char debug_tag[] = " quic_sec" ;
41- static constexpr char v_debug_tag[] = " v_quic_sec" ;
40+ namespace
41+ {
42+
43+ DbgCtl dbg_ctl{" quic_sec" };
44+ DbgCtl dbg_ctl_v{" v_quic_sec" };
45+ DbgCtl dbg_ctl_quick_ph{" quic_ph" };
46+
47+ } // end anonymous namespace
4248
43- #define QUICDebug (fmt, ...) Debug(debug_tag , fmt, ##__VA_ARGS__)
44- #define QUICQCDebug (qc, fmt, ...) Debug(debug_tag , " [%s] " fmt, qc->cids ().data(), ##__VA_ARGS__)
49+ #define QUICDebug (fmt, ...) Dbg(dbg_ctl , fmt, ##__VA_ARGS__)
50+ #define QUICQCDebug (qc, fmt, ...) Dbg(dbg_ctl , " [%s] " fmt, qc->cids ().data(), ##__VA_ARGS__)
4551
4652// ["local dcid" - "local scid"]
47- #define QUICPHDebug (dcid, scid, fmt, ...) \
48- Debug (debug_tag, " [%08" PRIx32 " -%08" PRIx32 " ] " fmt, dcid.h32(), scid.h32(), ##__VA_ARGS__)
53+ #define QUICPHDebug (dcid, scid, fmt, ...) Dbg(dbg_ctl, " [%08" PRIx32 " -%08" PRIx32 " ] " fmt, dcid.h32(), scid.h32(), ##__VA_ARGS__)
4954#define QUICVPHDebug (dcid, scid, fmt, ...) \
50- Debug (v_debug_tag , " [%08" PRIx32 " -%08" PRIx32 " ] " fmt, dcid.h32(), scid.h32(), ##__VA_ARGS__)
55+ Dbg (dbg_ctl_v , " [%08" PRIx32 " -%08" PRIx32 " ] " fmt, dcid.h32(), scid.h32(), ##__VA_ARGS__)
5156
5257//
5358// QUICPacketHandler
@@ -102,7 +107,7 @@ QUICPacketHandler::_send_packet(UDPConnection *udp_con, IpEndpoint &addr, Ptr<IO
102107{
103108 UDPPacket *udp_packet = UDPPacket::new_UDPPacket (addr, 0 , udp_payload);
104109
105- if (is_debug_tag_set (v_debug_tag )) {
110+ if (dbg_ctl_v. on ( )) {
106111 ip_port_text_buffer ipb;
107112 QUICConnectionId dcid = QUICConnectionId::ZERO ();
108113 QUICConnectionId scid = QUICConnectionId::ZERO ();
@@ -257,7 +262,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
257262 return ;
258263 }
259264
260- if (is_debug_tag_set (v_debug_tag )) {
265+ if (dbg_ctl_v. on ( )) {
261266 ip_port_text_buffer ipb_from;
262267 ip_port_text_buffer ipb_to;
263268 QUICVPHDebug (scid, dcid, " recv LH packet from %s to %s size=%" PRId64,
@@ -299,7 +304,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
299304 }
300305 } else {
301306 // TODO: lookup DCID by 5-tuple when ATS omits SCID
302- if (is_debug_tag_set (v_debug_tag )) {
307+ if (dbg_ctl_v. on ( )) {
303308 ip_port_text_buffer ipb_from;
304309 ip_port_text_buffer ipb_to;
305310 QUICVPHDebug (scid, dcid, " recv SH packet from %s to %s size=%" PRId64,
@@ -339,7 +344,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
339344 this ->_send_stateless_reset (dcid, params->instance_id (), udp_packet->getConnection (), udp_packet->from , buf_len - 1 );
340345 udp_packet->free ();
341346
342- if (is_debug_tag_set (debug_tag ) && sent) {
347+ if (dbg_ctl. on ( ) && sent) {
343348 QUICPHDebug (scid, dcid, " sent Stateless Reset : connection not found, dcid=%s" , dcid.hex ().c_str ());
344349 }
345350
@@ -350,7 +355,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
350355 this ->_send_stateless_reset (dcid, params->instance_id (), udp_packet->getConnection (), udp_packet->from , buf_len - 1 );
351356 udp_packet->free ();
352357
353- if (is_debug_tag_set (debug_tag ) && sent) {
358+ if (dbg_ctl. on ( ) && sent) {
354359 QUICPHDebug (scid, dcid, " sent Stateless Reset : connection is already closed, dcid=%s" , dcid.hex ().c_str ());
355360 }
356361
@@ -367,7 +372,7 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
367372 QUICConnectionId original_cid = dcid;
368373 QUICConnectionId peer_cid = scid;
369374
370- if (is_debug_tag_set ( " quic_sec " )) {
375+ if (dbg_ctl. on ( )) {
371376 QUICPHDebug (peer_cid, original_cid, " client initial dcid=%s" , original_cid.hex ().c_str ());
372377 }
373378
@@ -555,7 +560,7 @@ QUICPacketHandlerOut::event_handler(int event, Event *data)
555560 return EVENT_CONT;
556561 }
557562 default :
558- Debug ( " quic_ph " , " Unknown Event (%d)" , event);
563+ Dbg (dbg_ctl_quic_ph , " Unknown Event (%d)" , event);
559564
560565 break ;
561566 }
@@ -576,7 +581,7 @@ QUICPacketHandlerOut::_recv_packet(int event, UDPPacket *udp_packet)
576581 const uint8_t *buf = reinterpret_cast <uint8_t *>(block->buf ());
577582 uint64_t buf_len = block->size ();
578583
579- if (is_debug_tag_set (debug_tag )) {
584+ if (dbg_ctl. on ( )) {
580585 ip_port_text_buffer ipb_from;
581586 ip_port_text_buffer ipb_to;
582587 QUICQCDebug (this ->_vc , " recv %s packet from %s to %s size=%" PRId64, (QUICInvariants::is_long_header (buf) ? " LH" : " SH" ),
0 commit comments