@@ -23,7 +23,7 @@ const (
2323 modeServer
2424)
2525
26- // Conn represents a M3UA connection, which satisfies standard net.Conn interface.
26+ // Conn represents a M3UA connection, which satisfies the standard net.Conn interface.
2727type Conn struct {
2828 // maxMessageStreamID is the maximum negotiated sctp stream ID used,
2929 // must not be zero, must vary from 1 to maxMessageStreamID
@@ -40,15 +40,11 @@ type Conn struct {
4040 established chan struct {}
4141 // beatAckChan notifies that heartbeat gets the ack as expected
4242 beatAckChan chan struct {}
43- // dataChan is to pass the ProtocolDataPayload(=payload on M3UA DATA) to user
43+ // dataChan is to pass the ProtocolDataPayload(=payload on M3UA DATA) to the user
4444 dataChan chan * params.ProtocolDataPayload
45- // errChan is to pass errors to goroutine that monitors status
45+ // errChan is to pass errors to a goroutine that monitors status
4646 errChan chan error
47- // sctpConn is the underlying SCTP association
48- sctpConn * sctp.SCTPConn
49- // sctpInfo is SndRcvInfo in SCTP association
50- sctpInfo * sctp.SndRcvInfo
51- // cfg is a configuration that is required to communicate between M3UA endpoints
47+ // cfg is a configuration required to communicate between M3UA endpoints
5248 cfg * Config
5349 // Condition to allow heartbeat, only after the state is AspUp
5450 beatAllow * sync.Cond
@@ -126,9 +122,9 @@ func (c *Conn) WriteToStream(b []byte, streamID uint16) (n int, err error) {
126122 }
127123
128124 // taken by value to avoid race condition on the stream id
129- info := * c .sctpInfo
125+ info := * c .cfg . SCTPConfig . sctpInfo
130126 info .Stream = streamID
131- n , err = c .sctpConn .SCTPWrite (d , & info )
127+ n , err = c .cfg . SCTPConfig . sctpConn .SCTPWrite (d , & info )
132128 if err != nil {
133129 return 0 , err
134130 }
@@ -160,9 +156,9 @@ func (c *Conn) WritePDToStream(protocolData *params.Param, streamID uint16) (n i
160156 }
161157
162158 // taken by value to avoid race condition on the stream id
163- info := * c .sctpInfo
159+ info := * c .cfg . SCTPConfig . sctpInfo
164160 info .Stream = streamID
165- n , err = c .sctpConn .SCTPWrite (d , & info )
161+ n , err = c .cfg . SCTPConfig . sctpConn .SCTPWrite (d , & info )
166162 if err != nil {
167163 return 0 , err
168164 }
@@ -180,12 +176,12 @@ func (c *Conn) WriteSignal(m3 messages.M3UA) (n int, err error) {
180176 }
181177
182178 // taken by value to avoid race condition on the stream id
183- sctpInfo := * c .sctpInfo
179+ sctpInfo := * c .cfg . SCTPConfig . sctpInfo
184180 if m3 .MessageClass () != messages .MsgClassTransfer {
185181 sctpInfo .Stream = 0
186182 }
187183
188- nn , err := c .sctpConn .SCTPWrite (buf , & sctpInfo )
184+ nn , err := c .cfg . SCTPConfig . sctpConn .SCTPWrite (buf , & sctpInfo )
189185 if err != nil {
190186 return 0 , fmt .Errorf ("failed to write M3UA: %w" , err )
191187 }
@@ -200,39 +196,39 @@ func (c *Conn) Close() error {
200196 defer c .muState .Unlock ()
201197
202198 if c .state == StateAspDown {
203- return c .sctpConn .Close ()
199+ return c .cfg . SCTPConfig . sctpConn .Close ()
204200 }
205201
206202 close (c .established )
207203 close (c .beatAckChan )
208204 close (c .dataChan )
209205 c .state = StateAspDown
210- return c .sctpConn .Close ()
206+ return c .cfg . SCTPConfig . sctpConn .Close ()
211207}
212208
213209// LocalAddr returns the local network address.
214210func (c * Conn ) LocalAddr () net.Addr {
215- return c .sctpConn .LocalAddr ()
211+ return c .cfg . SCTPConfig . sctpConn .LocalAddr ()
216212}
217213
218214// RemoteAddr returns the remote network address.
219215func (c * Conn ) RemoteAddr () net.Addr {
220- return c .sctpConn .RemoteAddr ()
216+ return c .cfg . SCTPConfig . sctpConn .RemoteAddr ()
221217}
222218
223219// SetDeadline sets the read and write deadlines associated.
224220func (c * Conn ) SetDeadline (t time.Time ) error {
225- return c .sctpConn .SetDeadline (t )
221+ return c .cfg . SCTPConfig . sctpConn .SetDeadline (t )
226222}
227223
228224// SetReadDeadline sets the deadline for future Read calls.
229225func (c * Conn ) SetReadDeadline (t time.Time ) error {
230- return c .sctpConn .SetReadDeadline (t )
226+ return c .cfg . SCTPConfig . sctpConn .SetReadDeadline (t )
231227}
232228
233229// SetWriteDeadline sets the deadline for future Write calls.
234230func (c * Conn ) SetWriteDeadline (t time.Time ) error {
235- return c .sctpConn .SetWriteDeadline (t )
231+ return c .cfg . SCTPConfig . sctpConn .SetWriteDeadline (t )
236232}
237233
238234// State returns current state of Conn.
@@ -244,7 +240,7 @@ func (c *Conn) State() State {
244240
245241// StreamID returns sctpInfo.Stream of Conn.
246242func (c * Conn ) StreamID () uint16 {
247- return c .sctpInfo .Stream
243+ return c .cfg . SCTPConfig . sctpInfo .Stream
248244}
249245
250246// MaxMessageStreamID returns the maximum negotiated sctp stream ID
@@ -264,7 +260,7 @@ func (c *Conn) MaxMessageStreamID() uint16 {
264260//
265261// Note: sackDelay=0, sackFrequency=1 (disables delayed SACK)
266262func (c * Conn ) SetSctpSackConfig (sackDelay , sackFrequency uint32 ) error {
267- return c .sctpConn .SetSackTimer (& sctp.SackTimer {
263+ return c .cfg . SCTPConfig . sctpConn .SetSackTimer (& sctp.SackTimer {
268264 SackDelay : sackDelay ,
269265 SackFrequency : sackFrequency ,
270266 })
0 commit comments