Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting Subscription-Id AVP from incoming message #138

Open
m00zi opened this issue Jun 18, 2020 · 1 comment
Open

Extracting Subscription-Id AVP from incoming message #138

m00zi opened this issue Jun 18, 2020 · 1 comment

Comments

@m00zi
Copy link

m00zi commented Jun 18, 2020

Hi, In the coming diameter messages there are 2 subscription-ID with different Enumerated
1- datatype.Enumerated(0) datatype.UTF8String("<<>>")
2- datatype.Enumerated(1) datatype.UTF8String("<<>>")

I have the struct defined, and it is working fine, but since there are 2 SubscriptionID1, I can get the first one only, how I can get the IMSI too, which is the second one, here is the struct :

type SubscriptionID struct {
	SubscriptionIDType datatype.Enumerated `avp:"Subscription-Id-Type"`
	SubscriptionIDData datatype.UTF8String `avp:"Subscription-Id-Data"`
}
.
.
.
type CCR struct {
	SessionID                     datatype.UTF8String           `avp:"Session-Id"`
	OriginHost                    datatype.DiameterIdentity     `avp:"Origin-Host"`
	OriginRealm                   datatype.DiameterIdentity     `avp:"Origin-Realm"`
	DestinationRealm              datatype.DiameterIdentity     `avp:"Destination-Realm"`
	AuthApplicationID             datatype.Unsigned32           `avp:"Auth-Application-Id"`
	ServiceContextID              datatype.UTF8String           `avp:"Service-Context-Id"`
	CCRequestType                 datatype.Enumerated           `avp:"CC-Request-Type"`
	CCRequestNumber               datatype.Unsigned32           `avp:"CC-Request-Number"`
	DestinationHost               datatype.DiameterIdentity     `avp:"Destination-Host"`
	UserName                      string                        `avp:"User-Name"`
	OriginStateID                 datatype.Unsigned32           `avp:"Origin-State-Id"`
	EventTimestamp                datatype.Time                 `avp:"Event-Timestamp"`
	SubscriptionID1               SubscriptionID                `avp:"Subscription-Id"`
	SubscriptionID2               SubscriptionID                `avp:"Subscription-Id"`
	MultipleServicesIndicator     datatype.Enumerated           `avp:"Multiple-Services-Indicator"`
	MultipleServicesCreditControl MultipleServicesCreditControl `avp:"Multiple-Services-Credit-Control"`
	UserEquipmentInfo             UserEquipmentInfo             `avp:"User-Equipment-Info"`
	ServiceInformation            ServiceInformation            `avp:"Service-Information"`
	TerminationCause              datatype.Enumerated           `avp:"Termination-Cause"`
}
@vivl4725
Copy link

You can do like this

type CreditControlRequest struct {
// Code ...
    SubscriptionID []struct {
		SubscriptionIDType datatype.Enumerated `avp:"Subscription-Id-Type"`
		SubscriptionIDData string              `avp:"Subscription-Id-Data"`
    } `avp:"Subscription-Id"`
// Code ...
}

@k0teyk0

// GetIMSIAndMSISDN get imsi and msisdn from request data
func (ccr CreditControlRequest) GetIMSIAndMSISDN() (imsi string, msisdn string) {
	for _, sID := range ccr.SubscriptionID {
		switch sID.SubscriptionIDType {
		case 0:
			msisdn = sID.SubscriptionIDData
		case 1:
			imsi = sID.SubscriptionIDData
		default:
			continue
		}
	}

	return
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants