1 /* Copyright (c) 2001 NETLAB, Temple University
2 * Copyright (c) 2001 Protocol Engineering Lab, University of Delaware
4 * Jerry Heinz <gheinz@astro.temple.edu>
5 * John Fiore <jfiore@joda.cis.temple.edu>
6 * Armando L. Caro Jr. <acaro@cis.udel.edu>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor of the Laboratory may be used
20 * to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 #include <netdissect-stdinc.h>
42 #include "netdissect.h"
43 #include "addrtoname.h"
50 * SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
52 * Redistribution and use in source and binary forms, with or without
53 * modification, are permitted provided that the following conditions
56 * 1. Redistributions of source code must retain the above copyright
57 * notice, this list of conditions and the following disclaimer.
59 * 2. Redistributions in binary form must reproduce the above copyright
60 * notice, this list of conditions and the following disclaimer in the
61 * documentation and/or other materials provided with the distribution.
63 * 3. Neither the name of Cisco nor of Motorola may be used
64 * to endorse or promote products derived from this software without
65 * specific prior written permission.
67 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
68 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
69 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
70 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
71 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
72 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
73 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
74 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
75 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
76 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
79 * This file is part of the SCTP reference Implementation
82 * Please send any bug reports or fixes you make to one of the following email
85 * rstewar1@email.mot.com
89 * Any bugs reported given to us we will try to fix... any fixes shared will
90 * be incorperated into the next SCTP release.
93 /* The valid defines for all message
94 * types know to SCTP. 0 is reserved
96 #define SCTP_DATA 0x00
97 #define SCTP_INITIATION 0x01
98 #define SCTP_INITIATION_ACK 0x02
99 #define SCTP_SELECTIVE_ACK 0x03
100 #define SCTP_HEARTBEAT_REQUEST 0x04
101 #define SCTP_HEARTBEAT_ACK 0x05
102 #define SCTP_ABORT_ASSOCIATION 0x06
103 #define SCTP_SHUTDOWN 0x07
104 #define SCTP_SHUTDOWN_ACK 0x08
105 #define SCTP_OPERATION_ERR 0x09
106 #define SCTP_COOKIE_ECHO 0x0a
107 #define SCTP_COOKIE_ACK 0x0b
108 #define SCTP_ECN_ECHO 0x0c
109 #define SCTP_ECN_CWR 0x0d
110 #define SCTP_SHUTDOWN_COMPLETE 0x0e
111 #define SCTP_FORWARD_CUM_TSN 0xc0
112 #define SCTP_RELIABLE_CNTL 0xc1
113 #define SCTP_RELIABLE_CNTL_ACK 0xc2
115 static const struct tok sctp_chunkid_str
[] = {
116 { SCTP_DATA
, "DATA" },
117 { SCTP_INITIATION
, "INIT" },
118 { SCTP_INITIATION_ACK
, "INIT ACK" },
119 { SCTP_SELECTIVE_ACK
, "SACK" },
120 { SCTP_HEARTBEAT_REQUEST
, "HB REQ" },
121 { SCTP_HEARTBEAT_ACK
, "HB ACK" },
122 { SCTP_ABORT_ASSOCIATION
, "ABORT" },
123 { SCTP_SHUTDOWN
, "SHUTDOWN" },
124 { SCTP_SHUTDOWN_ACK
, "SHUTDOWN ACK" },
125 { SCTP_OPERATION_ERR
, "OP ERR" },
126 { SCTP_COOKIE_ECHO
, "COOKIE ECHO" },
127 { SCTP_COOKIE_ACK
, "COOKIE ACK" },
128 { SCTP_ECN_ECHO
, "ECN ECHO" },
129 { SCTP_ECN_CWR
, "ECN CWR" },
130 { SCTP_SHUTDOWN_COMPLETE
, "SHUTDOWN COMPLETE" },
131 { SCTP_FORWARD_CUM_TSN
, "FOR CUM TSN" },
132 { SCTP_RELIABLE_CNTL
, "REL CTRL" },
133 { SCTP_RELIABLE_CNTL_ACK
, "REL CTRL ACK" },
137 /* Data Chuck Specific Flags */
138 #define SCTP_DATA_FRAG_MASK 0x03
139 #define SCTP_DATA_MIDDLE_FRAG 0x00
140 #define SCTP_DATA_LAST_FRAG 0x01
141 #define SCTP_DATA_FIRST_FRAG 0x02
142 #define SCTP_DATA_NOT_FRAG 0x03
143 #define SCTP_DATA_UNORDERED 0x04
145 #define SCTP_ADDRMAX 60
151 /* the sctp common header */
155 uint16_t destination
;
156 uint32_t verificationTag
;
160 /* various descriptor parsers */
162 struct sctpChunkDesc
{
165 uint16_t chunkLength
;
168 struct sctpParamDesc
{
170 uint16_t paramLength
;
174 struct sctpRelChunkDesc
{
175 struct sctpChunkDesc chk
;
176 uint32_t serialNumber
;
179 struct sctpVendorSpecificParam
{
180 struct sctpParamDesc p
; /* type must be 0xfffe */
181 uint32_t vendorId
; /* vendor ID from RFC 1700 */
182 uint16_t vendorSpecificType
;
183 uint16_t vendorSpecificLen
;
187 /* Structures for the control parts */
191 /* Sctp association init request/ack */
193 /* this is used for init ack, too */
194 struct sctpInitiation
{
195 uint32_t initTag
; /* tag of mine */
196 uint32_t rcvWindowCredit
; /* rwnd */
197 uint16_t NumPreopenStreams
; /* OS */
198 uint16_t MaxInboundStreams
; /* MIS */
200 /* optional param's follow in sctpParamDesc form */
203 struct sctpV4IpAddress
{
204 struct sctpParamDesc p
; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
209 struct sctpV6IpAddress
{
210 struct sctpParamDesc p
; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
211 uint8_t ipAddress
[16];
215 struct sctpParamDesc param
;
220 struct sctpCookiePreserve
{
221 struct sctpParamDesc p
; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
226 struct sctpTimeStamp
{
231 /* wire structure of my cookie */
232 struct cookieMessage
{
233 uint32_t TieTag_curTag
; /* copied from assoc if present */
234 uint32_t TieTag_hisTag
; /* copied from assoc if present */
235 int32_t cookieLife
; /* life I will award this cookie */
236 struct sctpTimeStamp timeEnteringState
; /* the time I built cookie */
237 struct sctpInitiation initAckISent
; /* the INIT-ACK that I sent to my peer */
238 uint32_t addressWhereISent
[4]; /* I make this 4 ints so I get 128bits for future */
239 int32_t addrtype
; /* address type */
240 uint16_t locScope
; /* V6 local scope flag */
241 uint16_t siteScope
; /* V6 site scope flag */
242 /* at the end is tacked on the INIT chunk sent in
243 * its entirety and of course our
249 /* this guy is for use when
250 * I have a initiate message gloming the
254 struct sctpUnifiedInit
{
255 struct sctpChunkDesc uh
;
256 struct sctpInitiation initm
;
259 struct sctpSendableInit
{
260 struct sctpHeader mh
;
261 struct sctpUnifiedInit msg
;
265 /* Selective Acknowledgement
266 * has the following structure with
267 * a optional ammount of trailing int's
268 * on the last part (based on the numberOfDesc
272 struct sctpSelectiveAck
{
273 uint32_t highestConseqTSN
;
274 uint32_t updatedRwnd
;
275 uint16_t numberOfdesc
;
279 struct sctpSelectiveFrag
{
280 uint16_t fragmentStart
;
281 uint16_t fragmentEnd
;
285 struct sctpUnifiedSack
{
286 struct sctpChunkDesc uh
;
287 struct sctpSelectiveAck sack
;
290 /* for both RTT request/response the
294 struct sctpHBrequest
{
295 uint32_t time_value_1
;
296 uint32_t time_value_2
;
299 /* here is what I read and respond with to. */
300 struct sctpHBunified
{
301 struct sctpChunkDesc hdr
;
302 struct sctpParamDesc hb
;
306 /* here is what I send */
308 struct sctpChunkDesc hdr
;
309 struct sctpParamDesc hb
;
310 struct sctpHBrequest rtt
;
311 int8_t addrFmt
[SCTP_ADDRMAX
];
317 /* for the abort and shutdown ACK
318 * we must carry the init tag in the common header. Just the
319 * common header is all that is needed with a chunk descriptor.
321 struct sctpUnifiedAbort
{
322 struct sctpChunkDesc uh
;
325 struct sctpUnifiedAbortLight
{
326 struct sctpHeader mh
;
327 struct sctpChunkDesc uh
;
330 struct sctpUnifiedAbortHeavy
{
331 struct sctpHeader mh
;
332 struct sctpChunkDesc uh
;
337 /* For the graceful shutdown we must carry
338 * the tag (in common header) and the highest consequitive acking value
340 struct sctpShutdown
{
344 struct sctpUnifiedShutdown
{
345 struct sctpChunkDesc uh
;
346 struct sctpShutdown shut
;
349 /* in the unified message we add the trailing
350 * stream id since it is the only message
351 * that is defined as a operation error.
353 struct sctpOpErrorCause
{
358 struct sctpUnifiedOpError
{
359 struct sctpChunkDesc uh
;
360 struct sctpOpErrorCause c
;
363 struct sctpUnifiedStreamError
{
364 struct sctpHeader mh
;
365 struct sctpChunkDesc uh
;
366 struct sctpOpErrorCause c
;
371 struct staleCookieMsg
{
372 struct sctpHeader mh
;
373 struct sctpChunkDesc uh
;
374 struct sctpOpErrorCause c
;
378 /* the following is used in all sends
379 * where nothing is needed except the
380 * chunk/type i.e. shutdownAck Abort */
382 struct sctpUnifiedSingleMsg
{
383 struct sctpHeader mh
;
384 struct sctpChunkDesc uh
;
391 uint32_t payloadtype
;
394 struct sctpUnifiedDatagram
{
395 struct sctpChunkDesc uh
;
396 struct sctpDataPart dp
;
400 struct sctpChunkDesc uh
;
406 struct sctpChunkDesc uh
;
407 uint32_t TSN_reduced_at
;
410 static const struct tok ForCES_channels
[] = {
411 { CHAN_HP
, "ForCES HP" },
412 { CHAN_MP
, "ForCES MP" },
413 { CHAN_LP
, "ForCES LP" },
417 /* data chunk's payload protocol identifiers */
419 #define SCTP_PPID_IUA 1
420 #define SCTP_PPID_M2UA 2
421 #define SCTP_PPID_M3UA 3
422 #define SCTP_PPID_SUA 4
423 #define SCTP_PPID_M2PA 5
424 #define SCTP_PPID_V5UA 6
425 #define SCTP_PPID_H248 7
426 #define SCTP_PPID_BICC 8
427 #define SCTP_PPID_TALI 9
428 #define SCTP_PPID_DUA 10
429 #define SCTP_PPID_ASAP 11
430 #define SCTP_PPID_ENRP 12
431 #define SCTP_PPID_H323 13
432 #define SCTP_PPID_QIPC 14
433 #define SCTP_PPID_SIMCO 15
434 #define SCTP_PPID_DDPSC 16
435 #define SCTP_PPID_DDPSSC 17
436 #define SCTP_PPID_S1AP 18
437 #define SCTP_PPID_RUA 19
438 #define SCTP_PPID_HNBAP 20
439 #define SCTP_PPID_FORCES_HP 21
440 #define SCTP_PPID_FORCES_MP 22
441 #define SCTP_PPID_FORCES_LP 23
442 #define SCTP_PPID_SBC_AP 24
443 #define SCTP_PPID_NBAP 25
445 #define SCTP_PPID_X2AP 27
447 static const struct tok PayloadProto_idents
[] = {
448 { SCTP_PPID_IUA
, "ISDN Q.921" },
449 { SCTP_PPID_M2UA
, "M2UA" },
450 { SCTP_PPID_M3UA
, "M3UA" },
451 { SCTP_PPID_SUA
, "SUA" },
452 { SCTP_PPID_M2PA
, "M2PA" },
453 { SCTP_PPID_V5UA
, "V5.2" },
454 { SCTP_PPID_H248
, "H.248" },
455 { SCTP_PPID_BICC
, "BICC" },
456 { SCTP_PPID_TALI
, "TALI" },
457 { SCTP_PPID_DUA
, "DUA" },
458 { SCTP_PPID_ASAP
, "ASAP" },
459 { SCTP_PPID_ENRP
, "ENRP" },
460 { SCTP_PPID_H323
, "H.323" },
461 { SCTP_PPID_QIPC
, "Q.IPC" },
462 { SCTP_PPID_SIMCO
, "SIMCO" },
463 { SCTP_PPID_DDPSC
, "DDPSC" },
464 { SCTP_PPID_DDPSSC
, "DDPSSC" },
465 { SCTP_PPID_S1AP
, "S1AP" },
466 { SCTP_PPID_RUA
, "RUA" },
467 { SCTP_PPID_HNBAP
, "HNBAP" },
468 { SCTP_PPID_FORCES_HP
, "ForCES HP" },
469 { SCTP_PPID_FORCES_MP
, "ForCES MP" },
470 { SCTP_PPID_FORCES_LP
, "ForCES LP" },
471 { SCTP_PPID_SBC_AP
, "SBc-AP" },
472 { SCTP_PPID_NBAP
, "NBAP" },
474 { SCTP_PPID_X2AP
, "X2AP" },
479 static inline int isForCES_port(u_short Port
)
491 void sctp_print(netdissect_options
*ndo
,
492 const u_char
*bp
, /* beginning of sctp packet */
493 const u_char
*bp2
, /* beginning of enclosing */
494 u_int sctpPacketLength
) /* ip packet */
496 u_int sctpPacketLengthRemaining
;
497 const struct sctpHeader
*sctpPktHdr
;
499 const struct ip6_hdr
*ip6
;
500 u_short sourcePort
, destPort
;
502 const struct sctpChunkDesc
*chunkDescPtr
;
506 if (sctpPacketLength
< sizeof(struct sctpHeader
))
508 ND_PRINT((ndo
, "truncated-sctp - %ld bytes missing!",
509 (long)(sizeof(struct sctpHeader
) - sctpPacketLength
)));
512 sctpPktHdr
= (const struct sctpHeader
*) bp
;
513 ND_TCHECK(*sctpPktHdr
);
514 sctpPacketLengthRemaining
= sctpPacketLength
;
516 sourcePort
= EXTRACT_16BITS(&sctpPktHdr
->source
);
517 destPort
= EXTRACT_16BITS(&sctpPktHdr
->destination
);
519 ip
= (const struct ip
*)bp2
;
521 ip6
= (const struct ip6_hdr
*)bp2
;
526 ND_PRINT((ndo
, "%s.%d > %s.%d: sctp",
527 ip6addr_string(ndo
, &ip6
->ip6_src
),
529 ip6addr_string(ndo
, &ip6
->ip6_dst
),
533 ND_PRINT((ndo
, "%s.%d > %s.%d: sctp",
534 ipaddr_string(ndo
, &ip
->ip_src
),
536 ipaddr_string(ndo
, &ip
->ip_dst
),
540 if (isForCES_port(sourcePort
)) {
541 ND_PRINT((ndo
, "[%s]", tok2str(ForCES_channels
, NULL
, sourcePort
)));
544 if (isForCES_port(destPort
)) {
545 ND_PRINT((ndo
, "[%s]", tok2str(ForCES_channels
, NULL
, destPort
)));
549 bp
+= sizeof(struct sctpHeader
);
550 sctpPacketLengthRemaining
-= sizeof(struct sctpHeader
);
552 if (ndo
->ndo_vflag
>= 2)
556 /* cycle through all chunks, printing information on each one */
557 for (chunkCount
= 0, chunkDescPtr
= (const struct sctpChunkDesc
*)bp
;
558 sctpPacketLengthRemaining
!= 0;
561 uint16_t chunkLength
, chunkLengthRemaining
;
564 chunkDescPtr
= (const struct sctpChunkDesc
*)bp
;
565 if (sctpPacketLengthRemaining
< sizeof(*chunkDescPtr
)) {
566 ND_PRINT((ndo
, "%s%d) [chunk descriptor cut off at end of packet]", sep
, chunkCount
+1));
569 ND_TCHECK(*chunkDescPtr
);
570 chunkLength
= EXTRACT_16BITS(&chunkDescPtr
->chunkLength
);
571 if (chunkLength
< sizeof(*chunkDescPtr
)) {
572 ND_PRINT((ndo
, "%s%d) [Bad chunk length %u, < size of chunk descriptor]", sep
, chunkCount
+1, chunkLength
));
575 chunkLengthRemaining
= chunkLength
;
577 align
= chunkLength
% 4;
581 if (sctpPacketLengthRemaining
< align
) {
582 ND_PRINT((ndo
, "%s%d) [Bad chunk length %u, > remaining data in packet]", sep
, chunkCount
+1, chunkLength
));
586 ND_TCHECK2(*bp
, chunkLength
);
588 bp
+= sizeof(*chunkDescPtr
);
589 sctpPacketLengthRemaining
-= sizeof(*chunkDescPtr
);
590 chunkLengthRemaining
-= sizeof(*chunkDescPtr
);
592 ND_PRINT((ndo
, "%s%d) ", sep
, chunkCount
+1));
593 ND_PRINT((ndo
, "[%s] ", tok2str(sctp_chunkid_str
, "Unknown chunk type: 0x%x",
594 chunkDescPtr
->chunkID
)));
595 switch (chunkDescPtr
->chunkID
)
599 const struct sctpDataPart
*dataHdrPtr
;
603 if ((chunkDescPtr
->chunkFlg
& SCTP_DATA_UNORDERED
)
604 == SCTP_DATA_UNORDERED
)
605 ND_PRINT((ndo
, "(U)"));
607 if ((chunkDescPtr
->chunkFlg
& SCTP_DATA_FIRST_FRAG
)
608 == SCTP_DATA_FIRST_FRAG
)
609 ND_PRINT((ndo
, "(B)"));
611 if ((chunkDescPtr
->chunkFlg
& SCTP_DATA_LAST_FRAG
)
612 == SCTP_DATA_LAST_FRAG
)
613 ND_PRINT((ndo
, "(E)"));
615 if( ((chunkDescPtr
->chunkFlg
& SCTP_DATA_UNORDERED
)
616 == SCTP_DATA_UNORDERED
)
618 ((chunkDescPtr
->chunkFlg
& SCTP_DATA_FIRST_FRAG
)
619 == SCTP_DATA_FIRST_FRAG
)
621 ((chunkDescPtr
->chunkFlg
& SCTP_DATA_LAST_FRAG
)
622 == SCTP_DATA_LAST_FRAG
) )
623 ND_PRINT((ndo
, " "));
625 if (chunkLengthRemaining
< sizeof(*dataHdrPtr
)) {
626 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
629 dataHdrPtr
=(const struct sctpDataPart
*)bp
;
631 ppid
= EXTRACT_32BITS(&dataHdrPtr
->payloadtype
);
632 ND_PRINT((ndo
, "[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr
->TSN
)));
633 ND_PRINT((ndo
, "[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr
->streamId
)));
634 ND_PRINT((ndo
, "[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr
->sequence
)));
635 ND_PRINT((ndo
, "[PPID %s] ",
636 tok2str(PayloadProto_idents
, "0x%x", ppid
)));
639 isforces
= (ppid
== SCTP_PPID_FORCES_HP
) ||
640 (ppid
== SCTP_PPID_FORCES_MP
) ||
641 (ppid
== SCTP_PPID_FORCES_LP
);
644 bp
+= sizeof(*dataHdrPtr
);
645 sctpPacketLengthRemaining
-= sizeof(*dataHdrPtr
);
646 chunkLengthRemaining
-= sizeof(*dataHdrPtr
);
647 payload_size
= chunkLengthRemaining
;
648 if (payload_size
== 0) {
649 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
654 forces_print(ndo
, bp
, payload_size
);
655 } else if (ndo
->ndo_vflag
>= 2) { /* if verbose output is specified */
656 /* at the command line */
658 case SCTP_PPID_M3UA
:
659 m3ua_print(ndo
, bp
, payload_size
);
662 ND_PRINT((ndo
, "[Payload"));
663 if (!ndo
->ndo_suppress_default_print
) {
664 ND_PRINT((ndo
, ":"));
665 ND_DEFAULTPRINT(bp
, payload_size
);
667 ND_PRINT((ndo
, "]"));
672 sctpPacketLengthRemaining
-= payload_size
;
673 chunkLengthRemaining
-= payload_size
;
676 case SCTP_INITIATION
:
678 const struct sctpInitiation
*init
;
680 if (chunkLengthRemaining
< sizeof(*init
)) {
681 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
684 init
=(const struct sctpInitiation
*)bp
;
685 ND_PRINT((ndo
, "[init tag: %u] ", EXTRACT_32BITS(&init
->initTag
)));
686 ND_PRINT((ndo
, "[rwnd: %u] ", EXTRACT_32BITS(&init
->rcvWindowCredit
)));
687 ND_PRINT((ndo
, "[OS: %u] ", EXTRACT_16BITS(&init
->NumPreopenStreams
)));
688 ND_PRINT((ndo
, "[MIS: %u] ", EXTRACT_16BITS(&init
->MaxInboundStreams
)));
689 ND_PRINT((ndo
, "[init TSN: %u] ", EXTRACT_32BITS(&init
->initialTSN
)));
691 sctpPacketLengthRemaining
-= sizeof(*init
);
692 chunkLengthRemaining
-= sizeof(*init
);
694 #if(0) /* ALC you can add code for optional params here */
695 if( chunkLengthRemaining
!= 0 )
696 ND_PRINT((ndo
, " @@@@@ UNFINISHED @@@@@@%s\n",
697 "Optional params present, but not printed."));
699 bp
+= chunkLengthRemaining
;
700 sctpPacketLengthRemaining
-= chunkLengthRemaining
;
701 chunkLengthRemaining
= 0;
704 case SCTP_INITIATION_ACK
:
706 const struct sctpInitiation
*init
;
708 if (chunkLengthRemaining
< sizeof(*init
)) {
709 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
712 init
=(const struct sctpInitiation
*)bp
;
713 ND_PRINT((ndo
, "[init tag: %u] ", EXTRACT_32BITS(&init
->initTag
)));
714 ND_PRINT((ndo
, "[rwnd: %u] ", EXTRACT_32BITS(&init
->rcvWindowCredit
)));
715 ND_PRINT((ndo
, "[OS: %u] ", EXTRACT_16BITS(&init
->NumPreopenStreams
)));
716 ND_PRINT((ndo
, "[MIS: %u] ", EXTRACT_16BITS(&init
->MaxInboundStreams
)));
717 ND_PRINT((ndo
, "[init TSN: %u] ", EXTRACT_32BITS(&init
->initialTSN
)));
719 sctpPacketLengthRemaining
-= sizeof(*init
);
720 chunkLengthRemaining
-= sizeof(*init
);
722 #if(0) /* ALC you can add code for optional params here */
723 if( chunkLengthRemaining
!= 0 )
724 ND_PRINT((ndo
, " @@@@@ UNFINISHED @@@@@@%s\n",
725 "Optional params present, but not printed."));
727 bp
+= chunkLengthRemaining
;
728 sctpPacketLengthRemaining
-= chunkLengthRemaining
;
729 chunkLengthRemaining
= 0;
732 case SCTP_SELECTIVE_ACK
:
734 const struct sctpSelectiveAck
*sack
;
735 const struct sctpSelectiveFrag
*frag
;
737 const u_char
*dupTSN
;
739 if (chunkLengthRemaining
< sizeof(*sack
)) {
740 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
743 sack
=(const struct sctpSelectiveAck
*)bp
;
744 ND_PRINT((ndo
, "[cum ack %u] ", EXTRACT_32BITS(&sack
->highestConseqTSN
)));
745 ND_PRINT((ndo
, "[a_rwnd %u] ", EXTRACT_32BITS(&sack
->updatedRwnd
)));
746 ND_PRINT((ndo
, "[#gap acks %u] ", EXTRACT_16BITS(&sack
->numberOfdesc
)));
747 ND_PRINT((ndo
, "[#dup tsns %u] ", EXTRACT_16BITS(&sack
->numDupTsns
)));
749 sctpPacketLengthRemaining
-= sizeof(*sack
);
750 chunkLengthRemaining
-= sizeof(*sack
);
755 chunkLengthRemaining
!= 0 && fragNo
< EXTRACT_16BITS(&sack
->numberOfdesc
);
756 bp
+= sizeof(*frag
), sctpPacketLengthRemaining
-= sizeof(*frag
), chunkLengthRemaining
-= sizeof(*frag
), fragNo
++) {
757 if (chunkLengthRemaining
< sizeof(*frag
)) {
758 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
761 frag
= (const struct sctpSelectiveFrag
*)bp
;
762 ND_PRINT((ndo
, "\n\t\t[gap ack block #%d: start = %u, end = %u] ",
764 EXTRACT_32BITS(&sack
->highestConseqTSN
) + EXTRACT_16BITS(&frag
->fragmentStart
),
765 EXTRACT_32BITS(&sack
->highestConseqTSN
) + EXTRACT_16BITS(&frag
->fragmentEnd
)));
768 /* print duplicate TSNs */
770 chunkLengthRemaining
!= 0 && tsnNo
<EXTRACT_16BITS(&sack
->numDupTsns
);
771 bp
+= 4, sctpPacketLengthRemaining
-= 4, chunkLengthRemaining
-= 4, tsnNo
++) {
772 if (chunkLengthRemaining
< 4) {
773 ND_PRINT((ndo
, "bogus chunk length %u]", chunkLength
));
776 dupTSN
= (const u_char
*)bp
;
777 ND_PRINT((ndo
, "\n\t\t[dup TSN #%u: %u] ", tsnNo
+1,
778 EXTRACT_32BITS(dupTSN
)));
784 bp
+= chunkLengthRemaining
;
785 sctpPacketLengthRemaining
-= chunkLengthRemaining
;
786 chunkLengthRemaining
= 0;
792 * Any extra stuff at the end of the chunk?
795 bp
+= chunkLengthRemaining
;
796 sctpPacketLengthRemaining
-= chunkLengthRemaining
;
798 if (ndo
->ndo_vflag
< 2)
803 * Fail if the alignment padding isn't in the captured data.
804 * Otherwise, skip it.
806 ND_TCHECK2(*bp
, align
);
808 sctpPacketLengthRemaining
-= align
;
814 ND_PRINT((ndo
, "[|sctp]"));