logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

rq_pid2sbn, rq_pid2esi, rq_pidsetsbn, rq_pidsetesi - get/set SBN,ESI in rq_pid_t

Description

       Bitshifting macros for getting and setting the SBN and ESI bits of rq_pid_t.

       0                   1                   2                   3
       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       |     SBN       |               Encoding Symbol ID              |
       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

       SBN (Source Block Number) is an 8 bit unsigned integer. The Encoding Symbol ID (ESI) is a 24 bit unsigned
       integer in network byte order.

Errors

       These macros do not return errors.

Example

Programsource

       #include <assert.h>
       #include <lcrq.h>

       int main(void)
       {
            rq_pid_t pid = 0;
            uint32_t esi = 19;
            uint8_t sbn = 42;

            /* set SBN and ESI bits */
            pid = rq_pidsetsbn(pid, sbn);
            pid = rq_pidsetesi(pid, esi);

            /* or set both at once */
            pid = rq_pidset(sbn, esi);

            /* make sure we can read them back */
            assert(sbn == rq_pid2sbn(pid));
            assert(esi == rq_pid2esi(pid));

            return 0;
       }

Name

       rq_pid2sbn, rq_pid2esi, rq_pidsetsbn, rq_pidsetesi - get/set SBN,ESI in rq_pid_t

Return Value

rq_pid2sbn()   and   rq_pid2esi()   return  the  uint8_t  SBN  and  uint32_t  ESI  numbers  respectively.
       rq_pidsetsbn() and rq_pidsetesi() both return rq_pid_t with the appropriate bits set.

See Also

rq_init(3), rq_free(3), rq_decode(3), rq_encode(3), rq_symbol(3), lcrq(7)

LCRQ                                               2023-07-21                                      RQ_PID2SBN(3)

Synopsis

#include<lcrq.h>uint8_trq_pid2sbn(rq_pid_tpid);uint32_trq_pid2esi(rq_pid_tpid);rq_pid_trq_pidset(uint8_tsbn,uint32_tesi);rq_pid_trq_pidsetsbn(rq_pid_tpid,uint8_tsbn);rq_pid_trq_pidsetesi(rq_pid_tpid,uint32_tesi);

       Compile and link with -llcrq.

See Also