-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sctp.Association.Abort(reason string) method
According to RFC 4960. Also see my comment at #176. Closes #182. I don't think we currently do any tag verification for any packets, but we can implement that later.
- Loading branch information
Showing
4 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sctp | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
/* | ||
This error cause MAY be included in ABORT chunks that are sent | ||
because of an upper-layer request. The upper layer can specify an | ||
Upper Layer Abort Reason that is transported by SCTP transparently | ||
and MAY be delivered to the upper-layer protocol at the peer. | ||
0 1 2 3 | ||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
| Cause Code=12 | Cause Length=Variable | | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
/ Upper Layer Abort Reason / | ||
\ \ | ||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
*/ | ||
type errorCauseUserInitiatedAbort struct { | ||
errorCauseHeader | ||
upperLayerAbortReason []byte | ||
} | ||
|
||
func (e *errorCauseUserInitiatedAbort) marshal() ([]byte, error) { | ||
e.code = userInitiatedAbort | ||
e.errorCauseHeader.raw = e.upperLayerAbortReason | ||
return e.errorCauseHeader.marshal() | ||
} | ||
|
||
func (e *errorCauseUserInitiatedAbort) unmarshal(raw []byte) error { | ||
err := e.errorCauseHeader.unmarshal(raw) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
e.upperLayerAbortReason = e.errorCauseHeader.raw | ||
return nil | ||
} | ||
|
||
// String makes errorCauseUserInitiatedAbort printable | ||
func (e *errorCauseUserInitiatedAbort) String() string { | ||
return fmt.Sprintf("%s: %s", e.errorCauseHeader.String(), e.upperLayerAbortReason) | ||
} |