summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-01-12 14:18:00 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-01-24 08:18:50 +0900
commit549b7037381ec51d0c5b9a0abbe8f73000fda70c (patch)
tree40ed8a74f1b75990071b79e363e331887e7db51e /table/policy.go
parentb391322bcbf56d623ca0a6b667c026b92f1e9e4d (diff)
*: Use strconv.ParseUint instead of strconv.Atoi()
For the 32-bit platform compatibility. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/table/policy.go b/table/policy.go
index e1b7d690..a7d02b06 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -337,8 +337,8 @@ func NewPrefix(c config.Prefix) (*Prefix, error) {
return nil, fmt.Errorf("mask length range format is invalid")
}
// we've already checked the range is sane by regexp
- min, _ := strconv.Atoi(elems[1])
- max, _ := strconv.Atoi(elems[2])
+ min, _ := strconv.ParseUint(elems[1], 10, 8)
+ max, _ := strconv.ParseUint(elems[2], 10, 8)
p.MasklengthRangeMin = uint8(min)
p.MasklengthRangeMax = uint8(max)
}
@@ -716,25 +716,25 @@ func NewSingleAsPathMatch(arg string) *singleAsPathMatch {
onlyRe := regexp.MustCompile("^\\^([0-9]+)\\$$")
switch {
case leftMostRe.MatchString(arg):
- asn, _ := strconv.Atoi(leftMostRe.FindStringSubmatch(arg)[1])
+ asn, _ := strconv.ParseUint(leftMostRe.FindStringSubmatch(arg)[1], 10, 32)
return &singleAsPathMatch{
asn: uint32(asn),
mode: LEFT_MOST,
}
case originRe.MatchString(arg):
- asn, _ := strconv.Atoi(originRe.FindStringSubmatch(arg)[1])
+ asn, _ := strconv.ParseUint(originRe.FindStringSubmatch(arg)[1], 10, 32)
return &singleAsPathMatch{
asn: uint32(asn),
mode: ORIGIN,
}
case includeRe.MatchString(arg):
- asn, _ := strconv.Atoi(includeRe.FindStringSubmatch(arg)[1])
+ asn, _ := strconv.ParseUint(includeRe.FindStringSubmatch(arg)[1], 10, 32)
return &singleAsPathMatch{
asn: uint32(asn),
mode: INCLUDE,
}
case onlyRe.MatchString(arg):
- asn, _ := strconv.Atoi(onlyRe.FindStringSubmatch(arg)[1])
+ asn, _ := strconv.ParseUint(onlyRe.FindStringSubmatch(arg)[1], 10, 32)
return &singleAsPathMatch{
asn: uint32(asn),
mode: ONLY,
@@ -985,8 +985,8 @@ func ParseCommunity(arg string) (uint32, error) {
exp := regexp.MustCompile("(\\d+):(\\d+)")
elems := exp.FindStringSubmatch(arg)
if len(elems) == 3 {
- fst, _ := strconv.Atoi(elems[1])
- snd, _ := strconv.Atoi(elems[2])
+ fst, _ := strconv.ParseUint(elems[1], 10, 16)
+ snd, _ := strconv.ParseUint(elems[2], 10, 16)
return uint32(fst<<16 | snd), nil
}
for i, v := range bgp.WellKnownCommunityNameMap {