Beispiel #1
0
    def createRequest(self, application, code, auth=False, acct=False):
        ret = DiameterMessage()
        ret.request_flag = True
        ret.eTe = self.nextEtE()
        ret.hBh = self.nextHbH()
        ret.application_id = application
        ret.command_code = code

        origin_host = DiameterAVP()
        origin_host.setCode(264)
        origin_host.setMandatory(True)
        origin_host.setOctetString(self.identity)
        ret.addAVP(origin_host)

        origin_realm = DiameterAVP()
        origin_realm.setCode(296)
        origin_realm.setMandatory(True)
        origin_realm.setOctetString(self.realm)
        ret.addAVP(origin_realm)

        if auth:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            ret.addAVP(tmp)
        elif acct:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            ret.addAVP(tmp)

        return ret
Beispiel #2
0
    def createRequest(self, application, code, auth=False, acct=False):
        ret = DiameterMessage()
        ret.request_flag = True
        ret.eTe = self.nextEtE()
        ret.hBh = self.nextHbH()
        ret.application_id = application
        ret.command_code = code

        origin_host = DiameterAVP()
        origin_host.setCode(264)
        origin_host.setMandatory(True)
        origin_host.setOctetString(self.identity)
        ret.addAVP(origin_host)

        origin_realm = DiameterAVP()
        origin_realm.setCode(296)
        origin_realm.setMandatory(True)
        origin_realm.setOctetString(self.realm)
        ret.addAVP(origin_realm)

        if auth:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            ret.addAVP(tmp)
        elif acct:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            ret.addAVP(tmp)

        return ret
Beispiel #3
0
    def createRequest(self,
                      application,
                      code,
                      auth=False,
                      acct=False,
                      vendor_id=None):
        _log.debug("Creating Diameter message with command code %d", code)
        ret = DiameterMessage()
        ret.request_flag = True
        ret.eTe = self.nextEtE()
        ret.hBh = self.nextHbH()
        ret.application_id = application
        ret.command_code = code

        self.addOriginHostRealm(ret)

        if vendor_id:
            app_container = DiameterAVP()
            app_container.setCode(260)
            app_container.setMandatory(True)
            tmp = DiameterAVP()
            tmp.setCode(266)
            tmp.setMandatory(True)
            tmp.setInteger32(vendor_id)
            app_container.addAVP(tmp)
        else:
            app_container = ret

        if auth:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            app_container.addAVP(tmp)
        elif acct:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            app_container.addAVP(tmp)

        if app_container != ret:
            ret.addAVP(app_container)

        return ret
Beispiel #4
0
    def createAnswer(self, req, ret_code=None):
        ret = DiameterMessage()
        ret.request_flag = False
        ret.proxiable_flag = req.proxiable_flag
        ret.eTe = req.eTe
        ret.hBh = req.hBh
        ret.application_id = req.application_id
        ret.command_code = req.command_code
  
        if ret_code:
            tmp = DiameterAVP()
            tmp.setCode(268)
            tmp.setMandatory(True)
            tmp.setInteger32(ret_code)
            ret.addAVP(tmp)
  
        self.addOriginHostRealm(ret)

        return ret
Beispiel #5
0
    def createAnswer(self, req, ret_code=None):
        ret = DiameterMessage()
        ret.request_flag = False
        ret.proxiable_flag = req.proxiable_flag
        ret.eTe = req.eTe
        ret.hBh = req.hBh
        ret.application_id = req.application_id
        ret.command_code = req.command_code
  
        if ret_code:
            tmp = DiameterAVP()
            tmp.setCode(268)
            tmp.setMandatory(True)
            tmp.setInteger32(ret_code)
            ret.addAVP(tmp)
  
        self.addOriginHostRealm(ret)

        return ret
Beispiel #6
0
    def createRequest(self, application, code, auth=False, acct=False, vendor_id=None):
        _log.debug("Creating Diameter message with command code %d", code)
        ret = DiameterMessage()
        ret.request_flag = True
        ret.eTe = self.nextEtE()
        ret.hBh = self.nextHbH()
        ret.application_id = application
        ret.command_code = code

        self.addOriginHostRealm(ret)

        if vendor_id:
            app_container = DiameterAVP()
            app_container.setCode(260)
            app_container.setMandatory(True)
            tmp = DiameterAVP()
            tmp.setCode(266)
            tmp.setMandatory(True)
            tmp.setInteger32(vendor_id)
            app_container.addAVP(tmp)
        else:
            app_container = ret

        if auth:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            app_container.addAVP(tmp)
        elif acct:
            tmp = DiameterAVP()
            tmp.setCode(258)
            tmp.setMandatory(True)
            tmp.setInteger32(application)
            app_container.addAVP(tmp)

        if app_container != ret:
            ret.addAVP(app_container)

        return ret