Exemple #1
0
    def test_add_service_nontransparent(self):
        self.newSetUp()
        service_cnt = len(self.services)
        self.check_send(messages.KZorpAddForwardServiceMessage("test-nontransparent-router", flags=0, count=0, dst_family=socket.AF_INET, dst_ip=socket.inet_pton(socket.AF_INET, '1.2.3.4'), dst_port=10010), 0)
        service_cnt += 1
        self.check_svc_num(service_cnt)

        self.check_send(messages.KZorpAddForwardServiceMessage("test-nontransparent-norouter", flags=0, count=0), -errno.EINVAL)
        self.check_svc_num(service_cnt)
Exemple #2
0
    def _test_add_service_nat(self, nat_message_class):
        service_cnt = len(self.services)

        #adding a nat rule to a service added in the same transaction
        self.start_transaction()
        self.send_message(
            messages.KZorpAddForwardServiceMessage(
                'test-nat', flags=messages.KZF_SVC_TRANSPARENT))
        self.send_message(
            nat_message_class('test-nat',
                              nat_src=IPRange('10.0.0.0', '10.0.0.255'),
                              nat_dst=IPRange('0.0.0.0', '255.255.255.255'),
                              nat_map=IPRange('192.168.0.0', '192.168.0.255'),
                              version=2))
        self.send_message(
            nat_message_class('test-nat',
                              nat_src=IPRange('fd00::', 'fd00::ffff'),
                              nat_dst=IPRange(
                                  '::',
                                  'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'),
                              nat_map=IPRange('fd00:1::', 'fd00:1::ffff'),
                              version=2))
        self.end_transaction()
        service_cnt += 3

        self.check_svc_num(service_cnt)
Exemple #3
0
    def __create_service_messages_that_do_not_fit_into_one_nelink_packet(self):
        service_name_format = 'service_%d'

        service_messages = []

        for service_num in range(self._get_netlink_packet_size()):
            service_name = service_name_format % (service_num, )

            add_service_message = messages.KZorpAddForwardServiceMessage(service_name, messages.KZF_SVC_TRANSPARENT)
            service_messages.append(add_service_message)

        return service_messages
    def _test_add_service_nat(self, nat_message_class):
        service_cnt = len(self.services)

        #adding a nat rule to a service added in the same transaction
        self.start_transaction()
        self.send_message(
            messages.KZorpAddForwardServiceMessage(
                'test-nat', flags=messages.KZF_SVC_TRANSPARENT))
        self.send_message(
            nat_message_class('test-nat',
                              nat_src=(messages.KZ_SVC_NAT_MAP_IPS +
                                       messages.KZ_SVC_NAT_MAP_PROTO_SPECIFIC,
                                       12345688, 12345689, 1024, 1025),
                              nat_map=(messages.KZ_SVC_NAT_MAP_IPS +
                                       messages.KZ_SVC_NAT_MAP_PROTO_SPECIFIC,
                                       12345688, 12345689, 1024, 1025)))
        self.end_transaction()
        service_cnt += 2

        self.check_svc_num(service_cnt)