patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / include / net / sctp / sm.h
index 7038423..a73cea9 100644 (file)
@@ -440,6 +440,23 @@ static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_a
                BUG();
 }
 
+/* Check VTAG of the packet matches the sender's own tag. */
+static inline int
+sctp_vtag_verify(const struct sctp_chunk *chunk,
+                const struct sctp_association *asoc)
+{
+       /* RFC 2960 Sec 8.5 When receiving an SCTP packet, the endpoint
+        * MUST ensure that the value in the Verification Tag field of
+        * the received SCTP packet matches its own Tag. If the received
+        * Verification Tag value does not match the receiver's own
+        * tag value, the receiver shall silently discard the packet...
+        */
+        if (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag)
+                return 1;
+
+       return 0;
+}
+
 /* Check VTAG of the packet matches the sender's own tag OR its peer's
  * tag and the T bit is set in the Chunk Flags.
  */