inet6_opt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * CDDL HEADER START
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * The contents of this file are subject to the terms of the
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Common Development and Distribution License, Version 1.0 only
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * (the "License"). You may not use this file except in compliance
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * with the License.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * See the License for the specific language governing permissions
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * and limitations under the License.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * When distributing Covered Code, include this CDDL HEADER in each
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * If applicable, add the following below this CDDL HEADER, with the
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * fields enclosed by brackets "[]" replaced with your own identifying
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * information: Portions Copyright [yyyy] [name of copyright owner]
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * CDDL HEADER END
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Use is subject to license terms.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt#pragma ident "%Z%%M% %I% %E% SMI"
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt * This code is conformant to RFC 3542.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * Section 10.1 RFC3542. This function returns the size of the empty
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt * extension header. If extbuf is not NULL then it initializes its length
ea3b3a75abb3f8b853f7da454b9b8e258a120eeaPatrik Flykt * field. If extlen is invalid then -1 is returned.
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt if (extbuf && ((extlen < 0) || (extlen % 8))) {
139b011ab81ccea1d51f09e0261a1c390115c6ffPatrik Flykt return (-1);
uint8_t *p;
if (extbuf) {
if (remainder == 0) {
padbytes = 0;
if (extbuf) {
return (endlen);
if (padbytes != 0) {
*p = IP6OPT_PAD1;
*p = IP6OPT_PADN;
p += padbytes;
*p++ = type;
*p++ = len;
if (databufp) {
*databufp = p;
return (endlen);
uint8_t *p;
int padbytes;
if (extbuf) {
padbytes = 0;
if (extbuf) {
if (padbytes != 0) {
*p = IP6OPT_PAD1;
*p = IP6OPT_PADN;
p += padbytes;
uint8_t *p;
if (offset == 0) {
case IP6OPT_PAD1:
case IP6OPT_PADN:
if (typep) {
*typep = *p;
if (lenp) {
if (databufp) {
databufp);
return (offset);