]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Add session ID per protocol version
authorpcarana <pc.moreno2099@gmail.com>
Thu, 28 Feb 2019 21:06:57 +0000 (15:06 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Thu, 28 Feb 2019 21:06:57 +0000 (15:06 -0600)
src/rtr/pdu_handler.c
src/vrps.c
src/vrps.h

index 3f3d8c786e5173fa8e77dc44e549afeb80d1918b..00460cb1ccd00f504bfb7c60c5151f6bb360041d 100644 (file)
@@ -51,6 +51,7 @@ handle_serial_query_pdu(int fd, void *pdu)
        int error, updates;
        u_int32_t current_serial;
        u_int16_t session_id;
+       u_int8_t version;
 
        /*
         * RFC 6810 and 8210:
@@ -59,14 +60,14 @@ handle_serial_query_pdu(int fd, void *pdu)
         * mismatch MUST immediately terminate the session with an Error Report PDU
         * with code 0 ("Corrupt Data")"
         */
-       session_id = current_session_id();
+       version = received->header.protocol_version;
+       session_id = current_session_id(version);
        if (received->header.session_id != session_id)
                return send_error_report_pdu(&common, ERR_CORRUPT_DATA, NULL, NULL);
 
        current_serial = last_serial_number();
-       init_sender_common(&common, fd, received->header.protocol_version,
-           &received->header.session_id, &received->serial_number,
-           &current_serial);
+       init_sender_common(&common, fd, version, &session_id,
+           &received->serial_number, &current_serial);
 
        updates = deltas_db_status(common.start_serial);
        switch (updates) {
@@ -99,12 +100,14 @@ handle_reset_query_pdu(int fd, void *pdu)
        struct sender_common common;
        u_int32_t current_serial;
        u_int16_t session_id;
+       u_int8_t version;
        int error, updates;
 
+       version = received->header.protocol_version;
+       session_id = current_session_id(version);
        current_serial = last_serial_number();
-       session_id = current_session_id();
-       init_sender_common(&common, fd, received->header.protocol_version,
-           &session_id, NULL, &current_serial);
+       init_sender_common(&common, fd, version, &session_id, NULL,
+           &current_serial);
 
        updates = deltas_db_status(common.start_serial);
        switch (updates) {
index 5ab1bf408e5396e07b442db772f2ebee90ee455d..ac45724010a5319a8977ef4e30e3bf473f03a5a8 100644 (file)
@@ -17,7 +17,8 @@ ARRAY_LIST(deltasdb, struct delta)
 
 struct deltasdb db;
 u_int32_t current_serial;
-u_int16_t session_id;
+u_int16_t v0_session_id;
+u_int16_t v1_session_id;
 
 int
 deltas_db_init(void)
@@ -31,7 +32,9 @@ deltas_db_init(void)
        }
        current_serial = 0;
        /* The downcast takes the LSBs */
-       session_id = time(NULL);
+       v0_session_id = time(NULL);
+       /* Minus 1 to prevent same ID */
+       v1_session_id = v0_session_id - 1;
 
        return 0;
 }
@@ -236,7 +239,9 @@ last_serial_number(void)
 }
 
 u_int16_t
-current_session_id(void)
+current_session_id(u_int8_t rtr_version)
 {
-       return session_id;
+       if (rtr_version == 1)
+               return v1_session_id;
+       return v0_session_id;
 }
index 4a7749601e5e4eeb7dcec8d3d77c8895df42ec75..1a07a353cba5aa223fdba3e2edd6ded933e903f6 100644 (file)
@@ -39,6 +39,6 @@ void delta_destroy(struct delta *);
 void deltas_db_destroy(void);
 
 u_int32_t last_serial_number(void);
-u_int16_t current_session_id(void);
+u_int16_t current_session_id(u_int8_t);
 
 #endif /* SRC_VRPS_H_ */