コード例 #1
0
ファイル: s1ap_utils.py プロジェクト: wlm328cs/magma
 def create_bearer(self, imsi, lbi):
     """
     Sends a CreateBearer Request to SPGW service
     """
     print('Sending CreateBearer request to spgw service')
     req = CreateBearerRequest(
         sid=SIDUtils.to_pb(imsi),
         link_bearer_id=lbi,
         policy_rules=[
             PolicyRule(
                 qos=FlowQos(
                     qci=1,
                     gbr_ul=10000000,
                     gbr_dl=10000000,
                     max_req_bw_ul=10000000,
                     max_req_bw_dl=10000000,
                     arp=QosArp(
                         priority_level=1,
                         pre_capability=1,
                         pre_vulnerability=0,
                     )
                 )
             )
         ]
     )
     self._stub.CreateBearer(req)
コード例 #2
0
ファイル: spgw_service_cli.py プロジェクト: go-magma/magma
def create_bearer(client, args):
    req = CreateBearerRequest(
        sid=SIDUtils.to_pb(args.imsi),
        link_bearer_id=args.lbi,
        policy_rules=[
            PolicyRule(qos=FlowQos(qci=args.qci,
                                   gbr_ul=args.gbr_ul,
                                   gbr_dl=args.gbr_dl,
                                   max_req_bw_ul=args.mbr_ul,
                                   max_req_bw_dl=args.mbr_dl,
                                   arp=QosArp(priority_level=args.priority,
                                              pre_capability=args.pre_cap,
                                              pre_vulnerability=args.pre_vul)))
        ])
    print("Creating dedicated bearer for : ", args.imsi)
    client.CreateBearer(req)
コード例 #3
0
ファイル: s1ap_utils.py プロジェクト: akshaytranzyt/magma
    def create_bearer_ipv4v6(self,
                             imsi,
                             lbi,
                             qci_val=1,
                             ipv4=False,
                             ipv6=False):
        """
        Sends a CreateBearer Request with ipv4/ipv6/ipv4v6 packet """
        """ filters to SPGW service """
        print("Sending CreateBearer request to spgw service")
        flow_match_list = []
        if ipv4:
            flow_match_list.append(
                FlowDescription(
                    match=FlowMatch(
                        ip_dst=IPAddress(
                            version=IPAddress.IPV4,
                            address="192.168.129.42/24".encode("utf-8"),
                        ),
                        tcp_dst=5001,
                        ip_proto=FlowMatch.IPPROTO_TCP,
                        direction=FlowMatch.UPLINK,
                    ),
                    action=FlowDescription.PERMIT,
                ))
            flow_match_list.append(
                FlowDescription(
                    match=FlowMatch(
                        ip_src=IPAddress(
                            version=IPAddress.IPV4,
                            address="192.168.129.42".encode("utf-8"),
                        ),
                        tcp_src=5001,
                        ip_proto=FlowMatch.IPPROTO_TCP,
                        direction=FlowMatch.DOWNLINK,
                    ),
                    action=FlowDescription.PERMIT,
                ))

        if ipv6:
            flow_match_list.append(
                FlowDescription(
                    match=FlowMatch(
                        ip_dst=IPAddress(
                            version=IPAddress.IPV6,
                            address="5546:222:2259::226".encode("utf-8"),
                        ),
                        tcp_dst=5001,
                        ip_proto=FlowMatch.IPPROTO_TCP,
                        direction=FlowMatch.UPLINK,
                    ),
                    action=FlowDescription.PERMIT,
                ))
            flow_match_list.append(
                FlowDescription(
                    match=FlowMatch(
                        ip_src=IPAddress(
                            version=IPAddress.IPV6,
                            address="fdee:0005:006c:018c::8c99".encode(
                                "utf-8"),
                        ),
                        tcp_src=5002,
                        ip_proto=FlowMatch.IPPROTO_TCP,
                        direction=FlowMatch.DOWNLINK,
                    ),
                    action=FlowDescription.PERMIT,
                ))

        req = CreateBearerRequest(
            sid=SIDUtils.to_pb(imsi),
            link_bearer_id=lbi,
            policy_rules=[
                PolicyRule(
                    id="rar_rule_1",
                    qos=FlowQos(
                        qci=qci_val,
                        gbr_ul=10000000,
                        gbr_dl=10000000,
                        max_req_bw_ul=10000000,
                        max_req_bw_dl=10000000,
                        arp=QosArp(
                            priority_level=1,
                            pre_capability=1,
                            pre_vulnerability=0,
                        ),
                    ),
                    flow_list=flow_match_list,
                )
            ],
        )
        self._stub.CreateBearer(req)
コード例 #4
0
ファイル: s1ap_utils.py プロジェクト: akshaytranzyt/magma
 def create_bearer(self, imsi, lbi, qci_val=1):
     """
     Sends a CreateBearer Request to SPGW service
     """
     print("Sending CreateBearer request to spgw service")
     req = CreateBearerRequest(
         sid=SIDUtils.to_pb(imsi),
         link_bearer_id=lbi,
         policy_rules=[
             PolicyRule(
                 id="rar_rule_1",
                 qos=FlowQos(
                     qci=qci_val,
                     gbr_ul=10000000,
                     gbr_dl=10000000,
                     max_req_bw_ul=10000000,
                     max_req_bw_dl=10000000,
                     arp=QosArp(
                         priority_level=1,
                         pre_capability=1,
                         pre_vulnerability=0,
                     ),
                 ),
                 flow_list=[
                     FlowDescription(
                         match=FlowMatch(
                             ip_dst=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="0.0.0.0/0".encode('utf-8')),
                             tcp_dst=5001,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_dst=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42/24".encode(
                                     'utf-8')),
                             tcp_dst=5002,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_dst=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42".encode('utf-8')),
                             tcp_dst=5003,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_dst=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42".encode('utf-8')),
                             tcp_dst=5004,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_dst=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42".encode('utf-8')),
                             tcp_dst=5005,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.DENY,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_src=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42".encode('utf-8')),
                             tcp_src=5001,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_src=IPAddress(version=IPAddress.IPV4,
                                              address="".encode('utf-8')),
                             tcp_dst=5002,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_src=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.64/26".encode(
                                     'utf-8')),
                             tcp_src=5003,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_src=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42/16".encode(
                                     'utf-8')),
                             tcp_src=5004,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ip_src=IPAddress(
                                 version=IPAddress.IPV4,
                                 address="192.168.129.42".encode('utf-8')),
                             tcp_src=5005,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.DENY,
                     ),
                 ],
             )
         ],
     )
     self._stub.CreateBearer(req)
コード例 #5
0
 def create_bearer(self, imsi, lbi):
     """
     Sends a CreateBearer Request to SPGW service
     """
     print("Sending CreateBearer request to spgw service")
     req = CreateBearerRequest(
         sid=SIDUtils.to_pb(imsi),
         link_bearer_id=lbi,
         policy_rules=[
             PolicyRule(
                 qos=FlowQos(
                     qci=1,
                     gbr_ul=10000000,
                     gbr_dl=10000000,
                     max_req_bw_ul=10000000,
                     max_req_bw_dl=10000000,
                     arp=QosArp(priority_level=1,
                                pre_capability=1,
                                pre_vulnerability=0),
                 ),
                 flow_list=[
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_dst="192.168.129.42",
                             tcp_dst=5001,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_dst="192.168.129.42",
                             tcp_dst=5002,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_dst="192.168.129.42",
                             tcp_dst=5003,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_dst="192.168.129.42",
                             tcp_dst=5004,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_dst="192.168.129.42",
                             tcp_dst=5005,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.UPLINK,
                         ),
                         action=FlowDescription.DENY,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_src="192.168.129.42",
                             tcp_src=5001,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_src="192.168.129.42",
                             tcp_src=5002,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_src="192.168.129.42",
                             tcp_src=5003,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_src="192.168.129.42",
                             tcp_src=5004,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.PERMIT,
                     ),
                     FlowDescription(
                         match=FlowMatch(
                             ipv4_src="192.168.129.42",
                             tcp_src=5005,
                             ip_proto=FlowMatch.IPPROTO_TCP,
                             direction=FlowMatch.DOWNLINK,
                         ),
                         action=FlowDescription.DENY,
                     ),
                 ],
             )
         ],
     )
     self._stub.CreateBearer(req)