static ossl_inline void packet_forward(PACKET *pkt, size_t len)
{
    pkt->curr += len;
    pkt->remaining -= len;
}
['static int test_PACKET_get_sub_packet()\n{\n    PACKET pkt, subpkt;\n    unsigned long i;\n    if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))\n            || !TEST_true(PACKET_get_sub_packet(&pkt, &subpkt, 4))\n            || !TEST_true(PACKET_get_net_4(&subpkt, &i))\n            || !TEST_ulong_eq(i, 0x02040608UL)\n            || !TEST_size_t_eq(PACKET_remaining(&subpkt), 0)\n            || !TEST_true(PACKET_forward(&pkt, BUF_LEN - 8))\n            || !TEST_true(PACKET_get_sub_packet(&pkt, &subpkt, 4))\n            || !TEST_true(PACKET_get_net_4(&subpkt, &i))\n            || !TEST_ulong_eq(i, 0xf8fafcfeUL)\n            || !TEST_size_t_eq(PACKET_remaining(&subpkt), 0)\n            || !TEST_false(PACKET_get_sub_packet(&pkt, &subpkt, 4)))\n        return 0;\n    return 1;\n}', 'static ossl_inline int PACKET_buf_init(PACKET *pkt,\n                                              const unsigned char *buf,\n                                              size_t len)\n{\n    if (len > (size_t)(SIZE_MAX / 2))\n        return 0;\n    pkt->curr = buf;\n    pkt->remaining = len;\n    return 1;\n}', 'static ossl_inline int PACKET_get_sub_packet(PACKET *pkt,\n                                                    PACKET *subpkt, size_t len)\n{\n    if (!PACKET_peek_sub_packet(pkt, subpkt, len))\n        return 0;\n    packet_forward(pkt, len);\n    return 1;\n}', 'static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt,\n                                                     PACKET *subpkt, size_t len)\n{\n    if (PACKET_remaining(pkt) < len)\n        return 0;\n    return PACKET_buf_init(subpkt, pkt->curr, len);\n}', 'static ossl_inline int PACKET_forward(PACKET *pkt, size_t len)\n{\n    if (PACKET_remaining(pkt) < len)\n        return 0;\n    packet_forward(pkt, len);\n    return 1;\n}', 'static ossl_inline void packet_forward(PACKET *pkt, size_t len)\n{\n    pkt->curr += len;\n    pkt->remaining -= len;\n}']