static void flushcheck_frames(nut_context_tt * nut) { int change, i; for (i = 0; i < nut->stream_count; i++) { // check if any streams are missing essential info if (!nut->sc[i].num_packets && !nut->sc[i].next_pts) return; } do { change = 0; for (i = 0; i < nut->stream_count; i++) { int j; int64_t min = -1; if (!nut->sc[i].num_packets) continue; // no packets pending in this stream for (j = 0; j < nut->stream_count; j++) { int64_t pts; if (i == j) continue; if (nut->sc[j].num_packets) pts = nut->sc[j].packets[0].dts; // CANT USE p.pts; else pts = nut->sc[j].next_pts; if (pts >= 0) { pts = convert_ts(pts, TO_TB(j), TO_TB(i)); if (min > pts || min == -1) min = pts; } } // MN rule, (i < j) && (i.dts <= j.pts) // actually, strict dts if (min == -1 || nut->sc[i].packets[0].dts <= min) { for (j = 1; j < nut->sc[i].num_packets; j++) { if (min != -1 && nut->sc[i].packets[j].dts > min) break; } shift_frames(nut, &nut->sc[i], j); change = 1; } } } while (change); }
static int slpv2_authblock(int cnt) { unsigned short bsd, length, slen; char *pp, *scopes; unsigned int timestamp; if (msglength < 10) { sprintf(get_line(0, 0), " [no room for auth block header: remaining msg length = %u]", msglength); return (-1); } /* bsd */ nbtohs(); bsd = netval; p += sizeof (unsigned short); /* length */ nbtohs(); length = netval; p += sizeof (unsigned short); /* timestamp */ nbtohl(); timestamp = netval; p += 4; /* SPI String length */ nbtohs(); slen = netval; p += sizeof (unsigned short); msglength -= 10; if (slen > msglength) { sprintf(get_line(0, 0), " [no room for auth block scopes: remaining msg length = %u]", msglength); return (-1); } if (length > (msglength + 10)) { if (!tcp_continuation) /* framing error: message is not long enough to contain data */ sprintf(get_line(0, 0), " [Framing error: remaining pkt length = %u]", msglength); return (-1); } scopes = p; p += slen; msglength -= slen; sprintf(get_line(0, 0), "Auth block %d: timestamp = %s", cnt, (timestamp) ? convert_ts(timestamp) : "0"); pp = get_line(0, 0); strcpy(pp, " SPI = "); strncat(pp, scopes, slen); sprintf(get_line(0, 0), " block desc = 0x%04x: %s", bsd, display_bsd(bsd)); sprintf(get_line(0, 0), " length = %u", length); p += (length - 10 - slen); msglength -= (length - 10 - slen); return (0); }