forked from fiorix/go-diameter
/
dwa.go
34 lines (30 loc) · 751 Bytes
/
dwa.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
// Copyright 2013-2015 go-diameter authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package sm
import (
"github.com/fiorix/go-diameter/diam"
"github.com/fiorix/go-diameter/diam/sm/smparser"
)
var dwaACK = struct{}{}
// handleDWA handles Device-Watchdog-Answer messages.
func handleDWA(sm *StateMachine, dwac chan struct{}) diam.HandlerFunc {
return func(c diam.Conn, m *diam.Message) {
dwa := new(smparser.DWA)
if err := dwa.Parse(m); err != nil {
sm.Error(&diam.ErrorReport{
Conn: c,
Message: m,
Error: err,
})
return
}
if dwa.ResultCode != diam.Success {
return
}
select {
case dwac <- dwaACK:
default:
}
}
}