Skip to content
Snippets Groups Projects
Commit 0b0afeac authored by Malte Bauch's avatar Malte Bauch
Browse files

Add AssignForwardingRoute method to KMS

parent 73911013
No related branches found
No related tags found
1 merge request!1Move proto kms into ekms
...@@ -220,6 +220,37 @@ func (kms *EKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) (*kms ...@@ -220,6 +220,37 @@ func (kms *EKMS) AddPeer(kmsPeerSocket string, servingQLE *QuantumElement) (*kms
return peer, nil return peer, nil
} }
func (kms *EKMS) AssignForwardingRoute(pId, pHop, nHop string) error {
pathId, err := uuid.Parse(pId)
if err != nil {
return fmt.Errorf("The given path id %s is no uuid; err = ", pathId, err)
}
var previousHop *kmsPeer
var nextHop *kmsPeer
var ok bool
if pHop != "" {
previousHop, ok = kms.KmsPeers[pHop]
if !ok {
return fmt.Errorf("No peer found for %s", pHop)
}
}
if nHop != "" {
nextHop, ok = kms.KmsPeers[nHop]
if !ok {
return fmt.Errorf("No peer found for %s", nHop)
}
}
// set the route within routing table
kms.routingTable[pathId] = &Route{
Previous: previousHop,
Next: nextHop,
}
return nil
}
// TODO/XXX error handling // TODO/XXX error handling
func (kms *EKMS) RemovePeer(kmsPeerSocket string) { func (kms *EKMS) RemovePeer(kmsPeerSocket string) {
if _, there := kms.KmsPeers[kmsPeerSocket]; there { if _, there := kms.KmsPeers[kmsPeerSocket]; there {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment