Пример #1
0
def add_subscriber(client, args):
    gsm = GSMSubscription()
    lte = LTESubscription()
    state = SubscriberState()

    if len(args.gsm_auth_tuple) != 0:
        gsm.state = GSMSubscription.ACTIVE
        for auth_tuple in args.gsm_auth_tuple:
            gsm.auth_tuples.append(bytes.fromhex(auth_tuple))

    if args.lte_auth_key is not None:
        lte.state = LTESubscription.ACTIVE
        lte.auth_key = bytes.fromhex(args.lte_auth_key)

    if args.lte_auth_next_seq is not None:
        state.lte_auth_next_seq = args.lte_auth_next_seq

    if args.lte_auth_opc is not None:
        lte.auth_opc = bytes.fromhex(args.lte_auth_opc)

    data = SubscriberData(
        sid=SIDUtils.to_pb(args.sid),
        gsm=gsm,
        lte=lte,
        state=state,
    )
    client.AddSubscriber(data)
Пример #2
0
 def add_srsue(self):
     # Add for srsUE, add the hardcoded SubscriberData into the store when receiving request
     imsi = 'IMSI' + SRSUE_IMSI
     lte = LTESubscription()
     lte.state = LTESubscription.ACTIVE
     lte.auth_key = bytes.fromhex(SRSUE_KEY)
     #lte.auth_opc = bytes.fromhex(SRSUE_OPC)
     state = SubscriberState()
     state.lte_auth_next_seq = 1
     sub_data = SubscriberData(sid=SIDUtils.to_pb(imsi),
                               lte=lte,
                               state=state)
     self.add_subscriber(sub_data)
Пример #3
0
    def _get_subscriberdb_data(sid):
        """
        Get subscriber data in protobuf format.

        Args:
            sid (str): string representation of the subscriber id
        Returns:
            subscriber_data (protos.subscriberdb_pb2.SubscriberData):
                full subscriber information for :sid: in protobuf format.
        """
        sub_db_sid = SIDUtils.to_pb(sid)
        lte = LTESubscription()
        lte.state = LTESubscription.ACTIVE
        lte.auth_key = bytes.fromhex(KEY)
        state = SubscriberState()
        state.lte_auth_next_seq = 1
        return SubscriberData(sid=sub_db_sid, lte=lte, state=state)
Пример #4
0
def add_subscriber(client, args):
    gsm = GSMSubscription()
    lte = LTESubscription()
    state = SubscriberState()
    sub_network = CoreNetworkType()

    if len(args.gsm_auth_tuple) != 0:
        gsm.state = GSMSubscription.ACTIVE
        for auth_tuple in args.gsm_auth_tuple:
            gsm.auth_tuples.append(bytes.fromhex(auth_tuple))

    if args.lte_auth_key is not None:
        lte.state = LTESubscription.ACTIVE
        lte.auth_key = bytes.fromhex(args.lte_auth_key)

    if args.lte_auth_next_seq is not None:
        state.lte_auth_next_seq = args.lte_auth_next_seq

    if args.lte_auth_opc is not None:
        lte.auth_opc = bytes.fromhex(args.lte_auth_opc)

    if args.forbidden_network_types is not None:
        if (len(args.forbidden_network_types.split(",")) > 2):
            print("Forbidden Core Network Types are NT_5GC, NT_EPC")
            return
        for n in args.forbidden_network_types.split(","):
            if n == "NT_5GC":
                sub_network.forbidden_network_types.extend(
                    [CoreNetworkType.NT_5GC])
            elif n == "NT_EPC":
                sub_network.forbidden_network_types.extend(
                    [CoreNetworkType.NT_EPC])
            else:
                print(
                    "Invalid Network type, Forbidden Core Network Types are NT_5GC, NT_EPC"
                )
                return

    data = SubscriberData(
        sid=SIDUtils.to_pb(args.sid),
        gsm=gsm,
        lte=lte,
        state=state,
        sub_network=sub_network,
    )
    client.AddSubscriber(data)