NAME

  tst_inet6_opt_finish_calc - Calculate the needed buffer size for the extension header


PURPOSE

  To check that inet6_opt_finish() can be used to calculate
  the needed buffer size for the extension header.


SYNOPSIS

  ./tst_inet6_opt_finish_calc [-tooloption ...]
    -tooloption : v6api tool option


TEST PROCEDURE

  1. Calculate the needed buffer size
  2. Check A: return the needed buffer size of 2
  3. Calculate the needed buffer size while the offset is not multiple of 8 bytes
  4. Check B: return the needed buffer size of 8
  5. Calculate the needed buffer size while the offset is multiple of 8 bytes
  6. Check C: return the needed buffer size of 8
  7. Calculate the needed buffer size while the offset is lager than extlen
  8. Check D: return the needed buffer size of -1
  9. Calculate the needed buffer size while the offset is equal to extlen
  10.Check E: return the needed buffer size of extlen


NOTE

  None


REFERENCE

  RFC 3542
  10.3.  inet6_opt_finish
      int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset);
    Offset should be the length returned by inet6_opt_init() or
    inet6_opt_append().  This function returns the updated total length
    taking into account the final padding of the extension header to make
    it a multiple of 8 bytes.  If extbuf is not NULL the function also
    initializes the option by inserting a Pad1 or PadN option of the
    proper length.
    If the necessary pad does not fit in the extension header buffer the
    function returns -1.