예제 #1
0
파일: qcrypt.py 프로젝트: giggsoff/qnet
    def get_handler(self, req, **kwargs):
        # In JSON file channel number is the key (string)
        channel = kwargs['channel']

        status = int(kwargs['status'])
        result = -1
        
        c = self.channels[channel]
        dp = self.dpset.get(c['dpid'])

        if status == 0:
            result = c["scrypt"]
            self.set_flows(dp, result) 
        elif status == 1:
            result = c["qcrypt"]
            self.set_flows(dp, result)
        elif status == 2:
            result = 'REREAD' # reread quantum key file
        elif status == 3:
            result = c["transp"]
            self.set_flows(dp, result)
        elif status == 4:
            result = 'DELETE'
            delete_flow_entry(dp)
        elif status == 5:
            result = os.system(qpath + '/bin/crypto_stat eth1 eth2')
        elif status == 6:
            p = os.popen(qpath + '/bin/crypto_stat_get eth1 eth2')
            result = p.readlines()

        body = json.dumps({'channel': channel, 'status': status, 'result': result})

        return Response(content_type='application/json', body=body)
예제 #2
0
파일: qcrypt.py 프로젝트: tatonka21/qnet
    def set_flows(self, dp, f):
        ofproto = dp.ofproto

        delete_flow_entry(dp)

        flow = {
            "priority":
            1000,
            "match": {
                "dl_type": 0x0800,
                "nw_proto": 6,
                "in_port": f["iport"],
                "nw_dst": self.dst['nw'],
                "tp_dst": self.dst['tp']
            },
            "actions": [{
                "type": "SET_NW_DST",
                "nw_dst": f["nw"]
            }, {
                "type": "SET_TP_DST",
                "tp_dst": f["tp"]
            }, {
                "type": "SET_DL_DST",
                "dl_dst": f["dl"]
            }, {
                "type": "OUTPUT",
                "port": f["oport"]
            }]
        }
        mod_flow_entry(dp, flow, ofproto.OFPFC_ADD)

        flow = {
            "priority":
            1000,
            "match": {
                "dl_type": 0x0800,
                "nw_proto": 6,
                "in_port": f["oport"],
                "nw_src": f["nw"],
                "tp_src": f["tp"]
            },
            "actions": [{
                "type": "SET_NW_SRC",
                "nw_src": self.dst['nw']
            }, {
                "type": "SET_TP_SRC",
                "tp_src": self.dst['tp']
            }, {
                "type": "SET_DL_SRC",
                "dl_src": f["dl"]
            }, {
                "type": "OUTPUT",
                "port": f["iport"]
            }]
        }
        mod_flow_entry(dp, flow, ofproto.OFPFC_ADD)
예제 #3
0
파일: ofctl_rest.py 프로젝트: taomaree/ryu
    def delete_flow_entry(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            ofctl_v1_0.delete_flow_entry(dp)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        return Response(status=200)
예제 #4
0
파일: ofctl_rest.py 프로젝트: 09zwcbupt/ryu
    def delete_flow_entry(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            ofctl_v1_0.delete_flow_entry(dp)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        return Response(status=200)
예제 #5
0
파일: qcrypt.py 프로젝트: itmo-infocom/qnet
    def set_flows(self, dp, f):
        ofproto = dp.ofproto

        delete_flow_entry(dp)

        flow = {"priority":1000,
                "match":{"dl_type": 0x0800, "nw_proto": 6,"in_port":f["iport"], "nw_dst":self.dst['nw'],"tp_dst":self.dst['tp']},
                "actions":[{"type":"SET_NW_DST","nw_dst":f["nw"]},{"type":"SET_TP_DST","tp_dst":f["tp"]},
                           {"type":"SET_DL_DST","dl_dst":f["dl"]},{"type":"OUTPUT", "port":f["oport"]}]}
        mod_flow_entry(dp, flow, ofproto.OFPFC_ADD)

        flow = {"priority":1000,
                "match":{"dl_type": 0x0800, "nw_proto": 6,"in_port":f["oport"],"nw_src":f["nw"],"tp_src":f["tp"]},
                "actions":[{"type":"SET_NW_SRC","nw_src":self.dst['nw']},{"type":"SET_TP_SRC","tp_src":self.dst['tp']},
                           {"type":"SET_DL_SRC","dl_src":f["dl"]},{"type":"OUTPUT", "port":f["iport"]}]}
        mod_flow_entry(dp, flow, ofproto.OFPFC_ADD)
예제 #6
0
    def delete_flow_entry(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        flow = {'table_id': dp.ofproto.OFPTT_ALL}

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            ofctl_v1_0.delete_flow_entry(dp)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            ofctl_v1_2.mod_flow_entry(dp, flow, dp.ofproto.OFPFC_DELETE)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            ofctl_v1_3.mod_flow_entry(dp, flow, dp.ofproto.OFPFC_DELETE)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        return Response(status=200)
예제 #7
0
    def delete_flow_entry(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        flow = {'table_id': dp.ofproto.OFPTT_ALL}

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            ofctl_v1_0.delete_flow_entry(dp)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            ofctl_v1_2.mod_flow_entry(dp, flow, dp.ofproto.OFPFC_DELETE)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            ofctl_v1_3.mod_flow_entry(dp, flow, dp.ofproto.OFPFC_DELETE)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

        return Response(status=200)
예제 #8
0
    def delete_flow_entry(self, req, dpid, **_kwargs):
        dp = self.dpset.get(int(dpid))
        if dp is None:
            return Response(status=404)

        if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
            ofctl_v1_0.delete_flow_entry(dp)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_2.OFP_VERSION:
            ofctl_v1_2.mod_flow_entry(dp, {}, dp.ofproto.OFPFC_DELETE)
        elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
            ofctl_v1_3.mod_flow_entry(dp, {}, dp.ofproto.OFPFC_DELETE)
        else:
            LOG.debug('Unsupported OF protocol')
            return Response(status=501)

	res = Response(status=200)
	res.headers.add('Access-Control-Allow-Origin', '*')
        return res
예제 #9
0
파일: qcrypt.py 프로젝트: itmo-infocom/qnet
    def qchannel(self, req, **kwargs):

        simple_switch = self.simpl_switch_spp

        #channel = int(kwargs['channel'])
        # In JSON file channel number is the key (string)
        channel = kwargs['channel']

        status = int(kwargs['status'])
        result = -1
        
        c = self.channels[channel]
        dp = self.dpset.get(c['dpid'])

        if status == 0:
            result = c["scrypt"]
            self.set_flows(dp, result) 
        elif status == 1:
            result = c["qcrypt"]
            self.set_flows(dp, result)
        elif status == 2:
            result = 'REREAD' # reread quantum key file
        elif status == 3:
            result = c["transp"]
            self.set_flows(dp, result)
        elif status == 4:
            result = 'DELETE'
            delete_flow_entry(dp)
        elif status == 5:
            result = os.system(qpath + '/bin/crypto_stat eth1 eth2')
        elif status == 6:
            p = os.popen(qpath + '/bin/crypto_stat_get eth1 eth2')
            result = p.readlines()

        body = json.dumps({'channel': channel, 'status': status, 'result': result})

        return Response(content_type='application/json', body=body)