diff options
author | Rob Austein <sra@hactrn.net> | 2007-10-01 20:22:57 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2007-10-01 20:22:57 +0000 |
commit | 20f735ac7884111b47bd8ba974ed3e8fd1242e89 (patch) | |
tree | b957f1a784408c57bbb9466f8738b1cb621c9b6f | |
parent | dc31da6d5e3c663e384a058142b920e092730268 (diff) |
Get rid of resource class silliness in left-right protocol.
svn path=/docs/left-right-xml; revision=1067
-rw-r--r-- | docs/left-right-xml | 15 | ||||
-rw-r--r-- | docs/sample-irdb.pdf | bin | 2340 -> 2143 bytes | |||
-rw-r--r-- | docs/sample-irdb.sql | 55 | ||||
-rw-r--r-- | scripts/left-right-protocol-samples/pdu.062.xml | 5 | ||||
-rw-r--r-- | scripts/left-right-schema.rnc | 10 | ||||
-rw-r--r-- | scripts/left-right-schema.rng | 60 | ||||
-rw-r--r-- | scripts/rpki/left_right.py | 62 | ||||
-rw-r--r-- | scripts/rpki/relaxng.py | 62 |
8 files changed, 94 insertions, 175 deletions
diff --git a/docs/left-right-xml b/docs/left-right-xml index 6496eda6..2c4c9738 100644 --- a/docs/left-right-xml +++ b/docs/left-right-xml @@ -705,15 +705,12 @@ </msg> <msg version="1" xmlns="http://www.hactrn.net/uris/rpki/left-right-spec/"> - <list_resources type="reply" self_id="42" child_id="289" valid_until="2008-04-01T00:00:00Z"> - <resource_class ipv4="10.0.0.44/32,10.3.0.44/32" - ipv6="fe80:dead:beef::/48" - as="666"/> - <resource_class subject_name="Wombats are us" - ipv4="10.2.0.6/32" - ipv6="fe80:deed:f00d::/48,fe80:dead:beef:2::-fe80:dead:beef:2::49" - as="666"/> - </list_resources> + <list_resources type="reply" self_id="42" child_id="289" + valid_until="2008-04-01T00:00:00Z" + subject_name="Wombats are us" + ipv4="10.0.0.44/32,10.3.0.44/32" + ipv6="fe80:deed:f00d::/48,fe80:dead:beef:2::-fe80:dead:beef:2::49" + as="666"/> </msg> <!-- === --> diff --git a/docs/sample-irdb.pdf b/docs/sample-irdb.pdf Binary files differindex 459729fb..883cb20a 100644 --- a/docs/sample-irdb.pdf +++ b/docs/sample-irdb.pdf diff --git a/docs/sample-irdb.sql b/docs/sample-irdb.sql index a039918a..abfba9e5 100644 --- a/docs/sample-irdb.sql +++ b/docs/sample-irdb.sql @@ -1,19 +1,24 @@ -- $Id$ +DROP TABLE IF EXISTS registrant; + +CREATE TABLE registrant ( + registrant_id SERIAL NOT NULL, + IRBE_mapped_id TEXT, + subject_name TEXT, + valid_until DATETIME NOT NULL, + PRIMARY KEY (registrant_id) +); + DROP TABLE IF EXISTS asn; CREATE TABLE asn ( asn_id SERIAL NOT NULL, start_as BIGINT unsigned NOT NULL, end_as BIGINT unsigned NOT NULL, - resource_class_id BIGINT unsigned NOT NULL, + registrant_id BIGINT unsigned NOT NULL, PRIMARY KEY (asn_id), - FOREIGN KEY (resource_class_id) REFERENCES resource_class ON DELETE SET NULL ON UPDATE SET NULL -); - -CREATE UNIQUE INDEX XPKasn ON asn -( - asn_id + FOREIGN KEY (registrant_id) REFERENCES registrant ON DELETE SET NULL ON UPDATE SET NULL ); DROP TABLE IF EXISTS net; @@ -23,41 +28,7 @@ CREATE TABLE net ( start_ip VARCHAR(40) NOT NULL, end_ip VARCHAR(40) NOT NULL, version TINYINT unsigned NOT NULL, - resource_class_id BIGINT unsigned NOT NULL, - PRIMARY KEY (net_id), - FOREIGN KEY (resource_class_id) REFERENCES resource_class ON DELETE SET NULL ON UPDATE SET NULL -); - -CREATE UNIQUE INDEX XPKnet ON net -( - net_id -); - -DROP TABLE IF EXISTS registrant; - -CREATE TABLE registrant ( - registrant_id SERIAL NOT NULL, - IRBE_mapped_id TEXT, - PRIMARY KEY (registrant_id) -); - -CREATE UNIQUE INDEX XPKregistrant ON registrant -( - registrant_id -); - -DROP TABLE IF EXISTS resource_class; - -CREATE TABLE resource_class ( - resource_class_id SERIAL NOT NULL, - subject_name TEXT, - valid_until DATETIME NOT NULL, registrant_id BIGINT unsigned NOT NULL, - PRIMARY KEY (resource_class_id), + PRIMARY KEY (net_id), FOREIGN KEY (registrant_id) REFERENCES registrant ON DELETE SET NULL ON UPDATE SET NULL ); - -CREATE UNIQUE INDEX XPKresource_class ON resource_class -( - resource_class_id -); diff --git a/scripts/left-right-protocol-samples/pdu.062.xml b/scripts/left-right-protocol-samples/pdu.062.xml index 086fddc8..5d218eb1 100644 --- a/scripts/left-right-protocol-samples/pdu.062.xml +++ b/scripts/left-right-protocol-samples/pdu.062.xml @@ -1,8 +1,5 @@ <?xml version="1.0" encoding="US-ASCII"?> <!--Automatically generated, do not edit.--> <msg xmlns="http://www.hactrn.net/uris/rpki/left-right-spec/" version="1"> - <list_resources type="reply" self_id="42" child_id="289" valid_until="2008-04-01T00:00:00Z"> - <resource_class ipv4="10.0.0.44/32,10.3.0.44/32" ipv6="fe80:dead:beef::/48" as="666"/> - <resource_class subject_name="Wombats are us" ipv4="10.2.0.6/32" ipv6="fe80:deed:f00d::/48,fe80:dead:beef:2::-fe80:dead:beef:2::49" as="666"/> - </list_resources> + <list_resources type="reply" self_id="42" child_id="289" valid_until="2008-04-01T00:00:00Z" subject_name="Wombats are us" ipv4="10.0.0.44/32,10.3.0.44/32" ipv6="fe80:deed:f00d::/48,fe80:dead:beef:2::-fe80:dead:beef:2::49" as="666"/> </msg> diff --git a/scripts/left-right-schema.rnc b/scripts/left-right-schema.rnc index 2ed54032..40f05314 100644 --- a/scripts/left-right-schema.rnc +++ b/scripts/left-right-schema.rnc @@ -182,12 +182,10 @@ list_resources_elt = element list_resources { ( attribute type { "query" }, self_id, child_id? ) | ( attribute type { "reply" }, self_id, child_id?, attribute valid_until { xsd:token { maxLength="1024" } }?, - element resource_class { - attribute subject_name { xsd:token { maxLength="1024" } }?, - attribute as { xsd:token { maxLength="1024" } }?, - attribute ipv4 { xsd:token { maxLength="1024" } }?, - attribute ipv6 { xsd:token { maxLength="1024" } }? - }* + attribute subject_name { xsd:token { maxLength="1024" } }?, + attribute as { xsd:token { maxLength="1024" } }?, + attribute ipv4 { xsd:token { maxLength="1024" } }?, + attribute ipv6 { xsd:token { maxLength="1024" } }? ) } diff --git a/scripts/left-right-schema.rng b/scripts/left-right-schema.rng index 90738f9a..4c0b9133 100644 --- a/scripts/left-right-schema.rng +++ b/scripts/left-right-schema.rng @@ -840,38 +840,34 @@ </data> </attribute> </optional> - <zeroOrMore> - <element name="resource_class"> - <optional> - <attribute name="subject_name"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="as"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="ipv4"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="ipv6"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - </element> - </zeroOrMore> + <optional> + <attribute name="subject_name"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="as"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="ipv4"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="ipv6"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> </group> </choice> </element> diff --git a/scripts/rpki/left_right.py b/scripts/rpki/left_right.py index 4c950951..069835a3 100644 --- a/scripts/rpki/left_right.py +++ b/scripts/rpki/left_right.py @@ -465,15 +465,15 @@ class route_origin_elt(data_elt): """Generate <route_origin/> element.""" return self.make_elt() -class resource_class_elt(base_elt): - """<resource_class/> element.""" +class list_resources_elt(base_elt): + """<list_resources/> element.""" - element_name = "resource_class" - attributes = ("as", "ipv4", "ipv6", "subject_name") + element_name = "list_resources" + attributes = ("type", "self_id", "child_id", "valid_until", "as", "ipv4", "ipv6", "subject_name") def startElement(self, stack, name, attrs): - """Handle <resource_class/> element.""" - assert name == "resource_class", "Unexpected name %s, stack %s" % (name, stack) + """Handle <list_resources/> element.""" + assert name == "list_resources", "Unexpected name %s, stack %s" % (name, stack) self.read_attrs(attrs) if self.as is not None: self.as = rpki.resource_set.resource_set_as(self.as) @@ -482,40 +482,9 @@ class resource_class_elt(base_elt): if self.ipv6 is not None: self.ipv6 = rpki.resource_set.resource_set_ipv6(self.ipv6) - def endElement(self, stack, name, text): - """Handle <resource_class/> element.""" - assert name == "resource_class", "Unexpected name %s, stack %s" % (name, stack) - stack.pop() - - def toXML(self): - """Generate <resource_class/> element.""" - return self.make_elt() - -class list_resources_elt(base_elt): - """<list_resources/> element.""" - - element_name = "list_resources" - attributes = ("type", "self_id", "child_id", "valid_until") - - def __init__(self): - self.resources = [] - - def startElement(self, stack, name, attrs): - """Handle <list_resources/> element.""" - if name == "resource_class": - rc = resource_class_elt() - self.resources.append(rc) - stack.append(rc) - rc.startElement(stack, name, attrs) - else: - assert name == "list_resources", "Unexpected name %s, stack %s" % (name, stack) - self.read_attrs(attrs) - def toXML(self): """Generate <list_resources/> element.""" - elt = self.make_elt() - elt.extend([i.toXML() for i in self.resources]) - return elt + return self.make_elt() class report_error_elt(base_elt): """<report_error/> element.""" @@ -595,6 +564,11 @@ def irdb_query(gctx, self_id, child_id=None): instead issue a query and set up a handler to receive the response. For the moment, though, we're doing simple lock step and damn the torpedos. + + Not yet doing anything useful with validity interval or subject + name. Most likely this function should really be wrapped up in a + class that carries both the query result and also the intermediate state + needed for the event-driven code that this function will need to become. """ q_msg = msg_elt() @@ -617,14 +591,4 @@ def irdb_query(gctx, self_id, child_id=None): r_msg = rpki.left_right.sax_handler.saxify(r_elt) if len(r_msg) != 0 or not isinstance(r_msg[0], list_resources_elt) or r_msg[0].type != "reply": raise rpki.exceptions.BadIRDBReply, "Unexpected response to IRDB query: %s" % r_msg.toXML() - as = rpki.resource_set.resource_set_as() - ipv4 = rpki.resource_set.resource_set_ipv4() - ipv6 = rpki.resource_set.resource_set_ipv6() - for r in r_msg[0].resources: - if r.as is not None: - as.union(r.as) - if r.ipv4 is not None: - ipv4.union(r.ipv4) - if r.ipv6 is not None: - ipv6.union(r.ipv6) - return as, ipv4, ipv6 + return r_msg[0].as, r_msg[0].ipv4, r_msg[0].ipv6 diff --git a/scripts/rpki/relaxng.py b/scripts/rpki/relaxng.py index e43e1bcb..502be9ee 100644 --- a/scripts/rpki/relaxng.py +++ b/scripts/rpki/relaxng.py @@ -4,7 +4,7 @@ import lxml.etree left_right = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encoding="UTF-8"?> <!-- - $Id: left-right-schema.rng 995 2007-09-19 20:42:31Z sra $ + $Id: left-right-schema.rnc 995 2007-09-19 20:42:31Z sra $ RelaxNG (Compact Syntax) Schema for RPKI left-right protocol. @@ -844,38 +844,34 @@ left_right = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" enc </data> </attribute> </optional> - <zeroOrMore> - <element name="resource_class"> - <optional> - <attribute name="subject_name"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="as"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="ipv4"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - <optional> - <attribute name="ipv6"> - <data type="token"> - <param name="maxLength">1024</param> - </data> - </attribute> - </optional> - </element> - </zeroOrMore> + <optional> + <attribute name="subject_name"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="as"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="ipv4"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> + <optional> + <attribute name="ipv6"> + <data type="token"> + <param name="maxLength">1024</param> + </data> + </attribute> + </optional> </group> </choice> </element> |