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

Fix/vendor specific application #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,27 @@ Configurations

### Diameter Config

| Field Name | Type | Description |
| ------------------------------ | ----------------------------- | -----------------------------------------------------------------------------|
| RequestTimeout | duration | Timeout for each request |
| MaxRetransmits | number | Maximum number of message retransmissions |
| RetransmitInterval | duration | Interval between message retransmissions |
| EnableWatchdog | boolean | Flag to enable automatic DWR (Diameter Watchdog Request) |
| WatchdogInterval | duration | Interval between sending DWRs |
| WatchdogStream | number | Stream ID for sending DWRs (for multistreaming protocols) |
| SupportedVendorID | number array | List of supported vendor IDs |
| AcctApplicationID | number array | List of accounting application IDs |
| AuthApplicationID | number array | List of authentication application IDs |
| VendorSpecificApplicationID | number array | List of vendor-specific application IDs |
| CapabilityExchange | object | Configuration for capability exchange |
| TransportProtocol | string | Transport layer protocol to use, either "tcp" or "sctp". Defaults to "tcp" |
| Field Name | Type | Description |
|-----------------------------|--------------|----------------------------------------------------------------------------|
| RequestTimeout | duration | Timeout for each request |
| MaxRetransmits | number | Maximum number of message retransmissions |
| RetransmitInterval | duration | Interval between message retransmissions |
| EnableWatchdog | boolean | Flag to enable automatic DWR (Diameter Watchdog Request) |
| WatchdogInterval | duration | Interval between sending DWRs |
| WatchdogStream | number | Stream ID for sending DWRs (for multistreaming protocols) |
| SupportedVendorID | number array | List of supported vendor IDs |
| AcctApplicationID | number array | List of accounting application IDs |
| AuthApplicationID | number array | List of authentication application IDs |
| VendorSpecificApplicationID | object | List of vendor-specific application IDs |
| CapabilityExchange | object | Configuration for capability exchange |
| TransportProtocol | string | Transport layer protocol to use, either "tcp" or "sctp". Defaults to "tcp" |

### Vendor Specific Application Id Config
| Field Name | Type | Description |
|-------------------|--------|---------------------|
| VendorID | number | Vendor ID |
| AuthApplicationID | number | Auth Application ID |
| AcctApplicationID | number | Acct Application ID |

### Capability Exchange Config

Expand All @@ -118,6 +125,12 @@ let client = diam.Client({
requestTimeout: "50ms",
enableWatchdog: false,
authApplicationId: [app.ChargingControl],
vendorSpecificApplicationId: [
{
authApplicationId: app.ChargingControl,
vendorId: vendor.TGPP,
}
],
capabilityExchange: {
vendorId: 35838,
},
Expand Down
32 changes: 19 additions & 13 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ import (
)

type DiameterConfig struct {
RequestTimeout *Duration `json:"requestTimeout,omitempty"`
MaxRetransmits *uint `json:"maxRetransmits,omitempty"`
RetransmitInterval *Duration `json:"retransmitInterval,omitempty"`
EnableWatchdog *bool `json:"enableWatchdog,omitempty"`
WatchdogInterval *Duration `json:"watchdogInterval,omitempty"`
WatchdogStream *uint `json:"watchdogStream,omitempty"`
SupportedVendorID *[]uint32 `json:"supportedVendorID,omitempty"`
AcctApplicationID *[]uint32 `json:"acctApplicationId,omitempty"`
AuthApplicationId *[]uint32 `json:"authApplicationId,omitempty"`
VendorSpecificApplicationID *[]uint32 `json:"vendorSpecificApplicationId,omitempty"`
TransportProtocol *string `josn:"transportProtocol,omitempty"`
CapabilityExchange *CapabilityExchangeConfig `json:"capabilityExchange,omitempty"`
RequestTimeout *Duration `json:"requestTimeout,omitempty"`
MaxRetransmits *uint `json:"maxRetransmits,omitempty"`
RetransmitInterval *Duration `json:"retransmitInterval,omitempty"`
EnableWatchdog *bool `json:"enableWatchdog,omitempty"`
WatchdogInterval *Duration `json:"watchdogInterval,omitempty"`
WatchdogStream *uint `json:"watchdogStream,omitempty"`
SupportedVendorID *[]uint32 `json:"supportedVendorID,omitempty"`
AcctApplicationID *[]uint32 `json:"acctApplicationId,omitempty"`
AuthApplicationId *[]uint32 `json:"authApplicationId,omitempty"`
VendorSpecificApplicationID *[]VendorSpecificApplicationIDConfig `json:"vendorSpecificApplicationId,omitempty"`
TransportProtocol *string `josn:"transportProtocol,omitempty"`
CapabilityExchange *CapabilityExchangeConfig `json:"capabilityExchange,omitempty"`
}

type VendorSpecificApplicationIDConfig struct {
VendorID *uint32 `json:"vendorId,omitempty"`
AuthApplicationID *uint32 `json:"authApplicationId,omitempty"`
AcctApplicationID *uint32 `json:"acctApplicationId,omitempty"`
}

type CapabilityExchangeConfig struct {
Expand Down Expand Up @@ -64,7 +70,7 @@ func setDiameterConfigDefaults(config *DiameterConfig) {
var defaultSupportedVendorID = []uint32{}
var defaultAcctApplicationID = []uint32{}
var defaultAuthApplicationID = []uint32{}
var defaultVendorSpecificApplicationID = []uint32{}
var defaultVendorSpecificApplicationID = []VendorSpecificApplicationIDConfig{}
var defaultTransportProtocol = "tcp"

// Set defaults for DiameterConfig
Expand Down
21 changes: 19 additions & 2 deletions diameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,25 @@ func (*Diameter) XClient(arg map[string]interface{}) (*DiameterClient, error) {
}

VendorSpecificApplicationID := []*diam.AVP{}
for _, appID := range *config.VendorSpecificApplicationID {
VendorSpecificApplicationID = append(VendorSpecificApplicationID, diam.NewAVP(avp.VendorSpecificApplicationID, avp.Mbit, 0, datatype.Unsigned32(appID)))
for _, vendorSpecificApplicationId := range *config.VendorSpecificApplicationID {
avps := []*diam.AVP{}

if vendorSpecificApplicationId.AuthApplicationID != nil {
authApplicationID := vendorSpecificApplicationId.AuthApplicationID
avps = append(avps, diam.NewAVP(avp.AuthApplicationID, avp.Mbit, 0, datatype.Unsigned32(*authApplicationID)))
}

if vendorSpecificApplicationId.AcctApplicationID != nil {
acctApplicationID := vendorSpecificApplicationId.AcctApplicationID
avps = append(avps, diam.NewAVP(avp.AcctApplicationID, avp.Mbit, 0, datatype.Unsigned32(*acctApplicationID)))
}

if vendorSpecificApplicationId.VendorID != nil {
vendorID := vendorSpecificApplicationId.VendorID
avps = append(avps, diam.NewAVP(avp.VendorID, avp.Mbit, 0, datatype.Unsigned32(*vendorID)))
}

VendorSpecificApplicationID = append(VendorSpecificApplicationID, diam.NewAVP(avp.VendorSpecificApplicationID, avp.Mbit, 0, &diam.GroupedAVP{AVP: avps}))
}

client := &sm.Client{
Expand Down
6 changes: 6 additions & 0 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ let client = diam.Client({
requestTimeout: "50ms",
enableWatchdog: false,
authApplicationId: [app.ChargingControl],
vendorSpecificApplicationId: [
{
authApplicationId: app.ChargingControl,
vendorId: vendor.TGPP,
}
],
capabilityExchange: {
vendorId: 35838,
},
Expand Down