[radvd-devel-l] how is the length field calcuted for the radvd options

Magesh mannar mageshmannar at yahoo.com
Tue Feb 28 06:25:37 EST 2006

  I am going through the radvd src code. In send.c program, i find the send_ra() fn which creates the various options and sends the ra using sendmsg.
  I suppose the msgs are created in the TLV format. I am wondering how the length filed is calculated. For example, while creating the prefix info option, the length field is set to 4 (pinfo->nd_opt_pi_len = 4;). Can you please let me know how the length field is calculated and how it is 4 for the prefix option
  dlog(LOG_DEBUG, 3, "Adding prefix on %p", prefix);
  if( prefix->enabled )
  struct nd_opt_prefix_info *pinfo;
  pinfo = (struct nd_opt_prefix_info *) (buff + len);
  pinfo->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION;
  pinfo->nd_opt_pi_len = 4;
  pinfo->nd_opt_pi_prefix_len = prefix->PrefixLen;
  pinfo->nd_opt_pi_flags_reserved = 
  pinfo->nd_opt_pi_flags_reserved |=
  /* Mobile IPv6 ext */
  pinfo->nd_opt_pi_flags_reserved |=
  pinfo->nd_opt_pi_valid_time = htonl(prefix->AdvValidLifetime);
  pinfo->nd_opt_pi_preferred_time = htonl(prefix->AdvPreferredLifetime);
  pinfo->nd_opt_pi_reserved2 = 0;
  memcpy(&pinfo->nd_opt_pi_prefix, &prefix->Prefix,
  sizeof(struct in6_addr));
  len += sizeof(*pinfo);
  Sorry for troubling with a trivial doubt.
  Many thanks

Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.litech.org/pipermail/radvd-devel-l/attachments/20060228/da39374a/attachment.htm

More information about the radvd-devel-l mailing list