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: rfc3162.FrameInterfaceID is 10 byte, ifid only 8byte, can not use #126

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
OS?=
CMD_BUILD=GOOS=${OS} go build
VENDORS=huawei zte

dictgen: cmd/radius-dict-gen/main.go
${CMD_BUILD} -o $@ $^

define GEN_DICT
./vendors/$(1)/generated.go : ./vendors/$(1)/dictionary.$(1)
./dictgen -output $$@ -package $(1) $$<
endef

$(foreach v, $(VENDORS), $(eval $(call GEN_DICT,$(v))))

gen: \
$(foreach v, $(VENDORS), ./vendors/$(v)/generated.go)


14 changes: 14 additions & 0 deletions attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package radius

import (
"errors"
"strconv"
)

// Type is the RADIUS attribute type.
type Type int

var _TypeName map[Type]string = map[Type]string{}

// TypeInvalid is a Type that can be used to represent an invalid RADIUS
// attribute type.
const TypeInvalid Type = -1
Expand Down Expand Up @@ -138,3 +141,14 @@ func AttributesEncodedLen(a Attributes) (int, error) {
}
return n, nil
}

func AddType(t Type, name string) {
_TypeName[t] = name
}

func (t Type) String() string {
if s, ok := _TypeName[t]; ok {
return s
}
return "Type(" + strconv.FormatUint(uint64(t), 10) + ")"
}
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type Client struct {
// InsecureSkipVerify controls whether the client should skip verifying
// response packets received.
InsecureSkipVerify bool

Timeout time.Duration
}

// DefaultClient is the RADIUS client used by the Exchange function.
Expand Down Expand Up @@ -98,6 +100,9 @@ func (c *Client) Exchange(ctx context.Context, packet *Packet, addr string) (*Pa

var incoming [MaxPacketLength]byte
for {
if c.Timeout > 0 {
conn.SetReadDeadline(time.Now().Add(c.Timeout))
}
n, err := conn.Read(incoming[:])
if err != nil {
select {
Expand Down
8 changes: 8 additions & 0 deletions dictionarygen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ func (g *Generator) Generate(dict *dictionary.Dictionary) ([]byte, error) {
p(&w, `)`)
}

p(&w)
p(&w, `func init() {`)
for _, attr := range attrs {
p(&w, ` radius.AddType(`, identifier(attr.Name), `_Type, "`, identifier(attr.Name), `")`)
}
p(&w, `}`)
p(&w)

for _, exAttr := range externalAttributes {
p(&w)
p(&w, `func init() {`)
Expand Down
44 changes: 44 additions & 0 deletions rfc2865/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions rfc2866/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rfc2867/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions rfc2868/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions rfc2869/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions rfc3162/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rfc3576/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rfc3580/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rfc4072/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rfc4372/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rfc4603/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rfc4675/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rfc4679/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rfc4818/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rfc4849/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions rfc5090/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rfc5176/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rfc5447/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions rfc5580/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading