Skip to content

Commit

Permalink
Handle all Application Id
Browse files Browse the repository at this point in the history
  • Loading branch information
lwlee2608 committed Nov 20, 2023
1 parent 80601d9 commit f3a396a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
11 changes: 11 additions & 0 deletions cmd/dict_generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ func main() {
defer w.Close()

PrintCmd(w)
PrintAppId(w)
PrintFlags(w)
PrintAvpCode(w, parser)
PrintVendorId(w, parser)
}

func PrintAppId(w io.Writer) {
fmt.Fprintf(w, "export const appId = {\n")
fmt.Fprintf(w, " %-35s %d,\n", "Accounting:", 3)
fmt.Fprintf(w, " %-35s %d,\n", "ChargingControl:", 4)
fmt.Fprintf(w, " %-35s %d,\n", "Gx:", 16777238)
fmt.Fprintf(w, " %-35s %d,\n", "Sy:", 16777302)
fmt.Fprintf(w, "}\n")
fmt.Fprintf(w, "\n")
}

func PrintCmd(w io.Writer) {
fmt.Fprintf(w, "export const cmd = {\n")
fmt.Fprintf(w, " %-35s %d,\n", "AA:", 265)
Expand Down
4 changes: 2 additions & 2 deletions diameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func (c *DiameterClient) Send(msg *DiameterMessage) (uint32, error) {
return uint32(resultCode), nil
}

func (*Diameter) NewMessage(cmd uint32) *DiameterMessage {
func (*Diameter) NewMessage(cmd uint32, appid uint32) *DiameterMessage {
return &DiameterMessage{
diamMsg: diam.NewRequest(cmd, 4, dict.Default),
diamMsg: diam.NewRequest(cmd, appid, dict.Default),
}
}

Expand Down
7 changes: 7 additions & 0 deletions example/diam/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const cmd = {
SpendingLimit: 8388635,
}

export const appId = {
Accounting: 3,
ChargingControl: 4,
Gx: 16777238,
Sy: 16777302,
}

export const flags = {
Vbit: 0x80,
Mbit: 0x40,
Expand Down
4 changes: 2 additions & 2 deletions example/example.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import diam from 'k6/x/diameter'
import avp from 'k6/x/diameter/avp'
import dict from 'k6/x/diameter/dict'
import { cmd, avpCode, flags, vendorId } from './diam/const.js'
import { cmd, appId, avpCode, flags, vendorId } from './diam/const.js'

import { check } from 'k6'

Expand All @@ -22,7 +22,7 @@ let dataType = diam.DataType()
export default function () {
client.connect("localhost:3868")

let msg = diam.newMessage(cmd.CreditControl);
let msg = diam.newMessage(cmd.CreditControl, appId.ChargingControl);

msg.AVP(avpCode.OriginHost, 0, 0, dataType.DiameterIdentity("origin.host"))
msg.AVP(avpCode.OriginRealm, 0, 0, dataType.DiameterIdentity("origin.realm"))
Expand Down

0 comments on commit f3a396a

Please sign in to comment.