;; Bitvector in protocol byte order (little endian) → integer in host byte order (define (ptoh octet-size bv) ;; Procedures to convert bytevector index to shift value for LE and BE. (define (shle idx) (* idx 8)) ;; INDEX * 8 (define (shbe idx) (- octet-size (+ 1 (* idx 8)))) ;; BYTE-SIZE - ((INDEX + 1) * 8) (let ((shift-proc (if (memq 'little-endian (features)) shle shbe))) ;; Use shle on LE and shbe on BE platforms (apply bitwise-ior (map (lambda (index) (arithmetic-shift (bytevector-u8-ref bv index) ;; Get nth byte from vector (shift-proc index))) ;; Shift according to byte order (range octet-size)))))