Example #1
0
    def send_cer(self, consumed, message):
        msg = self.stack.createRequest(0, 257)
        #vendorid
        tmp = DiameterAVP()
        tmp.setCode(266)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.vendor_id)
        msg.addAVP(tmp)

        #productname
        tmp = DiameterAVP()
        tmp.setCode(269)
        tmp.setMandatory(True)
        tmp.setOctetString(self.stack.product_name)
        msg.addAVP(tmp)

        #firmware
        tmp = DiameterAVP()
        tmp.setCode(267)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.firmware_revision)
        msg.addAVP(tmp)

        #host ip
        tmp = DiameterAVP()
        tmp.setCode(257)
        tmp.setMandatory(True)
        tmp.setIPV4(self.stack.ip4_address)
        msg.addAVP(tmp)

        #get supported vendors from stack
        for vendor in self.stack.supported_vendors:
            supp = DiameterAVP()
            supp.setCode(265)
            supp.setMandatory(True)
            supp.setInteger32(vendor)
            msg.addAVP(supp)

        #get applications from stack
        for apps in [self.stack.auth_apps, self.stack.acct_apps]:
            for app in apps:
                # Build *-Application-Id AVP
                app_id = DiameterAVP()
                if apps == self.stack.auth_apps:
                    # App is for authentication, so use Auth-Application-Id AVP code
                    app_id.setCode(258)
                else:
                    # App is for accounting, so use Acct-Application-Id AVP code
                    app_id.setCode(259)
                app_id.setMandatory(True)
                app_id.setInteger32(app[1])
    
                if app[0]:
                    tmp = DiameterAVP()
                    tmp.setCode(260)
                    tmp.setMandatory(True)
                    #vendor
                    v = DiameterAVP()
                    v.setCode(266)
                    v.setMandatory(True)
                    v.setInteger32(app[0])
                    tmp.addAVP(v)
                    tmp.addAVP(app_id)
                    msg.addAVP(tmp)
                else:
                    msg.addAVP(app_id)

        self.stack.sendByPeer(self.peer, msg, False)

        self.run = self.receive_cea
Example #2
0
    def send_cer(self, consumed, message):
        msg = self.stack.createRequest(0, 257)
        # vendorid
        tmp = DiameterAVP()
        tmp.setCode(266)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.vendor_id)
        msg.addAVP(tmp)

        # productname
        tmp = DiameterAVP()
        tmp.setCode(269)
        tmp.setMandatory(True)
        tmp.setOctetString(self.stack.product_name)
        msg.addAVP(tmp)

        # firmware
        tmp = DiameterAVP()
        tmp.setCode(267)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.firmware_revision)
        msg.addAVP(tmp)

        # host ip
        tmp = DiameterAVP()
        tmp.setCode(257)
        tmp.setMandatory(True)
        tmp.setIPV4(self.stack.ip4_address)
        msg.addAVP(tmp)

        # get supported vendors from stack
        for vendor in self.stack.supported_vendors:
            supp = DiameterAVP()
            supp.setCode(265)
            supp.setMandatory(True)
            supp.setInteger32(vendor)
            msg.addAVP(supp)

        # get applications from stack
        for apps in [self.stack.auth_apps, self.stack.acct_apps]:
            for app in apps:
                # Build *-Application-Id AVP
                app_id = DiameterAVP()
                if apps == self.stack.auth_apps:
                    # App is for authentication, so use Auth-Application-Id AVP code
                    app_id.setCode(258)
                    _log.debug("CER Auth-Application-Id %d", app[1])
                else:
                    # App is for accounting, so use Acct-Application-Id AVP code
                    app_id.setCode(259)
                    _log.debug("CER Acct-Application-Id %d", app[1])
                app_id.setMandatory(True)
                app_id.setInteger32(app[1])

                if app[0]:
                    tmp = DiameterAVP()
                    tmp.setCode(260)
                    tmp.setMandatory(True)
                    # vendor
                    v = DiameterAVP()
                    v.setCode(266)
                    v.setMandatory(True)
                    v.setInteger32(app[0])
                    tmp.addAVP(v)
                    tmp.addAVP(app_id)
                    msg.addAVP(tmp)
                else:
                    msg.addAVP(app_id)

        _log.debug("Send CEA")
        self.stack.sendByPeer(self.peer, msg, False)

        self.run = self.receive_cea
Example #3
0
    def send_cer(self, consumed, message):
        msg = self.stack.createRequest(0, 257)
        #vendorid
        tmp = DiameterAVP()
        tmp.setCode(266)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.vendor_id)
        msg.addAVP(tmp)

        #productname
        tmp = DiameterAVP()
        tmp.setCode(269)
        tmp.setMandatory(True)
        tmp.setOctetString(self.stack.product_name)
        msg.addAVP(tmp)

        #firmware
        tmp = DiameterAVP()
        tmp.setCode(267)
        tmp.setMandatory(True)
        tmp.setInteger32(self.stack.firmware_revision)
        msg.addAVP(tmp)

        #host ip
        tmp = DiameterAVP()
        tmp.setCode(257)
        tmp.setMandatory(True)
        tmp.setIPV4(self.stack.ip4_address)
        msg.addAVP(tmp)

        #get applications from stack
        apps = self.stack.applications.keys()
        for app in apps:
            #acct
            acc = DiameterAVP()
            acc.setCode(259)
            acc.setMandatory(True)
            acc.setInteger32(app[1])
            #auth
            auth = DiameterAVP()
            auth.setCode(258)
            auth.setMandatory(True)
            auth.setInteger32(app[1])

            if app[0]:
                tmp = DiameterAVP()
                tmp.setCode(260)
                tmp.setMandatory(True)
                #vendor
                v = DiameterAVP()
                v.setCode(266)
                v.setMandatory(True)
                v.setInteger32(app[0])
                tmp.addAVP(v)
                tmp.addAVP(auth)
                tmp.addAVP(acc)
                msg.addAVP(tmp)
                msg.addAVP(v)
            else:
                msg.addAVP(auth)
                msg.addAVP(acc)

        self.stack.sendByPeer(self.peer, msg, False)

        self.run = self.receive_cea