4545#define IPXP_PROCESS_QUIC_HPP
4646
4747
48-
4948#ifdef WITH_NEMEA
50- #include " fields.h"
49+ # include " fields.h"
5150#endif
5251
5352
5857
5958
6059namespace ipxp {
61-
6260#define QUIC_UNIREC_TEMPLATE " QUIC_SNI,QUIC_USER_AGENT,QUIC_VERSION"
6361UR_FIELDS (
6462 string QUIC_SNI,
@@ -71,15 +69,15 @@ UR_FIELDS(
7169 */
7270struct RecordExtQUIC : public RecordExt {
7371 static int REGISTERED_ID;
74- char sni[BUFF_SIZE] = { 0 };
75- char user_agent[BUFF_SIZE] = { 0 };
76- uint32_t quic_version;
72+ char sni[BUFF_SIZE] = { 0 };
73+ char user_agent[BUFF_SIZE] = { 0 };
74+ uint32_t quic_version;
7775
7876 RecordExtQUIC () : RecordExt(REGISTERED_ID)
7977 {
80- sni[0 ] = 0 ;
78+ sni[0 ] = 0 ;
8179 user_agent[0 ] = 0 ;
82- quic_version = 0 ;
80+ quic_version = 0 ;
8381 }
8482
8583 #ifdef WITH_NEMEA
@@ -94,22 +92,23 @@ struct RecordExtQUIC : public RecordExt {
9492 {
9593 return QUIC_UNIREC_TEMPLATE;
9694 }
97- #endif
95+
96+ #endif // ifdef WITH_NEMEA
9897
9998 virtual int fill_ipfix (uint8_t *buffer, int size)
10099 {
101- uint16_t len_sni = strlen (sni);
100+ uint16_t len_sni = strlen (sni);
102101 uint16_t len_user_agent = strlen (user_agent);
103- uint16_t len_version = sizeof (quic_version);
102+ uint16_t len_version = sizeof (quic_version);
104103 int pos = 0 ;
105104
106105 if ((len_sni + 3 ) + (len_user_agent + 3 ) + len_version > size) {
107106 return -1 ;
108107 }
109108
110- pos += variable2ipfix_buffer (buffer + pos, (uint8_t *) sni, len_sni);
111- pos += variable2ipfix_buffer (buffer + pos, (uint8_t *) user_agent, len_user_agent);
112- *(uint32_t *)(buffer + pos) = htonl (quic_version);
109+ pos += variable2ipfix_buffer (buffer + pos, (uint8_t *) sni, len_sni);
110+ pos += variable2ipfix_buffer (buffer + pos, (uint8_t *) user_agent, len_user_agent);
111+ *(uint32_t *) (buffer + pos) = htonl (quic_version);
113112 pos += len_version;
114113 return pos;
115114 }
@@ -120,13 +119,16 @@ struct RecordExtQUIC : public RecordExt {
120119 IPFIX_QUIC_TEMPLATE (IPFIX_FIELD_NAMES)
121120 nullptr
122121 };
122+
123123 return ipfix_template;
124124 }
125125
126126 std::string get_text () const
127127 {
128128 std::ostringstream out;
129- out << " quicsni=\" " << sni << " \" " << " quicuseragent=\" " << user_agent << " \" " << " quicversion=\" " << quic_version << " \" " ;
129+
130+ out << " quicsni=\" " << sni << " \" " << " quicuseragent=\" " << user_agent << " \" " << " quicversion=\" " <<
131+ quic_version << " \" " ;
130132 return out.str ();
131133 }
132134};
@@ -142,8 +144,11 @@ class QUICPlugin : public ProcessPlugin
142144 void init (const char *params);
143145 void close ();
144146 RecordExt *get_ext () const { return new RecordExtQUIC (); }
147+
145148 OptionsParser *get_parser () const { return new OptionsParser (" quic" , " Parse QUIC traffic" ); }
149+
146150 std::string get_name () const { return " quic" ; }
151+
147152 ProcessPlugin *copy ();
148153
149154 int pre_create (Packet &pkt);
@@ -158,6 +163,5 @@ class QUICPlugin : public ProcessPlugin
158163 int parsed_initial;
159164 RecordExtQUIC *quic_ptr;
160165};
161-
162166}
163167#endif /* IPXP_PROCESS_QUIC_HPP */
0 commit comments