// validate ensures the given acct or auth application ID exists in // the given dictionary. func (app *Application) validate(d *dict.Parser, appType uint32, appAVP *diam.AVP) (failedAVP *diam.AVP, err error) { if appAVP == nil { return nil, nil } var typ string switch appType { case avp.AcctApplicationID: typ = "acct" case avp.AuthApplicationID: typ = "auth" } if appAVP.Code != appType { return appAVP, &ErrUnexpectedAVP{appAVP} } appID, ok := appAVP.Data.(datatype.Unsigned32) if !ok { return appAVP, &ErrUnexpectedAVP{appAVP} } id := uint32(appID) avp, err := d.App(id) if err != nil { return appAVP, &ErrNoCommonApplication{id, typ} } if len(avp.Type) > 0 && avp.Type != typ { return appAVP, &ErrNoCommonApplication{id, typ} } app.id = append(app.id, id) return nil, nil }