/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Modified to be used by inetboot. */
#include <socket_impl.h>
#include "tcp_inet.h"
#include "tcp_sack.h"
/*
* To insert a new blk to the array of SACK blk in receiver.
*
* Parameters:
* sack_blk_t *head: pointer to the array of SACK blks.
* tcp_seq begin: starting seq num of the new blk.
* tcp_seq end: ending seq num of the new blk.
* int32_t *num: (referenced) total num of SACK blks on the list.
*/
void
{
/* The array is empty, just add the new one. */
if (*num == 0) {
*num = 1;
return;
}
/*
* Check for overlap. There are five cases.
*
* 1. there is no overlap with any other SACK blks.
* 2. new SACK blk is completely contained in another blk.
* 3. tail part of new SACK blk overlaps with another blk.
* 4. head part of new SACK blk overlaps with another blk.
* 5. new SACK blk completely contains another blk.
*
* Use tmp to hold old SACK blks. After the loop, copy them back
* to head.
*/
}
j = 0;
for (i = 0; i < old_num; i++) {
/* Case 1: continue to check. */
j++;
continue;
/* Case 2: re-insert the old blk to the head. */
/*
* Case 3: Extend the new blk, remove the old one
* and continue to check.
*/
/* Case 4 */
}
/*
* Common code for all cases except the first one, which
* copies the original SACK blk into the tmp storage. Other
* cases remove the original SACK blk by not copying into
* tmp storage.
*/
new_num--;
}
for (i = 0; i < new_num; i++) {
}
}
/*
* To remove a SACK block.
*
* Parameters:
* sack_blk_t *head: pointer to the array of SACK blks.
* tcp_seq end: to remove all sack blk with seq num less than end.
* int32_t *num: (referenced) total num of SACK blks in the array.
*/
void
{
if (*num == 0)
return;
j = 0;
/* Walk thru the whole list and copy the new list to tmp[]. */
for (i = 0; i < old_num; i++) {
/*
* Check to see if the old SACK blk needs to be
* removed or updated. If the old blk is just
* partially covered, update begin and continue.
* If the old blk is completely covered, remove it
* and continue to check.
*/
new_num--;
continue;
} else {
}
} else {
}
j++;
}
/* Copy tmp[] back to the original list. */
for (i = 0; i < new_num; i++) {
}
}
/*
* Use the SACK info to insert a "notsack'ed" blk. The notsack'ed blk list
* contains the list of blks which have not been selectively acknowledged
* by the receiver. The SACK info is a blk which is being selectively
* acknowledged by the receiver.
*
* Parameters:
* notsack_blk_t **head: address of the pointer to the list of notsack'ed
* blks.
* tcp_seq begin: starting seq num of the SACK info.
* tcp_seq end: ending seq num of the SACK info.
* int32_t *num: (referenced) total num of notsack'ed blk on the list.
* uint32_t *sum: (referenced) total num of bytes of all the notsack'ed
* blks.
*/
void
{
return;
}
/* Find the right place of updating the list. */
}
/*
* This can happen only when TCP sends new data but the notsack list
* is not updated.
*/
return;
}
/*
* This means the new SACK info covers something that is not on
* the list anymore.
*/
return;
}
/* The SACK info covers up to this blk. So just check for this blk. */
/*
* Only this notsack'ed blk is completely covered. Delete
* it and return.
*/
} else {
}
(*num)--;
return;
}
/* This blk is partially covered. */
/* Check what needs to be updated. */
} else {
/* Split the notsack blk. */
sizeof (notsack_blk_t))) == NULL) {
return;
}
(*num)++;
}
} else {
}
return;
}
/* Need to check for coverage of this blk and later blks. */
}
/* The coverage stops here. */
break;
} else {
/* Is the blk completely or partially covered? */
tmp_num--;
sizeof (notsack_blk_t));
} else {
sizeof (notsack_blk_t));
}
} else {
/*
* This blk is partially covered. It also
* means it should be the end of coverage.
*/
break;
}
}
}
}
/*
* To remove notsack'ed blks.
*
* Parameters:
* notsack_blk_t **head: address of the pointer to the list of notsack'ed
* blks.
* tcp_seq end: to remove all notsack'ed blk with seq num less than end.
* int32_t *num: (referenced) total num of notsack'ed blks.
* uint32_t *sum: (referenced) total num of bytes of all the notsack'ed
* blks.
*/
void
{
return;
/* There is nothing to discard. */
break;
}
/* Is the blk completely or partially covered? */
(*num)--;
sizeof (notsack_blk_t));
} else {
sizeof (notsack_blk_t));
}
} else {
break;
}
}
}
/*
* To update the notsack'ed list when new data is sent.
*
* Assumption: this should only be called when new notsack blk is to be added.
*
* Parameters:
* notsack_blk_t **head: address of the pointer to the list of notsack'ed
* blks.
* tcp_seq begin: beginning seq num of new data.
* tcp_seq end: ending seq num of new data.
* int32_t *num: (referenced) total num of notsack'ed blks.
* uint32_t *sum: (referenced) total num of bytes of all the notsack'ed
* blks.
*/
{
/* If the list is empty, create a new one. */
sizeof (notsack_blk_t))) == NULL) {
return;
}
*num = 1;
return;
}
/*
* Find the place to add the new blk. This assumes that new data
* is being sent, so the place to insert the new notsack blk is at
* the end of the list.
*/
}
/* Does the new blk overlap with old one? */
} else {
/* No. Need to create a new notsack blk. */
sizeof (notsack_blk_t));
(*num)++;
}
}
}