-
Notifications
You must be signed in to change notification settings - Fork 26
/
aspsm.go
78 lines (63 loc) · 1.62 KB
/
aspsm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2018-2024 go-m3ua authors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
package m3ua
import "github.com/wmnsk/go-m3ua/messages"
func (c *Conn) initiateASPSM() error {
if _, err := c.WriteSignal(
messages.NewAspUp(c.cfg.AspIdentifier, nil),
); err != nil {
return err
}
return nil
}
func (c *Conn) handleAspUp(aspUp *messages.AspUp) error {
if c.state != StateAspDown {
return NewErrUnexpectedMessage(aspUp)
}
if c.sctpInfo.Stream != 0 {
return NewErrInvalidSCTPStreamID(c.sctpInfo.Stream)
}
if _, err := c.WriteSignal(
messages.NewAspUpAck(
c.cfg.AspIdentifier,
nil,
),
); err != nil {
return err
}
return nil
}
func (c *Conn) handleAspUpAck(aspUpAck *messages.AspUpAck) error {
if c.state != StateAspDown {
return NewErrUnexpectedMessage(aspUpAck)
}
if c.sctpInfo.Stream != 0 {
return NewErrInvalidSCTPStreamID(c.sctpInfo.Stream)
}
return nil
}
func (c *Conn) handleAspDown(aspDown *messages.AspDown) error {
switch c.state {
case StateAspInactive, StateAspActive:
return NewErrUnexpectedMessage(aspDown)
}
if c.sctpInfo.Stream != 0 {
return NewErrInvalidSCTPStreamID(c.sctpInfo.Stream)
}
// XXX - Validate the params.
if _, err := c.WriteSignal(messages.NewAspDownAck(nil)); err != nil {
return err
}
return nil
}
func (c *Conn) handleAspDownAck(aspDownAck *messages.AspDownAck) error {
switch c.state {
case StateAspInactive, StateAspActive:
return NewErrUnexpectedMessage(aspDownAck)
}
if c.sctpInfo.Stream != 0 {
return NewErrInvalidSCTPStreamID(c.sctpInfo.Stream)
}
return nil
}