示例#1
0
文件: libdmt.go 项目: bhepp/cgrates
// debitInterval is the configured debitInterval, in sync with the diameter client one
func NewCCRFromDiameterMessage(m *diam.Message, debitInterval time.Duration) (*CCR, error) {
	var ccr CCR
	if err := m.Unmarshal(&ccr); err != nil {
		return nil, err
	}
	ccr.diamMessage = m
	ccr.debitInterval = debitInterval
	return &ccr, nil
}
示例#2
0
// Parse parses and validates the given message, and returns nil when
// all AVPs are ok.
func (dwr *DWR) Parse(m *diam.Message) error {
	err := m.Unmarshal(dwr)
	if err != nil {
		return nil
	}
	if err = dwr.sanityCheck(); err != nil {
		return err
	}
	return nil
}
示例#3
0
// Parse parses and validates the given message.
func (cea *CEA) Parse(m *diam.Message) (err error) {
	if err = m.Unmarshal(cea); err != nil {
		return err
	}
	if err = cea.sanityCheck(); err != nil {
		return err
	}
	app := &Application{
		AcctApplicationID:           cea.AcctApplicationID,
		AuthApplicationID:           cea.AuthApplicationID,
		VendorSpecificApplicationID: cea.VendorSpecificApplicationID,
	}
	if _, err := app.Parse(m.Dictionary()); err != nil {
		return err
	}
	cea.appID = app.ID()
	return nil
}
示例#4
0
// Parse parses and validates the given message, and returns nil when
// all AVPs are ok, and all accounting or authentication applications
// in the CER match the applications in our dictionary. If one or more
// mandatory AVPs are missing, it returns a nil failedAVP and a proper
// error. If all mandatory AVPs are present but no common application
// is found, then it returns the failedAVP (with the application that
// we don't support in our dictionary) and an error. Another cause
// for error is the presence of Inband Security, we don't support that.
func (cer *CER) Parse(m *diam.Message) (failedAVP *diam.AVP, err error) {
	if err = m.Unmarshal(cer); err != nil {
		return nil, err
	}
	if err = cer.sanityCheck(); err != nil {
		return nil, err
	}
	if cer.InbandSecurityID != nil {
		if v := cer.InbandSecurityID.Data.(datatype.Unsigned32); v != 0 {
			return cer.InbandSecurityID, ErrNoCommonSecurity
		}
	}
	app := &Application{
		AcctApplicationID:           cer.AcctApplicationID,
		AuthApplicationID:           cer.AuthApplicationID,
		VendorSpecificApplicationID: cer.VendorSpecificApplicationID,
	}
	if failedAVP, err = app.Parse(m.Dictionary()); err != nil {
		return failedAVP, err
	}
	cer.appID = app.ID()
	return nil, nil
}
示例#5
0
// Parse parses the given message.
func (dwa *DWA) Parse(m *diam.Message) error {
	if err := m.Unmarshal(dwa); err != nil {
		return err
	}
	return nil
}