Exemple #1
0
// FromCEA creates a Metadata object from data in the CEA.
func FromCEA(cea *smparser.CEA) *Metadata {
	return &Metadata{
		OriginHost:   cea.OriginHost,
		OriginRealm:  cea.OriginRealm,
		Applications: cea.Applications(),
	}
}
Exemple #2
0
// handleCEA handles Capabilities-Exchange-Answer messages.
func handleCEA(sm *StateMachine, errc chan error) diam.HandlerFunc {
	return func(c diam.Conn, m *diam.Message) {
		cea := new(smparser.CEA)
		if err := cea.Parse(m); err != nil {
			errc <- err
			return
		}
		if cea.ResultCode != diam.Success {
			errc <- &ErrFailedResultCode{Code: cea.ResultCode}
			return
		}
		meta := smpeer.FromCEA(cea)
		c.SetContext(smpeer.NewContext(c.Context(), meta))
		// Notify about peer passing the handshake.
		select {
		case sm.hsNotifyc <- c:
		default:
		}
		// Done receiving and validating this CEA.
		close(errc)
	}
}