Example #1
0
    def create_CER(self):
        # Let's build CER
        CER_avps = []
        CER_avps.append(encodeAVP("Origin-Host", self.ORIGIN_HOST))
        CER_avps.append(encodeAVP("Origin-Realm", self.ORIGIN_REALM))
        CER_avps.append(encodeAVP("Host-IP-Address", self.PCEF))
        CER_avps.append(encodeAVP("Vendor-Id", 11111))
        CER_avps.append(encodeAVP("Origin-State-Id", 1))
        CER_avps.append(encodeAVP("Supported-Vendor-Id", 10415))
        CER_avps.append(encodeAVP("Supported-Vendor-Id", 0))
        CER_avps.append(encodeAVP("Supported-Vendor-Id", 10415))
        CER_avps.append(encodeAVP("Supported-Vendor-Id", 11111))
        CER_avps.append(encodeAVP("Auth-Application-Id", 16777238))
        CER_avps.append(encodeAVP("Product-Name", "PCEF Algar"))

        # Create message header (empty)
        CER = HDRItem()
        # Set command code
        CER.cmd = dictCOMMANDname2code("Capabilities-Exchange")
        # Set Hop-by-Hop and End-to-End
        initializeHops(CER)
        # Add AVPs to header and calculate remaining fields
        msg = createReq(CER, CER_avps)
        # msg now contains CER Request as hex string
        return msg
Example #2
0
 def create_CCR_T(self, DEST_REALM):
     # Let's build Server-AssignmentRequest
     REQ_avps = []
     REQ_avps.append(encodeAVP("Session-Id", self.SESSION_ID))
     REQ_avps.append(encodeAVP("Destination-Realm", DEST_REALM))
     REQ_avps.append(encodeAVP("Auth-Application-Id", 16777238))
     REQ_avps.append(encodeAVP("Origin-Host", self.ORIGIN_HOST))
     REQ_avps.append(encodeAVP("Origin-Realm", self.ORIGIN_REALM))
     REQ_avps.append(encodeAVP("CC-Request-Type", 3))
     REQ_avps.append(encodeAVP("CC-Request-Number", 1))
     REQ_avps.append(
         encodeAVP(
             "Subscription-Id",
             [encodeAVP("Subscription-Id-Data", "1234567890"), encodeAVP("Subscription-Id-Type", 0)],
         )
     )
     REQ_avps.append(
         encodeAVP("Subscription-Id", [encodeAVP("Subscription-Id-Data", "1"), encodeAVP("Subscription-Id-Type", 1)])
     )
     REQ_avps.append(encodeAVP("Framed-IP-Address", "192.168.0.1"))
     # Create message header (empty)
     CCR = HDRItem()
     # Set command code
     CCR.cmd = dictCOMMANDname2code("Credit-Control")
     # Set Application-id
     CCR.appId = self.APPLICATION_ID
     # Set Hop-by-Hop and End-to-End
     initializeHops(CCR)
     # Set Proxyable flag
     setFlags(CCR, DIAMETER_HDR_PROXIABLE)
     # Add AVPs to header and calculate remaining fields
     ret = createReq(CCR, REQ_avps)
     # ret now contains CCR Request as hex string
     return ret
Example #3
0
 def create_DPR(self):
     # Let's build DPR
     DPR_avps = []
     DPR_avps.append(encodeAVP("Origin-Host", self.ORIGIN_HOST))
     DPR_avps.append(encodeAVP("Origin-Realm", self.ORIGIN_REALM))
     DPR_avps.append(encodeAVP("Disconnect-Cause", "DO_NOT_WANT_TO_TALK_TO_YOU"))
     DPR = HDRItem()
     DPR.cmd = dictCOMMANDname2code("Disconnect-Peer")
     initializeHops(DPR)
     # Add AVPs to header and calculate remaining fields
     msg = createReq(DPR, DPR_avps)
     # msg now contains DPR Request as hex string
     return msg