#Next two lines are to include parent directory for testing
import sys
sys.path.append("..")
# Remove them normally

import eap
import logging

if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)
    #logging.basicConfig(level=logging.INFO)
    eap.LoadEAPDictionary("../dictEAP.xml")
    EAP = eap.EAPItem()
    # Set command code
    # Remember - Requests normally starts from AAA-> UE, so
    # even when skipped, identity is actually an response
    EAP.cmd = eap.EAP_CODE_RESPONSE
    # Set id
    EAP.id = 1
    # Set type
    EAP.type = eap.EAP_TYPE_AKA
    # Set sub-type
    EAP.stype = eap.dictEAPSUBname2type("AKA-Identity")
    I = "0031303231313131323334353631303540776c616e2e6d6e633032332e6d63633236322e336770706e6574776f726b2e6f7267"
    print len(I), len(I) / 4, len(I) / 8
    IDENTITY = I.decode("hex")
    EAP.avps.append(("AT_IDENTITY", IDENTITY.encode("hex")))
    Payload = eap.encode_EAP(EAP)
    print "S Payload", Payload
    # Payload now contains EAP-Payload AVP
    E = eap.decode_EAP(Payload)
Example #2
0
########## VOID MAIN ###########

if __name__ == "__main__":
    logger.info('%s is started: %s', sys.argv[0], sys.argv[1:])
    logger.debug('Number of arguments: %s arguments.', len(sys.argv))
    if len(sys.argv) < 4:
        logger.debug("program started with empty parameters")
        print HELP.format(APP_NAME=sys.argv[0],
                          UDR=UDR_Template.keys(),
                          ALL_SI=ALL_SI_items)
        logger.debug("exiting")
        exit()

    LoadDictionary(pyprotosim_dict_path + "/dictDiameter.xml")
    eap.LoadEAPDictionary(pyprotosim_dict_path + "/dictEAP.xml")

    # ACTION: UDR / PUR / SNR
    # OPT: Service-Indicator or Data-Reference
    (ACTION, MSISDN, OPT) = sys.argv[1:4]

    #    ACTION = sys.argv[1]

    #    IMSI = sys.argv[2]
    #    MSISDN = sys.argv[3]

    IMSI = MSISDN

    #    OPT = sys.argv[4]

    #    PUBLIC_IDENTITY=params["IMPU_format"].format(IDENTITY = IDENTITY,IMPU_domain = params["IMPU_domain"] )