aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2007-10-03 21:09:41 +0000
committerRob Austein <sra@hactrn.net>2007-10-03 21:09:41 +0000
commit7dd3da9e7b4a119be78fc9be8921b9d4c3954b22 (patch)
tree5e7b961ef2ea47c6f45e4071eb53b4883f243879
parent35089d7e4f8591300a0b574e46101d7c1050ad88 (diff)
Checkpoint
svn path=/scripts/rpki/left_right.py; revision=1087
-rw-r--r--scripts/rpki/left_right.py35
-rw-r--r--scripts/rpki/up_down.py31
2 files changed, 57 insertions, 9 deletions
diff --git a/scripts/rpki/left_right.py b/scripts/rpki/left_right.py
index 35d8fd65..9f73b8a9 100644
--- a/scripts/rpki/left_right.py
+++ b/scripts/rpki/left_right.py
@@ -335,6 +335,41 @@ class parent_elt(data_elt):
self.make_b64elt(elt, "peer_ta", self.peer_ta.get_DER())
return elt
+ def query_up_down(self, gctx, q_pdu):
+ """Client code for sending one up-down query PDU to this parent."""
+ bsc = bsc_elt.sql_fetch(gctx.db, gctx.cur, self.bsc_id)
+ if bsc is None:
+ raise rpki.exceptions.NotFound, "Could not find BSC %s" % self.bsc_id
+
+ # I have no flipping idea what I should be putting into the sender
+ # and recipient fields yet. As far as I can tell they're worse
+ # than useless, in that they provide no information I can't get
+ # more easily in other ways and I have to check them and store
+ # data for them. Use bogus values for now, sort out later, may
+ # require hacking SQL just to have someplace to store the values
+ # we need to put here. Ick.
+
+ q_msg = rpki.up_down.message_pdu.make_query(sender = 'I have no idea what to put in the "sender" attribute',
+ recipient = 'I have no idea what to put in the "recipient" attribute',
+ payload = q_pdu)
+ q_elt = q_msg.toXML()
+ rpki.relaxng.up_down.assertValid(q_elt)
+ q_cms = rpki.cms.xml_encode(q_elt, bsc.private_key_id, bsc.signing_cert)
+
+ # Er, what do we use for HTTPS trust anchors here?!?
+
+ raise NotImplementedError
+
+ # Code from which to steal when completing this: child_elt.serve_up_down(), irbe-cli.py
+ #
+ # Need to check response CMS, decode, then dispatch to some (as yet unnamed) method
+ # in the response payload pdu. I think.
+ #
+ # When we handle asynchronous events properly, this method will be
+ # broken into two separate functions at the point where we're
+ # waiting for the https response to come back. Second half is probably another
+ # method of parent_elt so that it can check the response CMS, etc.
+
class child_elt(data_elt):
"""<child/> element."""
diff --git a/scripts/rpki/up_down.py b/scripts/rpki/up_down.py
index ef7d175d..91e82438 100644
--- a/scripts/rpki/up_down.py
+++ b/scripts/rpki/up_down.py
@@ -372,6 +372,17 @@ class message_pdu(base_elt):
version = 1
+ name2type = {
+ "list" : list_pdu,
+ "list_response" : list_response_pdu,
+ "issue" : issue_pdu,
+ "issue_response" : issue_response_pdu,
+ "revoke" : revoke_pdu,
+ "revoke_response" : revoke_response_pdu,
+ "error_response" : error_response_pdu }
+
+ type2name = dict((v,k) for k,v in name2type.items())
+
def toXML(self):
"""Generate payload of message PDU."""
elt = self.make_elt("message", "version", "sender", "recipient", "type")
@@ -390,15 +401,7 @@ class message_pdu(base_elt):
self.sender = attrs["sender"]
self.recipient = attrs["recipient"]
self.type = attrs["type"]
- self.payload = {
- "list" : list_pdu,
- "list_response" : list_response_pdu,
- "issue" : issue_pdu,
- "issue_response" : issue_response_pdu,
- "revoke" : revoke_pdu,
- "revoke_response" : revoke_response_pdu,
- "error_response" : error_response_pdu
- }[attrs["type"]]()
+ self.payload = self.name2type[attrs["type"]]()
stack.append(self.payload)
def __str__(self):
@@ -409,6 +412,16 @@ class message_pdu(base_elt):
self.payload.serve_pdu(gctx, self, r_msg, child)
return r_msg
+ @classmethod
+ def make_query(cls, sender, recipient, payload):
+ assert not self.type2name[type(payload)].endswith("_response")
+ self = cls()
+ self.sender = sender
+ self.recipient = recipient
+ self.payload = payload
+ self.type = self.type2name[type(payload)]
+ return self
+
class sax_handler(rpki.sax_utils.handler):
"""SAX handler for Up-Down protocol."""