code: private static int findEndOfHeader(final ByteBuf buffer) {
          final int n = buffer.readableBytes();
  
          // per spec, the 15th and 16th bytes contain the address length in bytes
          if (n < 16) {
              return -1;
          }
  
          int offset = buffer.readerIndex() + 14;
  
          // the total header length will be a fixed 16 byte sequence + the dynamic address information block
          int totalHeaderBytes = 16 + buffer.getUnsignedShort(offset);
  
          // ensure we actually have the full header available
          if (n >= totalHeaderBytes) {
              return totalHeaderBytes;
          } else {
              return -1;
          }
      }
docs: Returns the index in the buffer of the end of header if found.
  Returns -1 if no end of header was found in the buffer.