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

Customizable dictionary and list of supported applications for CEA #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yoone
Copy link
Contributor

@Yoone Yoone commented Nov 13, 2020

I need to specify the list of actual Application IDs / Vendor IDs my equipment actually supports. In order to do so, I had to override the existing Default dict, which isn't possible everywhere, namely in the default StateMachine creation (sm.New uses dict.Default).

On top of that, declaring a new *dict.Parser is cumbersome since all I want is to use the default one but with less interfaces. So I made all the default XML dicts public, and added a helper to initialize a dictionary using those.

With the changes in the PR, one can now change the default dict (and associated Application IDs / Vendor IDs) this way, reusing the dictionaries already declared in go-diameter:

import (
    "github.com/fiorix/go-diameter/v4/diam/dict"
    "github.com/fiorix/go-diameter/v4/diam/dict/library"
    "github.com/fiorix/go-diameter/v4/diam/sm"
)

dictionary, err := dict.NewParserFromLibrary(
    library.Base,
    library.CreditControl,
    library.TgppRoRf,
)
if err != nil { ... }

settings := &sm.Settings{
    // some settings
    Dictionary: dictionary,
}
stateMachine := sm.New(settings)

I did move all the XML (some 6k lines) to a new package because I believed it made more sense with the new structure, but I can revert that and make my changes in place if that's better.

Copy link
Collaborator

@emakeev emakeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dictionary .go files are generated from dictionaty definition XML files in https://github.com/fiorix/go-diameter/tree/master/diam/dict/testdata by this script: https://github.com/fiorix/go-diameter/blob/master/diam/autogen.sh

This PR does not take it into account and will break the ability to autogenerate dictionaries.

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

Successfully merging this pull request may close these issues.

2 participants