def process_session_message(self, new_session, process_pdr_rules):
        """
        Process the messages recevied from session. Return True
        if parsing is successfull.
        """

        # Assume things are green
        context_response =\
             UPFSessionContextState(cause_info=CauseIE(cause_ie=CauseIE.REQUEST_ACCEPTED),
                                    session_snapshot=UPFSessionState(subscriber_id=new_session.subscriber_id,
                                                                     local_f_teid=new_session.local_f_teid,
                                                                     session_version=new_session.session_version))

        context_response.cause_info.cause_ie = \
                  SessionStateManager.validate_session_msg(new_session)
        if context_response.cause_info.cause_ie != CauseIE.REQUEST_ACCEPTED:
            self.logger.error(
                "Error : Parsing Error in SetInterface Message %d",
                context_response.cause_info.cause_ie)
            return context_response

        #Create PDR rules
        pdr_validator = SessionStateManager._pdr_create_rule_group(
            new_session, process_pdr_rules)
        if pdr_validator:
            context_response.failure_rule_id.pdr.extend(
                [pdr_validator.offending_ie])
            context_response.cause_info.cause_ie = pdr_validator.cause_info

        return context_response
Esempio n. 2
0
    def _prepare_session_config_report(self, stats_msgs):
        session_config_dict = {}

        for flow_stats in stats_msgs:
            for stat in flow_stats:
                if stat.table_id != self.tbl_num:
                    continue

                local_f_teid_ng = _get_ng_local_f_id(stat)
                if not local_f_teid_ng or local_f_teid_ng == REG_ZERO_VAL:
                    continue
                # Already present
                if local_f_teid_ng in session_config_dict:
                    if local_f_teid_ng != session_config_dict[
                            local_f_teid_ng].local_f_teid:
                        self.logger.error(
                            "Mismatch local TEID value. Need to investigate")

                    continue

                sid = _get_sid(stat)
                if not sid:
                    continue

                rule_version = _get_version(stat)
                if rule_version == 0:
                    continue

                session_config_dict[local_f_teid_ng] = \
                                             UPFSessionState(
                                                 subscriber_id=sid,
                                                 session_version=rule_version,
                                                 local_f_teid=local_f_teid_ng,
                                             )

        SessionStateManager.report_session_config_state(
            session_config_dict,
            self.ng_config.sessiond_setinterface,
        )