Exemplo n.º 1
0
    def _pdr_create_rule_group(new_session,
                               pdr_rules) -> Optional[MsgParseOutput]:

        for pdr_entry in new_session.set_gr_pdr:
            # PDR Validation
            if pdr_entry.HasField('pdi') == False or pdr_entry.pdr_id == 0:
                offending_ie = OffendingIE(
                    identifier=pdr_entry.pdr_id,
                    version=pdr_entry.pdr_version,
                )
                return MsgParseOutput(offending_ie,
                                      CauseIE.MANDATORY_IE_INCORRECT)

            # If session is creted or activiated FAR_IDs cann't be 0
            if len(pdr_entry.set_gr_far.ListFields()) == 0 and \
                     pdr_entry.pdr_state == PdrState.Value('INSTALL'):
                offending_ie = OffendingIE(
                    identifier=pdr_entry.pdr_id,
                    version=pdr_entry.pdr_version,
                )
                return MsgParseOutput(offending_ie,
                                      CauseIE.INVALID_FORWARDING_POLICY)

            if not pdr_entry.pdi.ue_ip_adr:
                return MsgParseOutput(offending_ie,
                                      CauseIE.MANDATORY_IE_INCORRECT)

            pdr_rules.update(
                {pdr_entry.pdr_id: pdr_create_rule_entry(pdr_entry)})

        return None
Exemplo n.º 2
0
    def ng_update_session_flows(self, request: SessionSet,
                                fut: 'Future(UPFSessionContextState)') -> UPFSessionContextState:
        """
        Install PDR, FAR and QER flows for the 5G Session send by SMF
        """
        logging.debug('Update 5G Session Flow for SessionID:%s, SessionVersion:%d',
                      request.subscriber_id, request.session_version)

        # Convert message containing PDR to Named Tuple Rules.
        process_pdr_rules = OrderedDict()
        response = self._ng_servicer_app.ng_session_message_handler(request, process_pdr_rules)

        # Failure in message processing return failure
        if response.cause_info.cause_ie == CauseIE.REQUEST_ACCEPTED:
            for _, pdr_entries in process_pdr_rules.items():
                # Create the Tunnel
                ret = self._ng_tunnel_update(pdr_entries, request.subscriber_id)
                if ret == False:
                    offending_ie = OffendingIE(identifier=pdr_entries.pdr_id,
                                               version=pdr_entries.pdr_version)

                    #Session information is filled already
                    response.cause_info.cause_ie = CauseIE.RULE_CREATION_OR_MODIFICATION_FAILURE
                    response.failure_rule_id.pdr.extend([offending_ie])
                    break

        fut.set_result(response)