📄 ppp.s
字号:
.dbfunc e PPP_Add32 _PPP_Add32 fV
; dw -> y+0
.even
_PPP_Add32::
xcall push_arg4
.dbline -1
.dbline 505
; }
;
; void PPP_Add32(u32 dw)
; { // add a 32-bit value into the PPP packet
.dbline 506
; *(u32*)(MainBuffer + MainBufferWr_Tx) = htonl(dw); // 32-bit
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall _htonl
ldi R24,<_MainBuffer
ldi R25,>_MainBuffer
lds R30,_MainBufferWr_Tx
lds R31,_MainBufferWr_Tx+1
add R30,R24
adc R31,R25
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 507
; MainBufferWr_Tx += 4; // update index
lds R24,_MainBufferWr_Tx
lds R25,_MainBufferWr_Tx+1
adiw R24,4
sts _MainBufferWr_Tx+1,R25
sts _MainBufferWr_Tx,R24
.dbline 508
; CodeHeader->Len += 4; // update length
lds R24,_CodeHeader
lds R25,_CodeHeader+1
adiw R24,2
movw R30,R24
ldd R24,z+0
ldd R25,z+1
adiw R24,4
std z+1,R25
std z+0,R24
.dbline -2
L202:
adiw R28,4
.dbline 0 ; func end
ret
.dbsym l dw 0 l
.dbend
.dbfunc e PPP_AddText _PPP_AddText fI
; i -> R20,R21
; s -> R22,R23
.even
_PPP_AddText::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 512
; }
;
; int PPP_AddText(char *s)
; { // add text into the PPP packet
.dbline 513
; u16 i = (u16)strlen(s); // length of text
movw R16,R22
xcall _strlen
movw R20,R16
.dbline 514
; MainBuffer[MainBufferWr_Tx++] = (char)i; // length
lds R2,_MainBufferWr_Tx
lds R3,_MainBufferWr_Tx+1
movw R24,R2
adiw R24,1
sts _MainBufferWr_Tx+1,R25
sts _MainBufferWr_Tx,R24
ldi R24,<_MainBuffer
ldi R25,>_MainBuffer
movw R30,R2
add R30,R24
adc R31,R25
std z+0,R20
.dbline 515
; strcpy((char*)MainBuffer + MainBufferWr_Tx, s); // text
movw R18,R22
lds R16,_MainBufferWr_Tx
lds R17,_MainBufferWr_Tx+1
add R16,R24
adc R17,R25
xcall _strcpy
.dbline 516
; MainBufferWr_Tx += i; // update index
lds R2,_MainBufferWr_Tx
lds R3,_MainBufferWr_Tx+1
add R2,R20
adc R3,R21
sts _MainBufferWr_Tx+1,R3
sts _MainBufferWr_Tx,R2
.dbline 517
; CodeHeader->Len += 1 + i; // update length
lds R24,_CodeHeader
lds R25,_CodeHeader+1
adiw R24,2
movw R2,R24
movw R24,R20
adiw R24,1
movw R30,R2
ldd R4,z+0
ldd R5,z+1
add R4,R24
adc R5,R25
std z+1,R5
std z+0,R4
.dbline 518
; return 1 + i; // size of data we have added
movw R16,R20
subi R16,255 ; offset = 1
sbci R17,255
.dbline -2
L203:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 s
.dbsym r s 22 pc
.dbend
.dbfunc e PPP_Add_IPCP_Option _PPP_Add_IPCP_Option fI
; ip -> y+0
; Code -> R20
.even
_PPP_Add_IPCP_Option::
xcall push_gset1
mov R20,R16
sbiw R28,4
.dbline -1
.dbline 522
; }
;
; int PPP_Add_IPCP_Option(u8 Code)
; { // add an IP option into the PPP packet
.dbline 525
; u32 ip;
;
; if (Code == 3) ip = PPP.OUR_IP.ip32; // point to our ip
cpi R20,3
brne L205
.dbline 525
lds R4,_PPP+13+2
lds R5,_PPP+13+2+1
lds R2,_PPP+13
lds R3,_PPP+13+1
movw R30,R28
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
xjmp L206
L205:
.dbline 527
; else //
; if (Code == 129) ip = PPP.DNS1_IP.ip32; // point to primary dns ip
cpi R20,129
brne L208
.dbline 527
lds R4,_PPP+21+2
lds R5,_PPP+21+2+1
lds R2,_PPP+21
lds R3,_PPP+21+1
movw R30,R28
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
xjmp L209
L208:
.dbline 529
; else //
; if (Code == 131) ip = PPP.DNS2_IP.ip32; // point to secondary dns ip
cpi R20,131
brne L211
.dbline 529
lds R4,_PPP+25+2
lds R5,_PPP+25+2+1
lds R2,_PPP+25
lds R3,_PPP+25+1
movw R30,R28
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
xjmp L212
L211:
.dbline 531
; else //
; return 0; //
clr R16
clr R17
xjmp L204
L212:
L209:
L206:
.dbline 533
; //
; PPP_Add8(Code); // type
mov R16,R20
xcall _PPP_Add8
.dbline 534
; PPP_Add8(6); // length
ldi R16,6
xcall _PPP_Add8
.dbline 535
; PPP_Add32(ntohl(ip)); // ip address
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall _ntohl
xcall _PPP_Add32
.dbline 537
; //
; return 6; // size of option we have added
ldi R16,6
ldi R17,0
.dbline -2
L204:
adiw R28,4
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym l ip 0 l
.dbsym r Code 20 c
.dbend
.dbfunc e PPP_AddACCM _PPP_AddACCM fI
; ACCM -> y+0
.even
_PPP_AddACCM::
xcall push_arg4
.dbline -1
.dbline 541
; }
;
; int PPP_AddACCM(u32 ACCM)
; { // add an ACCM option into the packet
.dbline 542
; PPP_Add8(LCP_ACCM); // type
ldi R16,2
xcall _PPP_Add8
.dbline 543
; PPP_Add8(6); // length
ldi R16,6
xcall _PPP_Add8
.dbline 544
; PPP_Add32(ACCM); // data
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall _PPP_Add32
.dbline 545
; return 6; // size of option we have added
ldi R16,6
ldi R17,0
.dbline -2
L214:
adiw R28,4
.dbline 0 ; func end
ret
.dbsym l ACCM 0 l
.dbend
.dbfunc e PPP_AddMN _PPP_AddMN fI
; MN -> y+0
.even
_PPP_AddMN::
xcall push_arg4
.dbline -1
.dbline 549
; }
;
; int PPP_AddMN(u32 MN)
; { // add a magic number option into the packet
.dbline 550
; PPP_Add8(LCP_MN); // type
ldi R16,5
xcall _PPP_Add8
.dbline 551
; PPP_Add8(6); // length
ldi R16,6
xcall _PPP_Add8
.dbline 552
; PPP_Add32(MN); // data
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall _PPP_Add32
.dbline 553
; return 6; // size of option we have added
ldi R16,6
ldi R17,0
.dbline -2
L215:
adiw R28,4
.dbline 0 ; func end
ret
.dbsym l MN 0 l
.dbend
.dbfunc e PPP_AddMRU _PPP_AddMRU fI
; MRU -> R20,R21
.even
_PPP_AddMRU::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 557
; }
;
; int PPP_AddMRU(u16 MRU)
; { // add an MRU option into the packet
.dbline 558
; PPP_Add8(LCP_MRU); // type
ldi R16,1
xcall _PPP_Add8
.dbline 559
; PPP_Add8(4); // length
ldi R16,4
xcall _PPP_Add8
.dbline 560
; PPP_Add16(MRU); // data
movw R16,R20
xcall _PPP_Add16
.dbline 561
; return 4; // size of option we have added
ldi R16,4
ldi R17,0
.dbline -2
L216:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r MRU 20 s
.dbend
.dbfunc e PPP_AddPAP _PPP_AddPAP fI
.even
_PPP_AddPAP::
.dbline -1
.dbline 565
; }
;
; int PPP_AddPAP(void)
; {
.dbline 566
; PPP_Add8(LCP_AP); // type
ldi R16,3
xcall _PPP_Add8
.dbline 567
; PPP_Add8(4); // length
ldi R16,4
xcall _PPP_Add8
.dbline 568
; PPP_Add16(PPP_PAP); // the auth protocol we can do
ldi R16,49187
ldi R17,192
xcall _PPP_Add16
.dbline 569
; return 4; // size of option we have added
ldi R16,4
ldi R17,0
.dbline -2
L217:
.dbline 0 ; func end
ret
.dbend
.dbfunc e PPP_SendEchoRequest _PPP_SendEchoRequest fc
; w -> R20,R21
.even
_PPP_SendEchoRequest::
xcall push_gset1
.dbline -1
.dbline 575
; }
;
; //****************************************************************************
;
; bool PPP_SendEchoRequest(void)
; { // Send an LCP Echo request packet
.dbline 578
; u16 w;
;
; PPP_StartPacket(PPP_LCP); //
ldi R16,49185
ldi R17,192
xcall _PPP_StartPacket
.dbline 579
; PPP_AddCodeHeader(PPP_EREQ); //
ldi R16,9
xcall _PPP_AddCodeHeader
.dbline 580
; PPP_Add32(PPP.TxMN); // magic number
lds R18,_PPP+33+2
lds R19,_PPP+33+2+1
lds R16,_PPP+33
lds R17,_PPP+33+1
xcall _PPP_Add32
.dbline 582
; //
; CodeHeader->Len = htons(CodeHeader->Len); // correct byte order
lds R24,_CodeHeader
lds R25,_CodeHeader+1
adiw R24,2
movw R30,R24
ldd R16,z+0
ldd R17,z+1
push R24
push R25
xcall _htons
pop R31
pop R30
std z+1,R17
std z+0,R16
.dbline 584
; //
; u16_Put(&PPP.SendTick, 0); // reset the send retry timer
clr R18
clr R19
ldi R16,<_PPP+6
ldi R17,>_PPP+6
xcall _u16_Put
.dbline 585
; PPP.Retries++; // update the send retry counter
lds R24,_PPP+8
subi R24,255 ; addi 1
sts _PPP+8,R24
.dbline 587
; //
; w = MainBufferWr_Tx; //
lds R20,_MainBufferWr_Tx
lds R21,_MainBufferWr_Tx+1
.dbline 589
; //
; if (!PPP_SendPacket(true)) return false; // send the packet
ldi R16,1
xcall _PPP_SendPacket
tst R16
brne L222
.dbline 589
clr R16
xjmp L218
L222:
.dbline 592
; //
; #ifdef Debug
; PPP_DisplayPacket(true, w); //
movw R18,R20
ldi R16,1
xcall _PPP_DisplayPacket
.dbline 595
; #endif
;
; return true; //
ldi R16,1
.dbline -2
L218:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r w 20 s
.dbend
.dbfunc e PPP_SendIPRequest _PPP_SendIPRequest fc
; w -> R10,R11
.even
_PPP_SendIPRequest::
xcall push_gset3
.dbline -1
.dbline 599
; }
;
; bool PPP_SendIPRequest(void)
; { // Send a IPCP packet requesting the ip's (our's and the dns ip's)
.dbline 602
; u16 w;
;
; PPP_StartPacket(PPP_IPCP); //
ldi R16,32801
ldi R17,128
xcall _PPP_StartPacket
.dbline 603
; PPP_AddCodeHeader(PPP_CREQ); //
ldi R16,1
xcall _PPP_AddCodeHeader
.dbline 605
; //
; if (PPP.OUR_IP.ip32 != 0xffffffff) PPP_Add_IPCP_Option(3); // add our ip to the packet
ldi R20,255
ldi R21,255
ldi R22,255
ldi R23,255
lds R4,_PPP+13+2
lds R5,_PPP+13+2+1
lds R2,_PPP+13
lds R3,_PPP+13+1
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
breq L225
.dbline 605
ldi R16,3
xcall _PPP_Add_IPCP_Option
L225:
.dbline 606
; if (PPP.DNS1_IP.ip32 != 0xffffffff) PPP_Add_IPCP_Option(129); // add the primary DNS ip
ldi R20,255
ldi R21,255
ldi R22,255
ldi R23,255
lds R4,_PPP+21+2
lds R5,_PPP+21+2+1
lds R2,_PPP+21
lds R3,_PPP+21+1
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
breq L228
.dbline 606
ldi R16,129
xcall _PPP_Add_IPCP_Option
L228:
.dbline 607
; if (PPP.DNS2_IP.ip32 != 0xffffffff) PPP_Add_IPCP_Option(131); // add the secondary DNS ip
ldi R20,255
ldi R21,255
ldi R22,255
ldi R23,255
lds R4,_PPP+25+2
lds R5,_PPP+25+2+1
lds R2,_PPP+25
lds R3,_PPP+25+1
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
breq L231
.dbline 607
ldi R16,131
xcall _PPP_Add_IPCP_Option
L231:
.dbline 609
; //
; CodeHeader->Len = htons(CodeHeader->Len); // correct byte order
lds R24,_CodeHeader
lds R25,_CodeHeader+1
adiw R24,2
movw R30,R24
ldd R16,z+0
ldd R17,z+1
push R24
push R25
xcall _htons
pop R31
pop R30
std z+1,R17
std z+0,R16
.dbline 611
; //
; u16_Put(&PPP.SendTick, 0); // reset the send retry timer
clr R18
clr R19
ldi R16,<_PPP+6
ldi R17,>_PPP+6
xcall _u16_Put
.dbline 612
; PPP.Retries++; // update the send retry counter
lds R24,_PPP+8
subi R24,255 ; addi 1
sts _PPP+8,R24
.dbline 614
; //
; w = MainBufferWr_Tx; // remember how many bytes their are
lds R10,_MainBufferWr_Tx
lds R11,_MainBufferWr_Tx+1
.dbline 616
; //
; if (!PPP_SendPacket(false)) return false; // send the packet
clr R16
xcall _PPP_SendPacket
tst R16
brne L236
.dbline 616
clr R16
xjmp L224
L236:
.dbline 619
; //
; #ifdef Debug
; PPP_DisplayPacket(true, w); //
movw R18,R10
ldi R16,1
xcall _PPP_DisplayPacket
.dbline 622
; #endif
;
; return true; //
ldi R16,1
.dbline -2
L224:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r w 10 s
.dbend
.dbfunc e PPP_SendPap _PPP_SendPap fc
; w -> R20,R21
.even
_PPP_SendPap::
xcall push_gset1
.dbline -1
.dbline 626
; }
;
; bool PPP_SendPap(void)
; { // Send an LCP PAP login packet
.dbline 629
; u16 w;
;
; P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -