1*7dc08ffcSJunyu Lai############################## 2*7dc08ffcSJunyu Lai% PPTP Related regression tests 3*7dc08ffcSJunyu Lai############################## 4*7dc08ffcSJunyu Lai 5*7dc08ffcSJunyu Lai+ GRE Tests 6*7dc08ffcSJunyu Lai 7*7dc08ffcSJunyu Lai= Test IP/GRE v0 decoding 8*7dc08ffcSJunyu Lai~ gre ip 9*7dc08ffcSJunyu Lai 10*7dc08ffcSJunyu Laidata = hex_bytes('45c00064000f0000ff2f1647c0a80c01c0a8170300000800') 11*7dc08ffcSJunyu Laipkt = IP(data) 12*7dc08ffcSJunyu Laiassert GRE in pkt 13*7dc08ffcSJunyu Laigre = pkt[GRE] 14*7dc08ffcSJunyu Laiassert gre.chksum_present == 0 15*7dc08ffcSJunyu Laiassert gre.routing_present == 0 16*7dc08ffcSJunyu Laiassert gre.key_present == 0 17*7dc08ffcSJunyu Laiassert gre.seqnum_present == 0 18*7dc08ffcSJunyu Laiassert gre.strict_route_source == 0 19*7dc08ffcSJunyu Laiassert gre.recursion_control == 0 20*7dc08ffcSJunyu Laiassert gre.flags == 0 21*7dc08ffcSJunyu Laiassert gre.version == 0 22*7dc08ffcSJunyu Laiassert gre.proto == 0x800 23*7dc08ffcSJunyu Lai 24*7dc08ffcSJunyu Lai= Test IP/GRE v1 decoding with PPP LCP 25*7dc08ffcSJunyu Lai~ gre ip pptp ppp lcp 26*7dc08ffcSJunyu Lai 27*7dc08ffcSJunyu Laidata = hex_bytes('4500003c18324000402f0e5a0a0000020a0000063001880b001c9bf500000000ff03'\ 28*7dc08ffcSJunyu Lai 'c021010100180206000000000304c2270506fbb8831007020802') 29*7dc08ffcSJunyu Laipkt = IP(data) 30*7dc08ffcSJunyu Laiassert GRE_PPTP in pkt 31*7dc08ffcSJunyu Laigre_pptp = pkt[GRE_PPTP] 32*7dc08ffcSJunyu Laiassert gre_pptp.chksum_present == 0 33*7dc08ffcSJunyu Laiassert gre_pptp.routing_present == 0 34*7dc08ffcSJunyu Laiassert gre_pptp.key_present == 1 35*7dc08ffcSJunyu Laiassert gre_pptp.seqnum_present == 1 36*7dc08ffcSJunyu Laiassert gre_pptp.strict_route_source == 0 37*7dc08ffcSJunyu Laiassert gre_pptp.recursion_control == 0 38*7dc08ffcSJunyu Laiassert gre_pptp.acknum_present == 0 39*7dc08ffcSJunyu Laiassert gre_pptp.flags == 0 40*7dc08ffcSJunyu Laiassert gre_pptp.version == 1 41*7dc08ffcSJunyu Laiassert gre_pptp.proto == 0x880b 42*7dc08ffcSJunyu Laiassert gre_pptp.payload_len == 28 43*7dc08ffcSJunyu Laiassert gre_pptp.call_id == 39925 44*7dc08ffcSJunyu Laiassert gre_pptp.seqence_number == 0x0 45*7dc08ffcSJunyu Lai 46*7dc08ffcSJunyu Laiassert HDLC in pkt 47*7dc08ffcSJunyu Laiassert PPP in pkt 48*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in pkt 49*7dc08ffcSJunyu Lai 50*7dc08ffcSJunyu Lai= Test IP/GRE v1 encoding/decoding with PPP LCP Echo 51*7dc08ffcSJunyu Lai~ gre ip pptp ppp hdlc lcp lcp_echo 52*7dc08ffcSJunyu Lai 53*7dc08ffcSJunyu Laipkt = IP(src='192.168.0.1', dst='192.168.0.2') /\ 54*7dc08ffcSJunyu Lai GRE_PPTP(seqnum_present=1, acknum_present=1, seqence_number=47, ack_number=42) /\ 55*7dc08ffcSJunyu Lai HDLC() / PPP() / PPP_LCP_Echo(id=42, magic_number=4242, data='abcdef') 56*7dc08ffcSJunyu Laipkt_data = raw(pkt) 57*7dc08ffcSJunyu Laipkt_data_ref = hex_bytes('4500003600010000402ff944c0a80001c0a800023081880b001200000000002f000000'\ 58*7dc08ffcSJunyu Lai '2aff03c021092a000e00001092616263646566') 59*7dc08ffcSJunyu Laiassert (pkt_data == pkt_data_ref) 60*7dc08ffcSJunyu Laipkt_decoded = IP(pkt_data_ref) 61*7dc08ffcSJunyu Laiassert IP in pkt 62*7dc08ffcSJunyu Laiassert GRE_PPTP in pkt 63*7dc08ffcSJunyu Laiassert HDLC in pkt 64*7dc08ffcSJunyu Laiassert PPP in pkt 65*7dc08ffcSJunyu Laiassert PPP_LCP_Echo in pkt 66*7dc08ffcSJunyu Lai 67*7dc08ffcSJunyu Laiassert pkt[IP].proto == 47 68*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].chksum_present == 0 69*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].routing_present == 0 70*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].key_present == 1 71*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].seqnum_present == 1 72*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].acknum_present == 1 73*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].seqence_number == 47 74*7dc08ffcSJunyu Laiassert pkt[GRE_PPTP].ack_number == 42 75*7dc08ffcSJunyu Laiassert pkt[PPP].proto == 0xc021 76*7dc08ffcSJunyu Laiassert pkt[PPP_LCP_Echo].code == 9 77*7dc08ffcSJunyu Laiassert pkt[PPP_LCP_Echo].id == 42 78*7dc08ffcSJunyu Laiassert pkt[PPP_LCP_Echo].magic_number == 4242 79*7dc08ffcSJunyu Laiassert pkt[PPP_LCP_Echo].data == b'abcdef' 80*7dc08ffcSJunyu Lai 81*7dc08ffcSJunyu Lai+ PPP LCP Tests 82*7dc08ffcSJunyu Lai= Test LCP Echo Request / Reply 83*7dc08ffcSJunyu Lai~ ppp lcp lcp_echo 84*7dc08ffcSJunyu Lai 85*7dc08ffcSJunyu Lailcp_echo_request_data = hex_bytes('c021090700080000002a') 86*7dc08ffcSJunyu Lailcp_echo_reply_data = raw(PPP()/PPP_LCP_Echo(code=10, id=7, magic_number=77, data='defgh')) 87*7dc08ffcSJunyu Lai 88*7dc08ffcSJunyu Lailcp_echo_request_pkt = PPP(lcp_echo_request_data) 89*7dc08ffcSJunyu Lailcp_echo_reply_pkt = PPP(lcp_echo_reply_data) 90*7dc08ffcSJunyu Lai 91*7dc08ffcSJunyu Laiassert lcp_echo_reply_pkt.answers(lcp_echo_request_pkt) 92*7dc08ffcSJunyu Laiassert not lcp_echo_request_pkt.answers(lcp_echo_reply_pkt) 93*7dc08ffcSJunyu Lai 94*7dc08ffcSJunyu Lailcp_echo_non_reply_data = raw(PPP()/PPP_LCP_Echo(code=10, id=3, magic_number=77)) 95*7dc08ffcSJunyu Lailcp_echo_non_reply_pkt = PPP(lcp_echo_non_reply_data) 96*7dc08ffcSJunyu Lai 97*7dc08ffcSJunyu Laiassert not lcp_echo_non_reply_pkt.answers(lcp_echo_request_pkt) 98*7dc08ffcSJunyu Lai 99*7dc08ffcSJunyu Lailcp_echo_non_reply_data = raw(PPP()/PPP_LCP_Echo(id=7, magic_number=42)) 100*7dc08ffcSJunyu Lailcp_echo_non_reply_pkt = PPP(lcp_echo_non_reply_data) 101*7dc08ffcSJunyu Lai 102*7dc08ffcSJunyu Laiassert not lcp_echo_non_reply_pkt.answers(lcp_echo_request_pkt) 103*7dc08ffcSJunyu Lai 104*7dc08ffcSJunyu Lai= Test LCP Configure Request 105*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure magic_number 106*7dc08ffcSJunyu Lai 107*7dc08ffcSJunyu Laiconf_req = PPP() / PPP_LCP_Configure(id=42, options=[PPP_LCP_Magic_Number_Option(magic_number=4242)]) 108*7dc08ffcSJunyu Laiconf_req_ref_data = hex_bytes('c021012a000a050600001092') 109*7dc08ffcSJunyu Lai 110*7dc08ffcSJunyu Laiassert raw(conf_req) == conf_req_ref_data 111*7dc08ffcSJunyu Lai 112*7dc08ffcSJunyu Laiconf_req_pkt = PPP(conf_req_ref_data) 113*7dc08ffcSJunyu Lai 114*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in conf_req_pkt 115*7dc08ffcSJunyu Laiassert conf_req_pkt[PPP_LCP_Configure].code == 1 116*7dc08ffcSJunyu Laiassert conf_req_pkt[PPP_LCP_Configure].id == 42 117*7dc08ffcSJunyu Laiassert len(conf_req_pkt[PPP_LCP_Configure].options) == 1 118*7dc08ffcSJunyu Laiassert isinstance(conf_req_pkt[PPP_LCP_Configure].options[0], PPP_LCP_Magic_Number_Option) 119*7dc08ffcSJunyu Laiassert conf_req_pkt[PPP_LCP_Configure].options[0].magic_number == 4242 120*7dc08ffcSJunyu Lai 121*7dc08ffcSJunyu Lai= Test LCP Configure Ack 122*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure lcp_configure_ack 123*7dc08ffcSJunyu Lai 124*7dc08ffcSJunyu Laiconf_ack = PPP() / PPP_LCP_Configure(code='Configure-Ack', id=42, 125*7dc08ffcSJunyu Lai options=[PPP_LCP_Magic_Number_Option(magic_number=4242)]) 126*7dc08ffcSJunyu Laiconf_ack_ref_data = hex_bytes('c021022a000a050600001092') 127*7dc08ffcSJunyu Lai 128*7dc08ffcSJunyu Laiassert (raw(conf_ack) == conf_ack_ref_data) 129*7dc08ffcSJunyu Lai 130*7dc08ffcSJunyu Laiconf_ack_pkt = PPP(conf_ack_ref_data) 131*7dc08ffcSJunyu Lai 132*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in conf_ack_pkt 133*7dc08ffcSJunyu Laiassert conf_ack_pkt[PPP_LCP_Configure].code == 2 134*7dc08ffcSJunyu Laiassert conf_ack_pkt[PPP_LCP_Configure].id == 42 135*7dc08ffcSJunyu Laiassert len(conf_ack_pkt[PPP_LCP_Configure].options) == 1 136*7dc08ffcSJunyu Laiassert isinstance(conf_ack_pkt[PPP_LCP_Configure].options[0], PPP_LCP_Magic_Number_Option) 137*7dc08ffcSJunyu Laiassert conf_ack_pkt[PPP_LCP_Configure].options[0].magic_number == 4242 138*7dc08ffcSJunyu Lai 139*7dc08ffcSJunyu Laiconf_req_pkt = PPP(hex_bytes('c021012a000a050600001092')) 140*7dc08ffcSJunyu Lai 141*7dc08ffcSJunyu Laiassert conf_ack_pkt.answers(conf_req_pkt) 142*7dc08ffcSJunyu Laiassert not conf_req_pkt.answers(conf_ack_pkt) 143*7dc08ffcSJunyu Lai 144*7dc08ffcSJunyu Lai= Test LCP Configure Nak 145*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure lcp_configure_nak lcp_mru_option lcp_accm_option 146*7dc08ffcSJunyu Lai 147*7dc08ffcSJunyu Laiconf_nak = PPP() / PPP_LCP_Configure(code='Configure-Nak', id=42, 148*7dc08ffcSJunyu Lai options=[PPP_LCP_MRU_Option(), PPP_LCP_ACCM_Option(accm=0xffff0000)]) 149*7dc08ffcSJunyu Laiconf_nak_ref_data = hex_bytes('c021032a000e010405dc0206ffff0000') 150*7dc08ffcSJunyu Lai 151*7dc08ffcSJunyu Laiassert(raw(conf_nak) == conf_nak_ref_data) 152*7dc08ffcSJunyu Lai 153*7dc08ffcSJunyu Laiconf_nak_pkt = PPP(conf_nak_ref_data) 154*7dc08ffcSJunyu Lai 155*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in conf_nak_pkt 156*7dc08ffcSJunyu Laiassert conf_nak_pkt[PPP_LCP_Configure].code == 3 157*7dc08ffcSJunyu Laiassert conf_nak_pkt[PPP_LCP_Configure].id == 42 158*7dc08ffcSJunyu Laiassert len(conf_nak_pkt[PPP_LCP_Configure].options) == 2 159*7dc08ffcSJunyu Laiassert isinstance(conf_nak_pkt[PPP_LCP_Configure].options[0], PPP_LCP_MRU_Option) 160*7dc08ffcSJunyu Laiassert conf_nak_pkt[PPP_LCP_Configure].options[0].max_recv_unit == 1500 161*7dc08ffcSJunyu Laiassert isinstance(conf_nak_pkt[PPP_LCP_Configure].options[1], PPP_LCP_ACCM_Option) 162*7dc08ffcSJunyu Laiassert conf_nak_pkt[PPP_LCP_Configure].options[1].accm == 0xffff0000 163*7dc08ffcSJunyu Lai 164*7dc08ffcSJunyu Laiconf_req_pkt = PPP(hex_bytes('c021012a000e010405dc0206ffff0000')) 165*7dc08ffcSJunyu Lai 166*7dc08ffcSJunyu Laiassert conf_nak_pkt.answers(conf_req_pkt) 167*7dc08ffcSJunyu Laiassert not conf_req_pkt.answers(conf_nak_pkt) 168*7dc08ffcSJunyu Lai 169*7dc08ffcSJunyu Lai= Test LCP Configure Reject 170*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure lcp_configure_reject 171*7dc08ffcSJunyu Lai 172*7dc08ffcSJunyu Laiconf_reject = PPP() / PPP_LCP_Configure(code='Configure-Reject', id=42, 173*7dc08ffcSJunyu Lai options=[PPP_LCP_Callback_Option(operation='Location identifier', 174*7dc08ffcSJunyu Lai message='test')]) 175*7dc08ffcSJunyu Laiconf_reject_ref_data = hex_bytes('c021042a000b0d070274657374') 176*7dc08ffcSJunyu Lai 177*7dc08ffcSJunyu Laiassert(raw(conf_reject) == conf_reject_ref_data) 178*7dc08ffcSJunyu Lai 179*7dc08ffcSJunyu Laiconf_reject_pkt = PPP(conf_reject_ref_data) 180*7dc08ffcSJunyu Lai 181*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in conf_reject_pkt 182*7dc08ffcSJunyu Laiassert conf_reject_pkt[PPP_LCP_Configure].code == 4 183*7dc08ffcSJunyu Laiassert conf_reject_pkt[PPP_LCP_Configure].id == 42 184*7dc08ffcSJunyu Laiassert len(conf_reject_pkt[PPP_LCP_Configure].options) == 1 185*7dc08ffcSJunyu Laiassert isinstance(conf_reject_pkt[PPP_LCP_Configure].options[0], PPP_LCP_Callback_Option) 186*7dc08ffcSJunyu Laiassert conf_reject_pkt[PPP_LCP_Configure].options[0].operation == 2 187*7dc08ffcSJunyu Laiassert conf_reject_pkt[PPP_LCP_Configure].options[0].message == b'test' 188*7dc08ffcSJunyu Lai 189*7dc08ffcSJunyu Laiconf_req_pkt = PPP(hex_bytes('c021012a000b0d070274657374')) 190*7dc08ffcSJunyu Lai 191*7dc08ffcSJunyu Laiassert conf_reject_pkt.answers(conf_req_pkt) 192*7dc08ffcSJunyu Laiassert not conf_req_pkt.answers(conf_reject_pkt) 193*7dc08ffcSJunyu Lai 194*7dc08ffcSJunyu Lai= Test LCP Configure options 195*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure 196*7dc08ffcSJunyu Lai 197*7dc08ffcSJunyu Laiconf_req = PPP() / PPP_LCP_Configure(id=42, options=[PPP_LCP_MRU_Option(max_recv_unit=5000), 198*7dc08ffcSJunyu Lai PPP_LCP_ACCM_Option(accm=0xf0f0f0f0), 199*7dc08ffcSJunyu Lai PPP_LCP_Auth_Protocol_Option(), 200*7dc08ffcSJunyu Lai PPP_LCP_Quality_Protocol_Option(data='test'), 201*7dc08ffcSJunyu Lai PPP_LCP_Magic_Number_Option(magic_number=4242), 202*7dc08ffcSJunyu Lai PPP_LCP_Callback_Option(operation='Distinguished name',message='test')]) 203*7dc08ffcSJunyu Laiconf_req_ref_data = hex_bytes('c021012a0027010413880206f0f0f0f00304c0230408c025746573740506000010920d070474657374') 204*7dc08ffcSJunyu Lai 205*7dc08ffcSJunyu Laiassert(raw(conf_req) == conf_req_ref_data) 206*7dc08ffcSJunyu Lai 207*7dc08ffcSJunyu Laiconf_req_pkt = PPP(conf_req_ref_data) 208*7dc08ffcSJunyu Lai 209*7dc08ffcSJunyu Laiassert PPP_LCP_Configure in conf_req_pkt 210*7dc08ffcSJunyu Laioptions = conf_req_pkt[PPP_LCP_Configure].options 211*7dc08ffcSJunyu Laiassert len(options) == 6 212*7dc08ffcSJunyu Laiassert isinstance(options[0], PPP_LCP_MRU_Option) 213*7dc08ffcSJunyu Laiassert options[0].max_recv_unit == 5000 214*7dc08ffcSJunyu Laiassert isinstance(options[1], PPP_LCP_ACCM_Option) 215*7dc08ffcSJunyu Laiassert options[1].accm == 0xf0f0f0f0 216*7dc08ffcSJunyu Laiassert isinstance(options[2], PPP_LCP_Auth_Protocol_Option) 217*7dc08ffcSJunyu Laiassert options[2].auth_protocol == 0xc023 218*7dc08ffcSJunyu Laiassert isinstance(options[3], PPP_LCP_Quality_Protocol_Option) 219*7dc08ffcSJunyu Laiassert options[3].quality_protocol == 0xc025 220*7dc08ffcSJunyu Laiassert options[3].data == b'test' 221*7dc08ffcSJunyu Laiassert isinstance(options[4], PPP_LCP_Magic_Number_Option) 222*7dc08ffcSJunyu Laiassert options[4].magic_number == 4242 223*7dc08ffcSJunyu Laiassert isinstance(options[5], PPP_LCP_Callback_Option) 224*7dc08ffcSJunyu Laiassert options[5].operation == 4 225*7dc08ffcSJunyu Laiassert options[5].message == b'test' 226*7dc08ffcSJunyu Lai 227*7dc08ffcSJunyu Lai= Test LCP Auth option 228*7dc08ffcSJunyu Lai~ ppp lcp lcp_configure 229*7dc08ffcSJunyu Lai 230*7dc08ffcSJunyu Laipap = PPP_LCP_Auth_Protocol_Option() 231*7dc08ffcSJunyu Laipap_ref_data = hex_bytes('0304c023') 232*7dc08ffcSJunyu Lai 233*7dc08ffcSJunyu Laiassert(raw(pap) == pap_ref_data) 234*7dc08ffcSJunyu Lai 235*7dc08ffcSJunyu Laipap_pkt = PPP_LCP_Option(pap_ref_data) 236*7dc08ffcSJunyu Laiassert isinstance(pap_pkt, PPP_LCP_Auth_Protocol_Option) 237*7dc08ffcSJunyu Laiassert pap_pkt.auth_protocol == 0xc023 238*7dc08ffcSJunyu Lai 239*7dc08ffcSJunyu Laichap_sha1 = PPP_LCP_Auth_Protocol_Option(auth_protocol='Challenge-response authentication protocol', algorithm="SHA1") 240*7dc08ffcSJunyu Laichap_sha1_ref_data = hex_bytes('0305c22306') 241*7dc08ffcSJunyu Lai 242*7dc08ffcSJunyu Laiassert raw(chap_sha1) == chap_sha1_ref_data 243*7dc08ffcSJunyu Lai 244*7dc08ffcSJunyu Laichap_sha1_pkt = PPP_LCP_Option(chap_sha1_ref_data) 245*7dc08ffcSJunyu Laiassert isinstance(chap_sha1_pkt, PPP_LCP_Auth_Protocol_Option) 246*7dc08ffcSJunyu Laiassert chap_sha1_pkt.auth_protocol == 0xc223 247*7dc08ffcSJunyu Laiassert chap_sha1_pkt.algorithm == 6 248*7dc08ffcSJunyu Lai 249*7dc08ffcSJunyu Laieap = PPP_LCP_Auth_Protocol_Option(auth_protocol='PPP Extensible authentication protocol', data='test') 250*7dc08ffcSJunyu Laieap_ref_data = hex_bytes('0308c22774657374') 251*7dc08ffcSJunyu Lai 252*7dc08ffcSJunyu Laiassert raw(eap) == eap_ref_data 253*7dc08ffcSJunyu Lai 254*7dc08ffcSJunyu Laieap_pkt = PPP_LCP_Option(eap_ref_data) 255*7dc08ffcSJunyu Laiassert isinstance(eap_pkt, PPP_LCP_Auth_Protocol_Option) 256*7dc08ffcSJunyu Laiassert eap_pkt.auth_protocol == 0xc227 257*7dc08ffcSJunyu Laiassert eap_pkt.data == b'test' 258*7dc08ffcSJunyu Lai 259*7dc08ffcSJunyu Lai= Test LCP Code-Reject 260*7dc08ffcSJunyu Lai~ ppp lcp lcp_code_reject 261*7dc08ffcSJunyu Lai 262*7dc08ffcSJunyu Laicode_reject = PPP() / PPP_LCP_Code_Reject(id=42, rejected_packet=PPP_LCP(code=42, id=7, data='unknown_data')) 263*7dc08ffcSJunyu Laicode_reject_ref_data = hex_bytes('c021072a00142a070010756e6b6e6f776e5f64617461') 264*7dc08ffcSJunyu Lai 265*7dc08ffcSJunyu Laiassert raw(code_reject) == code_reject_ref_data 266*7dc08ffcSJunyu Lai 267*7dc08ffcSJunyu Laicode_reject_pkt = PPP(code_reject_ref_data) 268*7dc08ffcSJunyu Laiassert PPP_LCP_Code_Reject in code_reject_pkt 269*7dc08ffcSJunyu Laiassert code_reject_pkt[PPP_LCP_Code_Reject].id == 42 270*7dc08ffcSJunyu Laiassert isinstance(code_reject_pkt[PPP_LCP_Code_Reject].rejected_packet, PPP_LCP) 271*7dc08ffcSJunyu Laiassert code_reject[PPP_LCP_Code_Reject].rejected_packet.code == 42 272*7dc08ffcSJunyu Laiassert code_reject[PPP_LCP_Code_Reject].rejected_packet.id == 7 273*7dc08ffcSJunyu Laiassert code_reject[PPP_LCP_Code_Reject].rejected_packet.data == b'unknown_data' 274*7dc08ffcSJunyu Lai 275*7dc08ffcSJunyu Lai= Test LCP Protocol-Reject 276*7dc08ffcSJunyu Lai~ ppp lcp lcp_protocol_reject 277*7dc08ffcSJunyu Lai 278*7dc08ffcSJunyu Laiprotocol_reject = PPP() / PPP_LCP_Protocol_Reject(id=42, rejected_protocol=0x8039, 279*7dc08ffcSJunyu Lai rejected_information=Packet(hex_bytes('0305c22306'))) 280*7dc08ffcSJunyu Laiprotocol_reject_ref_data = hex_bytes('c021082a000b80390305c22306') 281*7dc08ffcSJunyu Lai 282*7dc08ffcSJunyu Laiassert raw(protocol_reject) == protocol_reject_ref_data 283*7dc08ffcSJunyu Lai 284*7dc08ffcSJunyu Laiprotocol_reject_pkt = PPP(protocol_reject_ref_data) 285*7dc08ffcSJunyu Laiassert PPP_LCP_Protocol_Reject in protocol_reject_pkt 286*7dc08ffcSJunyu Laiassert protocol_reject_pkt[PPP_LCP_Protocol_Reject].id == 42 287*7dc08ffcSJunyu Laiassert protocol_reject_pkt[PPP_LCP_Protocol_Reject].rejected_protocol == 0x8039 288*7dc08ffcSJunyu Laiassert len(protocol_reject_pkt[PPP_LCP_Protocol_Reject].rejected_information) == 5 289*7dc08ffcSJunyu Lai 290*7dc08ffcSJunyu Lai= Test LCP Discard Request 291*7dc08ffcSJunyu Lai~ ppp lcp lcp_discard_request 292*7dc08ffcSJunyu Lai 293*7dc08ffcSJunyu Laidiscard_request = PPP() / PPP_LCP_Discard_Request(id=7, magic_number=4242, data='test') 294*7dc08ffcSJunyu Laidiscard_request_ref_data = hex_bytes('c0210b07000c0000109274657374') 295*7dc08ffcSJunyu Lai 296*7dc08ffcSJunyu Laiassert raw(discard_request) == discard_request_ref_data 297*7dc08ffcSJunyu Lai 298*7dc08ffcSJunyu Laidiscard_request_pkt = PPP(discard_request_ref_data) 299*7dc08ffcSJunyu Laiassert PPP_LCP_Discard_Request in discard_request_pkt 300*7dc08ffcSJunyu Laiassert discard_request_pkt[PPP_LCP_Discard_Request].id == 7 301*7dc08ffcSJunyu Laiassert discard_request_pkt[PPP_LCP_Discard_Request].magic_number == 4242 302*7dc08ffcSJunyu Laiassert discard_request_pkt[PPP_LCP_Discard_Request].data == b'test' 303*7dc08ffcSJunyu Lai 304*7dc08ffcSJunyu Lai= Test LCP Terminate-Request/Terminate-Ack 305*7dc08ffcSJunyu Lai~ ppp lcp lcp_terminate 306*7dc08ffcSJunyu Lai 307*7dc08ffcSJunyu Laiterminate_request = PPP() / PPP_LCP_Terminate(id=7, data='test') 308*7dc08ffcSJunyu Laiterminate_request_ref_data = hex_bytes('c0210507000874657374') 309*7dc08ffcSJunyu Lai 310*7dc08ffcSJunyu Laiassert raw(terminate_request) == terminate_request_ref_data 311*7dc08ffcSJunyu Lai 312*7dc08ffcSJunyu Laiterminate_request_pkt = PPP(terminate_request_ref_data) 313*7dc08ffcSJunyu Laiassert PPP_LCP_Terminate in terminate_request_pkt 314*7dc08ffcSJunyu Laiassert terminate_request_pkt[PPP_LCP_Terminate].code == 5 315*7dc08ffcSJunyu Laiassert terminate_request_pkt[PPP_LCP_Terminate].id == 7 316*7dc08ffcSJunyu Laiassert terminate_request_pkt[PPP_LCP_Terminate].data == b'test' 317*7dc08ffcSJunyu Lai 318*7dc08ffcSJunyu Laiterminate_ack = PPP() / PPP_LCP_Terminate(code='Terminate-Ack', id=7) 319*7dc08ffcSJunyu Laiterminate_ack_ref_data = hex_bytes('c02106070004') 320*7dc08ffcSJunyu Lai 321*7dc08ffcSJunyu Laiassert raw(terminate_ack) == terminate_ack_ref_data 322*7dc08ffcSJunyu Lai 323*7dc08ffcSJunyu Laiterminate_ack_pkt = PPP(terminate_ack_ref_data) 324*7dc08ffcSJunyu Laiassert PPP_LCP_Terminate in terminate_ack_pkt 325*7dc08ffcSJunyu Laiassert terminate_ack_pkt[PPP_LCP_Terminate].code == 6 326*7dc08ffcSJunyu Laiassert terminate_ack_pkt[PPP_LCP_Terminate].id == 7 327*7dc08ffcSJunyu Lai 328*7dc08ffcSJunyu Laiassert terminate_ack_pkt.answers(terminate_request_pkt) 329*7dc08ffcSJunyu Laiassert not terminate_request_pkt.answers(terminate_ack_pkt) 330*7dc08ffcSJunyu Lai 331*7dc08ffcSJunyu Lai+ PPP PAP Tests 332*7dc08ffcSJunyu Lai= Test PPP PAP Request 333*7dc08ffcSJunyu Lai~ ppp pap pap_request 334*7dc08ffcSJunyu Laipap_request = PPP() / PPP_PAP_Request(id=42, username='administrator', password='secret_password') 335*7dc08ffcSJunyu Laipap_request_ref_data = hex_bytes('c023012a00220d61646d696e6973747261746f720f7365637265745f70617373776f7264') 336*7dc08ffcSJunyu Lai 337*7dc08ffcSJunyu Laiassert raw(pap_request) == pap_request_ref_data 338*7dc08ffcSJunyu Lai 339*7dc08ffcSJunyu Laipap_request_pkt = PPP(pap_request_ref_data) 340*7dc08ffcSJunyu Laiassert PPP_PAP_Request in pap_request_pkt 341*7dc08ffcSJunyu Laiassert pap_request_pkt[PPP_PAP_Request].code == 1 342*7dc08ffcSJunyu Laiassert pap_request_pkt[PPP_PAP_Request].id == 42 343*7dc08ffcSJunyu Laiassert pap_request_pkt[PPP_PAP_Request].username == b'administrator' 344*7dc08ffcSJunyu Laiassert pap_request_pkt[PPP_PAP_Request].password == b'secret_password' 345*7dc08ffcSJunyu Laiassert pap_request_pkt[PPP_PAP_Request].summary() in ['PAP-Request username=\'administrator\' password=\'secret_password\'', 346*7dc08ffcSJunyu Lai 'PAP-Request username=b\'administrator\' password=b\'secret_password\''] 347*7dc08ffcSJunyu Lai 348*7dc08ffcSJunyu Lai= Test PPP PAP Authenticate-Ack 349*7dc08ffcSJunyu Lai~ ppp pap pap_response pap_ack 350*7dc08ffcSJunyu Laipap_response = PPP() / PPP_PAP(code='Authenticate-Ack', id=42) 351*7dc08ffcSJunyu Laipap_response_ref_data = hex_bytes('c023022a000500') 352*7dc08ffcSJunyu Lai 353*7dc08ffcSJunyu Laiassert raw(pap_response) == pap_response_ref_data 354*7dc08ffcSJunyu Lai 355*7dc08ffcSJunyu Laipap_response_pkt = PPP(pap_response_ref_data) 356*7dc08ffcSJunyu Laiassert PPP_PAP_Response in pap_response_pkt 357*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].code == 2 358*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].id == 42 359*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].msg_len == 0 360*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].message == b'' 361*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].summary() == 'PAP-Ack' 362*7dc08ffcSJunyu Lai 363*7dc08ffcSJunyu Laipap_request_pkt = PPP(hex_bytes('c023012a00220d61646d696e6973747261746f720f7365637265745f70617373776f7264')) 364*7dc08ffcSJunyu Laiassert pap_response_pkt.answers(pap_request_pkt) 365*7dc08ffcSJunyu Laiassert not pap_request_pkt.answers(pap_response_pkt) 366*7dc08ffcSJunyu Lai 367*7dc08ffcSJunyu Lai= Test PPP PAP Authenticate-Nak 368*7dc08ffcSJunyu Lai~ ppp pap pap_response pap_nak 369*7dc08ffcSJunyu Laipap_response = PPP() / PPP_PAP(code=3, id=42, message='Bad password') 370*7dc08ffcSJunyu Laipap_response_ref_data = hex_bytes('c023032a00110c4261642070617373776f7264') 371*7dc08ffcSJunyu Lai 372*7dc08ffcSJunyu Laiassert raw(pap_response) == pap_response_ref_data 373*7dc08ffcSJunyu Lai 374*7dc08ffcSJunyu Laipap_response_pkt = PPP(pap_response_ref_data) 375*7dc08ffcSJunyu Laiassert PPP_PAP_Response in pap_response_pkt 376*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].code == 3 377*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].id == 42 378*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].msg_len == len('Bad password') 379*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].message == b'Bad password' 380*7dc08ffcSJunyu Laiassert pap_response_pkt[PPP_PAP_Response].summary() in ['PAP-Nak msg=\'Bad password\'', 'PAP-Nak msg=b\'Bad password\''] 381*7dc08ffcSJunyu Lai 382*7dc08ffcSJunyu Laipap_request_pkt = PPP(hex_bytes('c023012a00220d61646d696e6973747261746f720f7365637265745f70617373776f7264')) 383*7dc08ffcSJunyu Laiassert pap_response_pkt.answers(pap_request_pkt) 384*7dc08ffcSJunyu Laiassert not pap_request_pkt.answers(pap_response_pkt) 385*7dc08ffcSJunyu Lai 386*7dc08ffcSJunyu Lai+ PPP CHAP Tests 387*7dc08ffcSJunyu Lai= Test PPP CHAP Challenge 388*7dc08ffcSJunyu Lai~ ppp chap chap_challenge 389*7dc08ffcSJunyu Laichap_challenge = PPP() / PPP_CHAP(code=1, id=47, value=b'B' * 7, 390*7dc08ffcSJunyu Lai optional_name='server') 391*7dc08ffcSJunyu Laichap_challenge_ref_data = hex_bytes('c223012f00120742424242424242736572766572') 392*7dc08ffcSJunyu Lai 393*7dc08ffcSJunyu Laiassert raw(chap_challenge) == chap_challenge_ref_data 394*7dc08ffcSJunyu Lai 395*7dc08ffcSJunyu Laichap_challenge_pkt = PPP(chap_challenge_ref_data) 396*7dc08ffcSJunyu Laiassert PPP_CHAP_ChallengeResponse in chap_challenge_pkt 397*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].code == 1 398*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].id == 47 399*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].value_size == 7 400*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].value == b'B' * 7 401*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].optional_name == b'server' 402*7dc08ffcSJunyu Laiassert chap_challenge_pkt[PPP_CHAP_ChallengeResponse].summary() in ['CHAP challenge=0x42424242424242 optional_name=\'server\'', 403*7dc08ffcSJunyu Lai 'CHAP challenge=0x42424242424242 optional_name=b\'server\''] 404*7dc08ffcSJunyu Lai 405*7dc08ffcSJunyu Lai= Test PPP CHAP Response 406*7dc08ffcSJunyu Lai~ ppp chap chap_response 407*7dc08ffcSJunyu Laichap_response = PPP() / PPP_CHAP(code='Response', id=47, value=b'\x00' * 16, optional_name='client') 408*7dc08ffcSJunyu Laichap_response_ref_data = hex_bytes('c223022f001b1000000000000000000000000000000000636c69656e74') 409*7dc08ffcSJunyu Lai 410*7dc08ffcSJunyu Laiassert raw(chap_response) == chap_response_ref_data 411*7dc08ffcSJunyu Lai 412*7dc08ffcSJunyu Laichap_response_pkt = PPP(chap_response_ref_data) 413*7dc08ffcSJunyu Laiassert PPP_CHAP_ChallengeResponse in chap_response_pkt 414*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].code == 2 415*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].id == 47 416*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].value_size == 16 417*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].value == b'\x00' * 16 418*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].optional_name == b'client' 419*7dc08ffcSJunyu Laiassert chap_response_pkt[PPP_CHAP_ChallengeResponse].summary() in ['CHAP response=0x00000000000000000000000000000000 optional_name=\'client\'', 420*7dc08ffcSJunyu Lai 'CHAP response=0x00000000000000000000000000000000 optional_name=b\'client\''] 421*7dc08ffcSJunyu Lai 422*7dc08ffcSJunyu Laichap_request = PPP(hex_bytes('c223012f00120742424242424242736572766572')) 423*7dc08ffcSJunyu Lai 424*7dc08ffcSJunyu Laiassert chap_response.answers(chap_challenge) 425*7dc08ffcSJunyu Laiassert not chap_challenge.answers(chap_response) 426*7dc08ffcSJunyu Lai 427*7dc08ffcSJunyu Lai= Test PPP CHAP Success 428*7dc08ffcSJunyu Lai~ ppp chap chap_success 429*7dc08ffcSJunyu Lai 430*7dc08ffcSJunyu Laichap_success = PPP() / PPP_CHAP(code='Success', id=47) 431*7dc08ffcSJunyu Laichap_success_ref_data = hex_bytes('c223032f0004') 432*7dc08ffcSJunyu Lai 433*7dc08ffcSJunyu Laiassert raw(chap_success) == chap_success_ref_data 434*7dc08ffcSJunyu Lai 435*7dc08ffcSJunyu Laichap_success_pkt = PPP(chap_success_ref_data) 436*7dc08ffcSJunyu Laiassert PPP_CHAP in chap_success_pkt 437*7dc08ffcSJunyu Laiassert chap_success_pkt[PPP_CHAP].code == 3 438*7dc08ffcSJunyu Laiassert chap_success_pkt[PPP_CHAP].id == 47 439*7dc08ffcSJunyu Laiassert chap_success_pkt[PPP_CHAP].data == b'' 440*7dc08ffcSJunyu Laiassert chap_success_pkt[PPP_CHAP].summary() in ['CHAP Success message=\'\'', 'CHAP Success message=b\'\''] 441*7dc08ffcSJunyu Lai 442*7dc08ffcSJunyu Laichap_response_pkt = PPP(hex_bytes('c223022f001b1000000000000000000000000000000000636c69656e74')) 443*7dc08ffcSJunyu Lai 444*7dc08ffcSJunyu Laiassert chap_success_pkt.answers(chap_response_pkt) 445*7dc08ffcSJunyu Laiassert not chap_response_pkt.answers(chap_success_pkt) 446*7dc08ffcSJunyu Lai 447*7dc08ffcSJunyu Lai= Test PPP CHAP Failure 448*7dc08ffcSJunyu Lai~ ppp chap chap_failure 449*7dc08ffcSJunyu Laichap_failure = PPP() / PPP_CHAP(code='Failure', id=47, data='Go away') 450*7dc08ffcSJunyu Laichap_failure_ref_data = hex_bytes('c223042f000b476f2061776179') 451*7dc08ffcSJunyu Lai 452*7dc08ffcSJunyu Laiassert raw(chap_failure) == chap_failure_ref_data 453*7dc08ffcSJunyu Lai 454*7dc08ffcSJunyu Laichap_failure_pkt = PPP(chap_failure_ref_data) 455*7dc08ffcSJunyu Laiassert PPP_CHAP in chap_failure_pkt 456*7dc08ffcSJunyu Laiassert chap_failure_pkt[PPP_CHAP].code == 4 457*7dc08ffcSJunyu Laiassert chap_failure_pkt[PPP_CHAP].id == 47 458*7dc08ffcSJunyu Laiassert chap_failure_pkt[PPP_CHAP].data == b'Go away' 459*7dc08ffcSJunyu Laiassert chap_failure_pkt[PPP_CHAP].summary() in ['CHAP Failure message=\'Go away\'', 'CHAP Failure message=b\'Go away\''] 460*7dc08ffcSJunyu Lai 461*7dc08ffcSJunyu Laichap_response_pkt = PPP(hex_bytes('c223022f001b1000000000000000000000000000000000636c69656e74')) 462*7dc08ffcSJunyu Lai 463*7dc08ffcSJunyu Laiassert chap_failure_pkt.answers(chap_response_pkt) 464*7dc08ffcSJunyu Laiassert not chap_failure_pkt.answers(chap_success_pkt) 465*7dc08ffcSJunyu Lai 466*7dc08ffcSJunyu Lai+ PPTP Tests 467*7dc08ffcSJunyu Lai= Test PPTP Start-Control-Connection-Request 468*7dc08ffcSJunyu Lai~ pptp 469*7dc08ffcSJunyu Laistart_control_connection = PPTPStartControlConnectionRequest(framing_capabilities='Asynchronous Framing supported', 470*7dc08ffcSJunyu Lai bearer_capabilities='Digital access supported', 471*7dc08ffcSJunyu Lai maximum_channels=42, 472*7dc08ffcSJunyu Lai firmware_revision=47, 473*7dc08ffcSJunyu Lai host_name='test host name', 474*7dc08ffcSJunyu Lai vendor_string='test vendor string') 475*7dc08ffcSJunyu Laistart_control_connection_ref_data = hex_bytes('009c00011a2b3c4d00010000000100000000000100000002002a00'\ 476*7dc08ffcSJunyu Lai '2f7465737420686f7374206e616d65000000000000000000000000'\ 477*7dc08ffcSJunyu Lai '000000000000000000000000000000000000000000000000000000'\ 478*7dc08ffcSJunyu Lai '0000000000000000000000746573742076656e646f722073747269'\ 479*7dc08ffcSJunyu Lai '6e6700000000000000000000000000000000000000000000000000'\ 480*7dc08ffcSJunyu Lai '000000000000000000000000000000000000000000') 481*7dc08ffcSJunyu Lai 482*7dc08ffcSJunyu Laiassert raw(start_control_connection) == start_control_connection_ref_data 483*7dc08ffcSJunyu Lai 484*7dc08ffcSJunyu Laistart_control_connection_pkt = PPTP(start_control_connection_ref_data) 485*7dc08ffcSJunyu Lai 486*7dc08ffcSJunyu Laiassert isinstance(start_control_connection_pkt, PPTPStartControlConnectionRequest) 487*7dc08ffcSJunyu Laiassert start_control_connection_pkt.magic_cookie == 0x1a2b3c4d 488*7dc08ffcSJunyu Laiassert start_control_connection_pkt.protocol_version == 1 489*7dc08ffcSJunyu Laiassert start_control_connection_pkt.framing_capabilities == 1 490*7dc08ffcSJunyu Laiassert start_control_connection_pkt.bearer_capabilities == 2 491*7dc08ffcSJunyu Laiassert start_control_connection_pkt.maximum_channels == 42 492*7dc08ffcSJunyu Laiassert start_control_connection_pkt.firmware_revision == 47 493*7dc08ffcSJunyu Laiassert start_control_connection_pkt.host_name == b'test host name' + b'\0' * (64-len('test host name')) 494*7dc08ffcSJunyu Laiassert start_control_connection_pkt.vendor_string == b'test vendor string' + b'\0' * (64-len('test vendor string')) 495*7dc08ffcSJunyu Lai 496*7dc08ffcSJunyu Lai= Test PPTP Start-Control-Connection-Reply 497*7dc08ffcSJunyu Lai~ pptp 498*7dc08ffcSJunyu Laistart_control_connection_reply = PPTPStartControlConnectionReply(result_code='General error', 499*7dc08ffcSJunyu Lai error_code='Not-Connected', 500*7dc08ffcSJunyu Lai framing_capabilities='Synchronous Framing supported', 501*7dc08ffcSJunyu Lai bearer_capabilities='Analog access supported', 502*7dc08ffcSJunyu Lai vendor_string='vendor') 503*7dc08ffcSJunyu Laistart_control_connection_reply_ref_data = hex_bytes('009c00011a2b3c4d00020000000102010000000200000001ffff0'\ 504*7dc08ffcSJunyu Lai '1006c696e75780000000000000000000000000000000000000000'\ 505*7dc08ffcSJunyu Lai '00000000000000000000000000000000000000000000000000000'\ 506*7dc08ffcSJunyu Lai '000000000000000000000000076656e646f720000000000000000'\ 507*7dc08ffcSJunyu Lai '00000000000000000000000000000000000000000000000000000'\ 508*7dc08ffcSJunyu Lai '00000000000000000000000000000000000000000000000') 509*7dc08ffcSJunyu Lai 510*7dc08ffcSJunyu Laiassert raw(start_control_connection_reply) == start_control_connection_reply_ref_data 511*7dc08ffcSJunyu Lai 512*7dc08ffcSJunyu Laistart_control_connection_reply_pkt = PPTP(start_control_connection_reply_ref_data) 513*7dc08ffcSJunyu Lai 514*7dc08ffcSJunyu Laiassert isinstance(start_control_connection_reply_pkt, PPTPStartControlConnectionReply) 515*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.magic_cookie == 0x1a2b3c4d 516*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.protocol_version == 1 517*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.result_code == 2 518*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.error_code == 1 519*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.framing_capabilities == 2 520*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.bearer_capabilities == 1 521*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.host_name == b'linux' + b'\0' * (64-len('linux')) 522*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.vendor_string == b'vendor' + b'\0' * (64-len('vendor')) 523*7dc08ffcSJunyu Lai 524*7dc08ffcSJunyu Laistart_control_connection_request = PPTPStartControlConnectionRequest() 525*7dc08ffcSJunyu Lai 526*7dc08ffcSJunyu Laiassert start_control_connection_reply_pkt.answers(start_control_connection_request) 527*7dc08ffcSJunyu Laiassert not start_control_connection_request.answers(start_control_connection_reply_pkt) 528*7dc08ffcSJunyu Lai 529*7dc08ffcSJunyu Lai= Test PPTP Stop-Control-Connection-Request 530*7dc08ffcSJunyu Lai~ pptp 531*7dc08ffcSJunyu Laistop_control_connection = PPTPStopControlConnectionRequest(reason='Stop-Local-Shutdown') 532*7dc08ffcSJunyu Laistop_control_connection_ref_data = hex_bytes('001000011a2b3c4d0003000003000000') 533*7dc08ffcSJunyu Lai 534*7dc08ffcSJunyu Laiassert raw(stop_control_connection) == stop_control_connection_ref_data 535*7dc08ffcSJunyu Lai 536*7dc08ffcSJunyu Laistop_control_connection_pkt = PPTP(stop_control_connection_ref_data) 537*7dc08ffcSJunyu Lai 538*7dc08ffcSJunyu Laiassert isinstance(stop_control_connection_pkt, PPTPStopControlConnectionRequest) 539*7dc08ffcSJunyu Laiassert stop_control_connection_pkt.magic_cookie == 0x1a2b3c4d 540*7dc08ffcSJunyu Laiassert stop_control_connection_pkt.reason == 3 541*7dc08ffcSJunyu Lai 542*7dc08ffcSJunyu Lai= Test PPTP Stop-Control-Connection-Reply 543*7dc08ffcSJunyu Lai~ pptp 544*7dc08ffcSJunyu Laistop_control_connection_reply = PPTPStopControlConnectionReply(result_code='General error',error_code='PAC-Error') 545*7dc08ffcSJunyu Laistop_control_connection_reply_ref_data = hex_bytes('001000011a2b3c4d0004000002060000') 546*7dc08ffcSJunyu Lai 547*7dc08ffcSJunyu Laiassert raw(stop_control_connection_reply) == stop_control_connection_reply_ref_data 548*7dc08ffcSJunyu Lai 549*7dc08ffcSJunyu Laistop_control_connection_reply_pkt = PPTP(stop_control_connection_reply_ref_data) 550*7dc08ffcSJunyu Lai 551*7dc08ffcSJunyu Laiassert isinstance(stop_control_connection_reply_pkt, PPTPStopControlConnectionReply) 552*7dc08ffcSJunyu Laiassert stop_control_connection_reply_pkt.magic_cookie == 0x1a2b3c4d 553*7dc08ffcSJunyu Laiassert stop_control_connection_reply_pkt.result_code == 2 554*7dc08ffcSJunyu Laiassert stop_control_connection_reply_pkt.error_code == 6 555*7dc08ffcSJunyu Lai 556*7dc08ffcSJunyu Laistop_control_connection_request = PPTPStopControlConnectionRequest() 557*7dc08ffcSJunyu Lai 558*7dc08ffcSJunyu Laiassert stop_control_connection_reply_pkt.answers(stop_control_connection_request) 559*7dc08ffcSJunyu Laiassert not stop_control_connection_request.answers(stop_control_connection_reply_pkt) 560*7dc08ffcSJunyu Lai 561*7dc08ffcSJunyu Lai= Test PPTP Echo-Request 562*7dc08ffcSJunyu Lai~ pptp 563*7dc08ffcSJunyu Laiecho_request = PPTPEchoRequest(identifier=42) 564*7dc08ffcSJunyu Laiecho_request_ref_data = hex_bytes('001000011a2b3c4d000500000000002a') 565*7dc08ffcSJunyu Lai 566*7dc08ffcSJunyu Laiassert raw(echo_request) == echo_request_ref_data 567*7dc08ffcSJunyu Lai 568*7dc08ffcSJunyu Laiecho_request_pkt = PPTP(echo_request_ref_data) 569*7dc08ffcSJunyu Lai 570*7dc08ffcSJunyu Laiassert isinstance(echo_request_pkt, PPTPEchoRequest) 571*7dc08ffcSJunyu Laiassert echo_request_pkt.magic_cookie == 0x1a2b3c4d 572*7dc08ffcSJunyu Laiassert echo_request_pkt.identifier == 42 573*7dc08ffcSJunyu Lai 574*7dc08ffcSJunyu Lai= Test PPTP Echo-Reply 575*7dc08ffcSJunyu Lai~ pptp 576*7dc08ffcSJunyu Laiecho_reply = PPTPEchoReply(identifier=42, result_code='OK') 577*7dc08ffcSJunyu Laiecho_reply_ref_data = hex_bytes('001400011a2b3c4d000600000000002a01000000') 578*7dc08ffcSJunyu Lai 579*7dc08ffcSJunyu Laiassert raw(echo_reply) == echo_reply_ref_data 580*7dc08ffcSJunyu Lai 581*7dc08ffcSJunyu Laiecho_reply_pkt = PPTP(echo_reply_ref_data) 582*7dc08ffcSJunyu Lai 583*7dc08ffcSJunyu Laiassert isinstance(echo_reply_pkt, PPTPEchoReply) 584*7dc08ffcSJunyu Laiassert echo_reply_pkt.magic_cookie == 0x1a2b3c4d 585*7dc08ffcSJunyu Laiassert echo_reply_pkt.identifier == 42 586*7dc08ffcSJunyu Laiassert echo_reply_pkt.result_code == 1 587*7dc08ffcSJunyu Laiassert echo_reply_pkt.error_code == 0 588*7dc08ffcSJunyu Lai 589*7dc08ffcSJunyu Laiecho_request = PPTPEchoRequest(identifier=42) 590*7dc08ffcSJunyu Lai 591*7dc08ffcSJunyu Laiassert echo_reply_pkt.answers(echo_request) 592*7dc08ffcSJunyu Laiassert not echo_request.answers(echo_reply) 593*7dc08ffcSJunyu Lai 594*7dc08ffcSJunyu Laiecho_request_incorrect = PPTPEchoRequest(identifier=47) 595*7dc08ffcSJunyu Lai 596*7dc08ffcSJunyu Laiassert not echo_reply_pkt.answers(echo_request_incorrect) 597*7dc08ffcSJunyu Laiassert not echo_request_incorrect.answers(echo_reply_pkt) 598*7dc08ffcSJunyu Lai 599*7dc08ffcSJunyu Lai= Test PPTP Outgoing-Call-Request 600*7dc08ffcSJunyu Lai~ pptp 601*7dc08ffcSJunyu Laioutgoing_call = PPTPOutgoingCallRequest(call_id=4242, call_serial_number=47, 602*7dc08ffcSJunyu Lai minimum_bps=1000, maximum_bps=10000, 603*7dc08ffcSJunyu Lai bearer_type='Digital channel', 604*7dc08ffcSJunyu Lai pkt_window_size=16, pkt_proc_delay=1, 605*7dc08ffcSJunyu Lai phone_number_len=9, phone_number='123456789', 606*7dc08ffcSJunyu Lai subaddress='test') 607*7dc08ffcSJunyu Laioutgoing_call_ref_data = hex_bytes('00a800011a2b3c4d000700001092002f000003e8000027100000000200'\ 608*7dc08ffcSJunyu Lai '0000030010000100090000313233343536373839000000000000000000'\ 609*7dc08ffcSJunyu Lai '0000000000000000000000000000000000000000000000000000000000'\ 610*7dc08ffcSJunyu Lai '0000000000000000000000000000000000746573740000000000000000'\ 611*7dc08ffcSJunyu Lai '0000000000000000000000000000000000000000000000000000000000'\ 612*7dc08ffcSJunyu Lai '0000000000000000000000000000000000000000000000') 613*7dc08ffcSJunyu Lai 614*7dc08ffcSJunyu Laiassert raw(outgoing_call) == outgoing_call_ref_data 615*7dc08ffcSJunyu Lai 616*7dc08ffcSJunyu Laioutgoing_call_pkt = PPTP(outgoing_call_ref_data) 617*7dc08ffcSJunyu Lai 618*7dc08ffcSJunyu Laiassert isinstance(outgoing_call_pkt, PPTPOutgoingCallRequest) 619*7dc08ffcSJunyu Laiassert outgoing_call_pkt.magic_cookie == 0x1a2b3c4d 620*7dc08ffcSJunyu Laiassert outgoing_call_pkt.call_id == 4242 621*7dc08ffcSJunyu Laiassert outgoing_call_pkt.call_serial_number == 47 622*7dc08ffcSJunyu Laiassert outgoing_call_pkt.minimum_bps == 1000 623*7dc08ffcSJunyu Laiassert outgoing_call_pkt.maximum_bps == 10000 624*7dc08ffcSJunyu Laiassert outgoing_call_pkt.bearer_type == 2 625*7dc08ffcSJunyu Laiassert outgoing_call_pkt.framing_type == 3 626*7dc08ffcSJunyu Laiassert outgoing_call_pkt.pkt_window_size == 16 627*7dc08ffcSJunyu Laiassert outgoing_call_pkt.pkt_proc_delay == 1 628*7dc08ffcSJunyu Laiassert outgoing_call_pkt.phone_number_len == 9 629*7dc08ffcSJunyu Laiassert outgoing_call_pkt.phone_number == b'123456789' + b'\0' * (64-len('123456789')) 630*7dc08ffcSJunyu Laiassert outgoing_call_pkt.subaddress == b'test' + b'\0' * (64-len('test')) 631*7dc08ffcSJunyu Lai 632*7dc08ffcSJunyu Lai= Test PPTP Outgoing-Call-Reply 633*7dc08ffcSJunyu Lai~ pptp 634*7dc08ffcSJunyu Laioutgoing_call_reply = PPTPOutgoingCallReply(call_id=4243, peer_call_id=4242, 635*7dc08ffcSJunyu Lai result_code='Busy', error_code='No-Resource', 636*7dc08ffcSJunyu Lai cause_code=42, connect_speed=5000, 637*7dc08ffcSJunyu Lai pkt_window_size=32, pkt_proc_delay=3, 638*7dc08ffcSJunyu Lai channel_id=42) 639*7dc08ffcSJunyu Laioutgoing_call_reply_ref_data = hex_bytes('002000011a2b3c4d00080000109310920404002a00001388002000030000002a') 640*7dc08ffcSJunyu Lai 641*7dc08ffcSJunyu Laiassert raw(outgoing_call_reply) == outgoing_call_reply_ref_data 642*7dc08ffcSJunyu Lai 643*7dc08ffcSJunyu Laioutgoing_call_reply_pkt = PPTP(outgoing_call_reply_ref_data) 644*7dc08ffcSJunyu Lai 645*7dc08ffcSJunyu Laiassert isinstance(outgoing_call_reply_pkt, PPTPOutgoingCallReply) 646*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.magic_cookie == 0x1a2b3c4d 647*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.call_id == 4243 648*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.peer_call_id == 4242 649*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.result_code == 4 650*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.error_code == 4 651*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.cause_code == 42 652*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.connect_speed == 5000 653*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.pkt_window_size == 32 654*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.pkt_proc_delay == 3 655*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.channel_id == 42 656*7dc08ffcSJunyu Lai 657*7dc08ffcSJunyu Laioutgoing_call_request = PPTPOutgoingCallRequest(call_id=4242) 658*7dc08ffcSJunyu Lai 659*7dc08ffcSJunyu Laiassert outgoing_call_reply_pkt.answers(outgoing_call_request) 660*7dc08ffcSJunyu Laiassert not outgoing_call_request.answers(outgoing_call_reply_pkt) 661*7dc08ffcSJunyu Lai 662*7dc08ffcSJunyu Laioutgoing_call_request_incorrect = PPTPOutgoingCallRequest(call_id=5656) 663*7dc08ffcSJunyu Lai 664*7dc08ffcSJunyu Laiassert not outgoing_call_reply_pkt.answers(outgoing_call_request_incorrect) 665*7dc08ffcSJunyu Laiassert not outgoing_call_request_incorrect.answers(outgoing_call_reply_pkt) 666*7dc08ffcSJunyu Lai 667*7dc08ffcSJunyu Lai= Test PPTP Incoming-Call-Request 668*7dc08ffcSJunyu Lai~ pptp 669*7dc08ffcSJunyu Laiincoming_call = PPTPIncomingCallRequest(call_id=4242, call_serial_number=47, bearer_type='Digital channel', 670*7dc08ffcSJunyu Lai channel_id=12, dialed_number_len=9, dialing_number_len=10, 671*7dc08ffcSJunyu Lai dialed_number='123456789', dialing_number='0123456789', 672*7dc08ffcSJunyu Lai subaddress='test') 673*7dc08ffcSJunyu Laiincoming_call_ref_data = hex_bytes('00dc00011a2b3c4d000900001092002f000000020000000c0009000a313233343536373839'\ 674*7dc08ffcSJunyu Lai '00000000000000000000000000000000000000000000000000000000000000000000000000'\ 675*7dc08ffcSJunyu Lai '00000000000000000000000000000000000030313233343536373839000000000000000000'\ 676*7dc08ffcSJunyu Lai '00000000000000000000000000000000000000000000000000000000000000000000000000'\ 677*7dc08ffcSJunyu Lai '00000000000000007465737400000000000000000000000000000000000000000000000000'\ 678*7dc08ffcSJunyu Lai '0000000000000000000000000000000000000000000000000000000000000000000000') 679*7dc08ffcSJunyu Lai 680*7dc08ffcSJunyu Laiassert raw(incoming_call) == incoming_call_ref_data 681*7dc08ffcSJunyu Lai 682*7dc08ffcSJunyu Laiincoming_call_pkt = PPTP(incoming_call_ref_data) 683*7dc08ffcSJunyu Lai 684*7dc08ffcSJunyu Laiassert isinstance(incoming_call_pkt, PPTPIncomingCallRequest) 685*7dc08ffcSJunyu Laiassert incoming_call_pkt.magic_cookie == 0x1a2b3c4d 686*7dc08ffcSJunyu Laiassert incoming_call_pkt.call_id == 4242 687*7dc08ffcSJunyu Laiassert incoming_call_pkt.call_serial_number == 47 688*7dc08ffcSJunyu Laiassert incoming_call_pkt.bearer_type == 2 689*7dc08ffcSJunyu Laiassert incoming_call_pkt.channel_id == 12 690*7dc08ffcSJunyu Laiassert incoming_call_pkt.dialed_number_len == 9 691*7dc08ffcSJunyu Laiassert incoming_call_pkt.dialing_number_len == 10 692*7dc08ffcSJunyu Laiassert incoming_call_pkt.dialed_number == b'123456789' + b'\0' * (64-len('123456789')) 693*7dc08ffcSJunyu Laiassert incoming_call_pkt.dialing_number == b'0123456789' + b'\0' * (64-len('0123456879')) 694*7dc08ffcSJunyu Laiassert incoming_call_pkt.subaddress == b'test' + b'\0' * (64-len('test')) 695*7dc08ffcSJunyu Lai 696*7dc08ffcSJunyu Lai= Test PPTP Incoming-Call-Reply 697*7dc08ffcSJunyu Lai~ pptp 698*7dc08ffcSJunyu Laiincoming_call_reply = PPTPIncomingCallReply(call_id=4243, peer_call_id=4242, result_code='Connected', 699*7dc08ffcSJunyu Lai error_code='None', pkt_window_size=16, pkt_transmit_delay=42) 700*7dc08ffcSJunyu Laiincoming_call_reply_ref_data = hex_bytes('009400011a2b3c4d000a00001093109201000010002a0000') 701*7dc08ffcSJunyu Lai 702*7dc08ffcSJunyu Laiassert raw(incoming_call_reply) == incoming_call_reply_ref_data 703*7dc08ffcSJunyu Lai 704*7dc08ffcSJunyu Laiincoming_call_reply_pkt = PPTP(incoming_call_reply_ref_data) 705*7dc08ffcSJunyu Laiassert isinstance(incoming_call_reply_pkt, PPTPIncomingCallReply) 706*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.magic_cookie == 0x1a2b3c4d 707*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.call_id == 4243 708*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.peer_call_id == 4242 709*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.result_code == 1 710*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.error_code == 0 711*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.pkt_window_size == 16 712*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.pkt_transmit_delay == 42 713*7dc08ffcSJunyu Lai 714*7dc08ffcSJunyu Laiincoming_call_req = PPTPIncomingCallRequest(call_id=4242) 715*7dc08ffcSJunyu Lai 716*7dc08ffcSJunyu Laiassert incoming_call_reply_pkt.answers(incoming_call_req) 717*7dc08ffcSJunyu Laiassert not incoming_call_req.answers(incoming_call_reply) 718*7dc08ffcSJunyu Lai 719*7dc08ffcSJunyu Laiincoming_call_req_incorrect = PPTPIncomingCallRequest(call_id=4343) 720*7dc08ffcSJunyu Laiassert not incoming_call_reply_pkt.answers(incoming_call_req_incorrect) 721*7dc08ffcSJunyu Laiassert not incoming_call_req_incorrect.answers(incoming_call_reply_pkt) 722*7dc08ffcSJunyu Lai 723*7dc08ffcSJunyu Lai= Test PPTP Incoming-Call-Connected 724*7dc08ffcSJunyu Lai~ pptp 725*7dc08ffcSJunyu Laiincoming_call_connected = PPTPIncomingCallConnected(peer_call_id=4242, connect_speed=47474747, 726*7dc08ffcSJunyu Lai pkt_window_size=16, pkt_transmit_delay=7, 727*7dc08ffcSJunyu Lai framing_type='Any type of framing') 728*7dc08ffcSJunyu Laiincoming_call_connected_ref_data = hex_bytes('001c00011a2b3c4d000b00001092000002d4683b0010000700000003') 729*7dc08ffcSJunyu Lai 730*7dc08ffcSJunyu Laiassert raw(incoming_call_connected) == incoming_call_connected_ref_data 731*7dc08ffcSJunyu Lai 732*7dc08ffcSJunyu Laiincoming_call_connected_pkt = PPTP(incoming_call_connected_ref_data) 733*7dc08ffcSJunyu Laiassert isinstance(incoming_call_connected_pkt, PPTPIncomingCallConnected) 734*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.magic_cookie == 0x1a2b3c4d 735*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.peer_call_id == 4242 736*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.connect_speed == 47474747 737*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.pkt_window_size == 16 738*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.pkt_transmit_delay == 7 739*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.framing_type == 3 740*7dc08ffcSJunyu Lai 741*7dc08ffcSJunyu Laiincoming_call_reply = PPTPIncomingCallReply(call_id=4242) 742*7dc08ffcSJunyu Lai 743*7dc08ffcSJunyu Laiassert incoming_call_connected_pkt.answers(incoming_call_reply) 744*7dc08ffcSJunyu Laiassert not incoming_call_reply.answers(incoming_call_connected_pkt) 745*7dc08ffcSJunyu Lai 746*7dc08ffcSJunyu Laiincoming_call_reply_incorrect = PPTPIncomingCallReply(call_id=4243) 747*7dc08ffcSJunyu Lai 748*7dc08ffcSJunyu Laiassert not incoming_call_connected_pkt.answers(incoming_call_reply_incorrect) 749*7dc08ffcSJunyu Laiassert not incoming_call_reply_incorrect.answers(incoming_call_connected_pkt) 750*7dc08ffcSJunyu Lai 751*7dc08ffcSJunyu Lai= Test PPTP Call-Clear-Request 752*7dc08ffcSJunyu Lai~ pptp 753*7dc08ffcSJunyu Laicall_clear_request = PPTPCallClearRequest(call_id=4242) 754*7dc08ffcSJunyu Laicall_clear_request_ref_data = hex_bytes('001000011a2b3c4d000c000010920000') 755*7dc08ffcSJunyu Lai 756*7dc08ffcSJunyu Laiassert raw(call_clear_request) == call_clear_request_ref_data 757*7dc08ffcSJunyu Lai 758*7dc08ffcSJunyu Laicall_clear_request_pkt = PPTP(call_clear_request_ref_data) 759*7dc08ffcSJunyu Lai 760*7dc08ffcSJunyu Laiassert isinstance(call_clear_request_pkt, PPTPCallClearRequest) 761*7dc08ffcSJunyu Laiassert call_clear_request_pkt.magic_cookie == 0x1a2b3c4d 762*7dc08ffcSJunyu Laiassert call_clear_request_pkt.call_id == 4242 763*7dc08ffcSJunyu Lai 764*7dc08ffcSJunyu Lai= Test PPTP Call-Disconnect-Notify 765*7dc08ffcSJunyu Lai~ pptp 766*7dc08ffcSJunyu Laicall_disconnect_notify = PPTPCallDisconnectNotify(call_id=4242, result_code='Admin Shutdown', error_code='None', 767*7dc08ffcSJunyu Lai cause_code=47, call_statistic='some description') 768*7dc08ffcSJunyu Laicall_disconnect_notify_ref_data = hex_bytes('009400011a2b3c4d000d000010920300002f0000736f6d65206465736372697074696'\ 769*7dc08ffcSJunyu Lai 'f6e000000000000000000000000000000000000000000000000000000000000000000'\ 770*7dc08ffcSJunyu Lai '000000000000000000000000000000000000000000000000000000000000000000000'\ 771*7dc08ffcSJunyu Lai '000000000000000000000000000000000000000000000000000000000000000000000'\ 772*7dc08ffcSJunyu Lai '00000000000000000000') 773*7dc08ffcSJunyu Lai 774*7dc08ffcSJunyu Laiassert raw(call_disconnect_notify) == call_disconnect_notify_ref_data 775*7dc08ffcSJunyu Lai 776*7dc08ffcSJunyu Laicall_disconnect_notify_pkt = PPTP(call_disconnect_notify_ref_data) 777*7dc08ffcSJunyu Lai 778*7dc08ffcSJunyu Laiassert isinstance(call_disconnect_notify_pkt, PPTPCallDisconnectNotify) 779*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.magic_cookie == 0x1a2b3c4d 780*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.call_id == 4242 781*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.result_code == 3 782*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.error_code == 0 783*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.cause_code == 47 784*7dc08ffcSJunyu Laiassert call_disconnect_notify_pkt.call_statistic == b'some description' + b'\0' * (128-len('some description')) 785*7dc08ffcSJunyu Lai 786*7dc08ffcSJunyu Lai= Test PPTP WAN-Error-Notify 787*7dc08ffcSJunyu Lai~ pptp 788*7dc08ffcSJunyu Laiwan_error_notify = PPTPWANErrorNotify(peer_call_id=4242, crc_errors=1, framing_errors=2, 789*7dc08ffcSJunyu Lai hardware_overruns=3, buffer_overruns=4, time_out_errors=5, 790*7dc08ffcSJunyu Lai alignment_errors=6) 791*7dc08ffcSJunyu Laiwan_error_notify_ref_data = hex_bytes('002800011a2b3c4d000e000010920000000000010000000200000003000000040000000500000006') 792*7dc08ffcSJunyu Lai 793*7dc08ffcSJunyu Laiassert raw(wan_error_notify) == wan_error_notify_ref_data 794*7dc08ffcSJunyu Lai 795*7dc08ffcSJunyu Laiwan_error_notify_pkt = PPTP(wan_error_notify_ref_data) 796*7dc08ffcSJunyu Lai 797*7dc08ffcSJunyu Laiassert isinstance(wan_error_notify_pkt, PPTPWANErrorNotify) 798*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.magic_cookie == 0x1a2b3c4d 799*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.peer_call_id == 4242 800*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.crc_errors == 1 801*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.framing_errors == 2 802*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.hardware_overruns == 3 803*7dc08ffcSJunyu Laiassert wan_error_notify_pkt.buffer_overruns == 4 804*7dc08ffcSJunyu Lai 805*7dc08ffcSJunyu Lai= Test PPTP Set-Link-Info 806*7dc08ffcSJunyu Lai~ pptp 807*7dc08ffcSJunyu Laiset_link_info = PPTPSetLinkInfo(peer_call_id=4242, send_accm=0x0f0f0f0f, receive_accm=0xf0f0f0f0) 808*7dc08ffcSJunyu Laiset_link_info_ref_data = hex_bytes('001800011a2b3c4d000f0000109200000f0f0f0ff0f0f0f0') 809*7dc08ffcSJunyu Lai 810*7dc08ffcSJunyu Laiassert raw(set_link_info) == set_link_info_ref_data 811*7dc08ffcSJunyu Lai 812*7dc08ffcSJunyu Laiset_link_info_pkt = PPTP(set_link_info_ref_data) 813*7dc08ffcSJunyu Lai 814*7dc08ffcSJunyu Laiassert isinstance(set_link_info_pkt, PPTPSetLinkInfo) 815*7dc08ffcSJunyu Laiassert set_link_info_pkt.magic_cookie == 0x1a2b3c4d 816*7dc08ffcSJunyu Laiassert set_link_info_pkt.peer_call_id == 4242 817*7dc08ffcSJunyu Laiassert set_link_info_pkt.send_accm == 0x0f0f0f0f 818*7dc08ffcSJunyu Laiassert set_link_info_pkt.receive_accm == 0xf0f0f0f0 819