-
Notifications
You must be signed in to change notification settings - Fork 57
Add xxxFields for GroupIE in Release 17 #140
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
base: main
Are you sure you want to change the base?
Changes from all commits
66bce04
87659ce
0a69a8c
85970cf
c8a906e
ad91c00
53f7cbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,44 +10,60 @@ func NewAccessAvailabilityControlInformation(info *IE) *IE { | |||||
| } | ||||||
|
|
||||||
| // AccessAvailabilityControlInformation returns the IEs above AccessAvailabilityControlInformation if the type of IE matches. | ||||||
| func (i *IE) AccessAvailabilityControlInformation() ([]*IE, error) { | ||||||
| func (i *IE) AccessAvailabilityControlInformation() (*AccessAvailabilityControlInformationFields, error) { | ||||||
| switch i.Type { | ||||||
| case AccessAvailabilityControlInformation: | ||||||
| return ParseMultiIEs(i.Payload) | ||||||
| return ParseAccessAvailabilityControlInformationFields(i.Payload) | ||||||
| case CreateSRR: | ||||||
| ies, err := i.CreateSRR() | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| for _, x := range ies { | ||||||
| if x.Type == AccessAvailabilityControlInformation { | ||||||
| return x.AccessAvailabilityControlInformation() | ||||||
| } | ||||||
| if ies.AccessAvailabilityControlInformation != nil { | ||||||
| return ies.AccessAvailabilityControlInformation, nil | ||||||
| } | ||||||
| return nil, ErrIENotFound | ||||||
| case UpdateSRR: | ||||||
| ies, err := i.UpdateSRR() | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| for _, x := range ies { | ||||||
| if x.Type == AccessAvailabilityControlInformation { | ||||||
| return x.AccessAvailabilityControlInformation() | ||||||
| } | ||||||
| if ies.AccessAvailabilityControlInformation != nil { | ||||||
| return ies.AccessAvailabilityControlInformation, nil | ||||||
| } | ||||||
| return nil, ErrIENotFound | ||||||
| case SessionReport: | ||||||
| ies, err := i.SessionReport() | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| default: | ||||||
| return nil, &InvalidTypeError{Type: i.Type} | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // AccessAvailabilityControlInformationFields is a set of fields in CreateSSR IE. | ||||||
| // | ||||||
| // The contained fields are of type struct, as they are too complex to handle with | ||||||
| // existing (standard) types in Go. | ||||||
| type AccessAvailabilityControlInformationFields struct { | ||||||
| RequestedAccessAvailabilityInformation uint8 | ||||||
| } | ||||||
|
|
||||||
| func ParseAccessAvailabilityControlInformationFields(b []byte) (*AccessAvailabilityControlInformationFields, error) { | ||||||
|
|
||||||
| // Parse all IES heres | ||||||
|
Comment on lines
+49
to
+50
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
typo, but in the first place I don't think we need this comment, as it's obvious |
||||||
| ies, err := ParseMultiIEs(b) | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| a := &AccessAvailabilityControlInformationFields{} | ||||||
| for _, ie := range ies { | ||||||
| if ie == nil { | ||||||
| continue | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, each XxxFields structure should have |
||||||
| } | ||||||
| for _, x := range ies { | ||||||
| if x.Type == AccessAvailabilityControlInformation { | ||||||
| return x.AccessAvailabilityControlInformation() | ||||||
| if ie.Type == RequestedAccessAvailabilityInformation { | ||||||
| v, err := ie.RequestedAccessAvailabilityInformation() | ||||||
| if err != nil { | ||||||
| return a, err | ||||||
| } | ||||||
| a.RequestedAccessAvailabilityInformation = v | ||||||
| } | ||||||
| return nil, ErrIENotFound | ||||||
| default: | ||||||
| return nil, &InvalidTypeError{Type: i.Type} | ||||||
| } | ||||||
| return a, nil | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,10 +10,57 @@ func NewAccessAvailabilityReport(info *IE) *IE { | |||||
| } | ||||||
|
|
||||||
| // AccessAvailabilityReport returns the IEs above AccessAvailabilityReport if the type of IE matches. | ||||||
| func (i *IE) AccessAvailabilityReport() ([]*IE, error) { | ||||||
| func (i *IE) AccessAvailabilityReport() (*AccessAvailabilityReportFields, error) { | ||||||
| if i.Type != AccessAvailabilityReport { | ||||||
| return nil, &InvalidTypeError{Type: i.Type} | ||||||
| } | ||||||
| // Check if the ie.Parse have called or not | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which kind of situation it is already parsed and it is not? Clarifying that in the comment would definitely help devs in the future. |
||||||
| if len(i.ChildIEs) > 0 { | ||||||
| p := &AccessAvailabilityReportFields{} | ||||||
| if err := p.ParseIEs(i.ChildIEs...); err != nil { | ||||||
| return p, err | ||||||
| } | ||||||
| return p, nil | ||||||
| } | ||||||
| // If the ChildIEs not already parsed | ||||||
| return ParseAccessAvailabilityReportFields(i.Payload) | ||||||
| } | ||||||
|
|
||||||
| // AccessAvailabilityReportFields is a set of fields in AccessAvailabilityReport IE. | ||||||
| // | ||||||
| // The contained fields are of type struct, as they are too complex to handle with | ||||||
| // existing (standard) types in Go. | ||||||
| type AccessAvailabilityReportFields struct { | ||||||
| AccessAvailabilityInformation uint8 | ||||||
| } | ||||||
|
|
||||||
| // ParseAccessAvailabilityReportFields returns the IEs above AccessAvailabilityReport | ||||||
| func ParseAccessAvailabilityReportFields(b []byte) (*AccessAvailabilityReportFields, error) { | ||||||
| ies, err := ParseMultiIEs(b) | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
| c := &AccessAvailabilityReportFields{} | ||||||
| if err := c.ParseIEs(ies...); err != nil { | ||||||
| return c, err | ||||||
| } | ||||||
|
|
||||||
| return ParseMultiIEs(i.Payload) | ||||||
| return c, nil | ||||||
| } | ||||||
|
|
||||||
| // ParseIEs will iterator over all childs IE to avoid to use Parse or ParseMultiIEs any time we iterate in IE | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
typo, but is it necessary for this function to be exported? |
||||||
| func (s *AccessAvailabilityReportFields) ParseIEs(ies ...*IE) error { | ||||||
| for _, i := range ies { | ||||||
| if i == nil { | ||||||
| continue | ||||||
| } | ||||||
| if i.Type == AccessAvailabilityInformation { | ||||||
| v, err := i.AccessAvailabilityInformation() | ||||||
| if err != nil { | ||||||
| return nil | ||||||
| } | ||||||
| s.AccessAvailabilityInformation = v | ||||||
| } | ||||||
| } | ||||||
| return nil | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,21 +19,17 @@ func (i *IE) ActivatePredefinedRules() (string, error) { | |
| if err != nil { | ||
| return "", err | ||
| } | ||
| for _, x := range ies { | ||
| if x.Type == ActivatePredefinedRules { | ||
| return x.ActivatePredefinedRules() | ||
| } | ||
| if len(ies.ActivatePredefinedRules) > 0 { | ||
| return ies.ActivatePredefinedRules, nil | ||
|
Comment on lines
+22
to
+23
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We return |
||
| } | ||
| return "", ErrIENotFound | ||
| case UpdatePDR: | ||
| ies, err := i.UpdatePDR() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| for _, x := range ies { | ||
| if x.Type == ActivatePredefinedRules { | ||
| return x.ActivatePredefinedRules() | ||
| } | ||
| if len(ies.ActivatePredefinedRules) > 0 { | ||
| return ies.ActivatePredefinedRules, nil | ||
| } | ||
| return "", ErrIENotFound | ||
| default: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| package ie | ||
|
|
||
| // NewAddMBSUnicastParameters creates a new AbsMBSUnicastParameters IE. | ||
| func NewAddMBSUnicastParameters(ies ...*IE) *IE { | ||
| return newGroupedIE(AddMBSUnicastParameters, 0, ies...) | ||
| } | ||
|
|
||
| // AddMBSUnicastParameters returns the IEs above AddMBSUnicastParameters if the type of IE matches. | ||
| func (i *IE) AddMBSUnicastParameters() (*AddMBSUnicastParametersFields, error) { | ||
| switch i.Type { | ||
| case AddMBSUnicastParameters: | ||
| return ParseAddMBSUnicastParametersFields(i.Payload) | ||
| case CreateFAR: | ||
| ies, err := i.CreateFAR() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| for _, i := range ies.AddMBSUnicastParameters { | ||
| if i == nil { | ||
| continue | ||
| } | ||
| return i, nil | ||
| } | ||
| return nil, ErrIENotFound | ||
| case UpdateFAR: | ||
| ies, err := i.UpdateFAR() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| for _, i := range ies.AddMBSUnicastParameters { | ||
| if i == nil { | ||
| continue | ||
| } | ||
| return i, nil | ||
| } | ||
| return nil, ErrIENotFound | ||
| default: | ||
| return nil, &InvalidTypeError{Type: i.Type} | ||
| } | ||
| } | ||
|
|
||
| // AddMBSUnicastParametersFields is a set of fields in AddMBSUnicastParameters IE. | ||
| // | ||
| // The contained fields are of type struct, as they are too complex to handle with | ||
| // existing (standard) types in Go. | ||
| type AddMBSUnicastParametersFields struct { | ||
| DestinationInterface uint8 | ||
| MBSUnicastParametersID uint16 | ||
| NetworkInstance string | ||
| OuterHeaderCreation *OuterHeaderCreationFields | ||
| TransportLevelMarking uint16 | ||
| DestinationInterfaceType uint8 | ||
| } | ||
|
|
||
| // ParseAddMBSUnicastParametersFields returns the IEs above AddMBSUnicastParameters. | ||
| func ParseAddMBSUnicastParametersFields(b []byte) (*AddMBSUnicastParametersFields, error) { | ||
| ies, err := ParseMultiIEs(b) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| f := &AddMBSUnicastParametersFields{} | ||
| if err := f.ParseIEs(ies...); err != nil { | ||
| return f, err | ||
| } | ||
| return f, nil | ||
| } | ||
|
|
||
| // ParseIEs will iterator over all childs IE to avoid to use Parse or ParseMultiIEs any time we iterate in IE | ||
| func (a *AddMBSUnicastParametersFields) ParseIEs(ies ...*IE) error { | ||
| for _, ie := range ies { | ||
| if ie == nil { | ||
| continue | ||
| } | ||
|
|
||
| switch ie.Type { | ||
| case DestinationInterface: | ||
| dest, err := ie.DestinationInterface() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.DestinationInterface = dest | ||
| case MBSUnicastParametersID: | ||
| v, err := ie.MBSUnicastParametersID() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.MBSUnicastParametersID = v | ||
| case NetworkInstance: | ||
| v, err := ie.NetworkInstance() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.NetworkInstance = v | ||
| case OuterHeaderCreation: | ||
| creation, err := ie.OuterHeaderCreation() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.OuterHeaderCreation = creation | ||
| case TransportLevelMarking: | ||
| transport, err := ie.TransportLevelMarking() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.TransportLevelMarking = transport | ||
| case TGPPInterfaceType: | ||
| tgppinterface, err := ie.TGPPInterfaceType() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| a.DestinationInterfaceType = tgppinterface | ||
| } | ||
| } | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing godoc comment