.title Header Checksum Routines ; ; Macro routines for special functions ; .psect c$code ; ; Internet header checksum ; header checksum is calculated for ; a higher level program to verify ; ; USAGE: ipcheck((IPKT *)ptr,(int)len_in_words) ; ipcheck:: jsr r5,csv$ mov c$pmtr(r5),r2 ;buffer address mov c$pmtr+2(r5),r1 ;word count clr r0 ;checksum 1$: add (r2)+,r0 ;build checksum adc r0 sob r1,1$ com r0 ;complement jmp cret$ ; ; TCP checksum ; header checksum is calculated for ; a higher level program to verify ; includes support for a pseudo-header ; ; USAGE: tcpcheck((TCPKT *)psptr, ; (TCPKT *)tcpptr,(int)len_in_bytes) ; tcpcheck:: jsr r5,csv$ mov c$pmtr(r5),r2 ;psuedo header address mov #6,r1 ;word count clr r0 ;checksum 1$: add (r2)+,r0 ;build checksum adc r0 sob r1,1$ mov c$pmtr+2(r5),r2 ;tcp buffer address mov c$pmtr+4(r5),r3 ;byte count mov r3,r1 asr r1 ;word count 2$: add (r2)+,r0 ;continue with checksum adc r0 sob r1,2$ ror r3 ;odd number of bytes ? bcc 3$ ;no - skip clr r3 ;else process last byte bisb (r2),r3 add r3,r0 adc r0 3$: com r0 ;complement jmp cret$ .end