Hmm.. the example code in Annex C seems not to handle the case when the lower counter occupies the entire 32 bits space and an overflow takes place. I think this should fix the thing:
uint32_t incSeqNum( seqnum_t* sn, uint32_t pinc, uint32_t qinc ) {
uint32_t oldpval = sn->pval;
sn->pval += pinc;
if (sn->pval > sn->pmax || sn->pval < oldpval) {
sn->pval = sn->pval - sn->pmax - 1;
sn->qval += qinc;
}
if (sn->qval > sn->qmax) {
sn->qval = sn->qval - sn->qmax - 1;
}
return getSeqNum( sn );
}
--
Jouni Korhonen, CTO Office, Networking, Broadcom Corporation
O: +1-408-922-8135, M: +1-408-391-7160