Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Relocation of ASN from ROA entries to ROA
Browse files Browse the repository at this point in the history
  • Loading branch information
lspgn committed Mar 1, 2019
1 parent 8a3320c commit 884306d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/api-validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func main() {

for _, entry := range roa.Valids {
oroa := OutputROA{
ASN: fmt.Sprintf("AS%v", entry.ASN),
ASN: fmt.Sprintf("AS%v", roa.ASN),
Prefix: entry.IPNet.String(),
MaxLength: entry.MaxLength,
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/localrpki/localrpki.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func main() {

for _, entry := range d.Valids {
oroa := OutputROA{
ASN: fmt.Sprintf("AS%v", entry.ASN),
ASN: fmt.Sprintf("AS%v", d.ASN),
Prefix: entry.IPNet.String(),
MaxLength: entry.MaxLength,
Path: manager.PathOfResource[roa].ComputePath(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/octorpki/octorpki.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ func (s *state) MainValidation() {

for _, entry := range roa.Valids {
oroa := prefixfile.ROAJson{
ASN: fmt.Sprintf("AS%v", entry.ASN),
ASN: fmt.Sprintf("AS%v", roa.ASN),
Prefix: entry.IPNet.String(),
Length: uint8(entry.MaxLength),
TA: talname,
Expand Down
14 changes: 7 additions & 7 deletions validator/lib/roa.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ type ROA struct {
}

type ROA_Entry struct {
ASN int
IPNet *net.IPNet
MaxLength int
}

type RPKI_ROA struct {
ASN int
Entries []*ROA_Entry
Certificate *RPKI_Certificate
BadFormat bool
Expand Down Expand Up @@ -112,15 +112,15 @@ func (roa *RPKI_ROA) ValidateIPRoaCertificate(cert *RPKI_Certificate) ([]*ROA_En
return ValidateIPRoaCertificateList(roa.Entries, cert)
}

func ConvertROAEntries(roacontent ROAContent) ([]*ROA_Entry, error) {
func ConvertROAEntries(roacontent ROAContent) ([]*ROA_Entry, int, error) {
entries := make([]*ROA_Entry, 0)

asn := roacontent.ASID
//fmt.Printf("ROAContent %v %v AS: %v\n", len(fullbytes), err, roacontent.ASID)
for _, addrblock := range roacontent.IpAddrBlocks {
for _, addr := range addrblock.Addresses {
ip, err := DecodeIP(addrblock.AddressFamily, addr.Address)
if err != nil {
return entries, err
return entries, asn, err
}

maxlength := addr.MaxLength
Expand All @@ -129,14 +129,13 @@ func ConvertROAEntries(roacontent ROAContent) ([]*ROA_Entry, error) {
}
//fmt.Printf(" - %v %v\n", ip, err)
re := &ROA_Entry{
ASN: roacontent.ASID,
IPNet: ip,
MaxLength: maxlength,
}
entries = append(entries, re)
}
}
return entries, nil
return entries, asn, nil
}

func DecodeROA(data []byte) (*RPKI_ROA, error) {
Expand Down Expand Up @@ -165,7 +164,7 @@ func DecodeROA(data []byte) (*RPKI_ROA, error) {
return nil, err
}

entries, err := ConvertROAEntries(roacontent)
entries, asn, err := ConvertROAEntries(roacontent)
if err != nil {
return nil, err
}
Expand All @@ -174,6 +173,7 @@ func DecodeROA(data []byte) (*RPKI_ROA, error) {
rpki_roa := RPKI_ROA{
BadFormat: badformat,
Entries: entries,
ASN: asn,
}

rpki_roa.SigningTime, _ = c.GetSigningTime()
Expand Down

0 comments on commit 884306d

Please sign in to comment.