The system provides a python object for CHAP packet encapsulated in the input PPPoE packets: alc.chap.
Use alc.pppoe.getCHAP() to get the alc.chap object in the input PPPoE packet.
To apply changes to PAP packet, alc.pppoe.setCHAP(new_alc.pap_obj) need to be called.
Table: CHAP header fields provides CHAP header field information. alc.chap has following attributes to represent the CHAP header fields:
Class attributes | PAP field | Access |
---|---|---|
alc.chap.code |
Integer, code field in chap protocol header |
Read |
alc.chap.id |
Integer, identifier field in chap protocol header |
Read |
alc.chap.len |
Integer, length field in chap protocol header |
Read |
The following is a list of functions in the class:
alc.chap.getCred()
Only apply to challenge/response packet. Returns a tuple: (name, challenge, response), both are str. If either of them has 0 length, it is be ‟”; if system failed to parse the packet, such as the length < minimal_length or the packet is not challenge/response, then system raise an exception. If the packet has a wrong type it returns None (that is, no exception is raised). The second value in the returned tuple either contains the challenge (in a challenge packet) or the response (in a response packet) value.
alc.chap.setCred(chap_cred_tuple)
Only apply to challenge/response packets. Set the name and challenge to chap_cred_tuple; chap_cred_tuple is a tuple: (name, challenge, response) both are str. ‟” is allowed as the value for either of them. If packet is not challenge/response, then system raises an exception. The second value in the supplied tuple either contains the challenge (in a challenge packet) or the response (in a response packet) value.
alc.chap.getMsg()
Only apply to Success/Failure packet. Return the message in the packet as a str; return ‟” if len of message is 0; raise an exception for wrong type of packet (such as challenge). If the packet has a wrong type it returns None (that is, no exception is raised).
alc.chap.setMsg(msg)
Only apply to Success/Failure packet. set the message in the packet to parameter msg; msg is a str; ‟” is allowed; raise an exception for wrong type of packet (such as challenge).