1 // vim: noet sw=4 ts=4:
3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
22 ******************************************************************************
25 * Abstract: This routine is called to send a buffer of data to a partner
26 * if the buffer has been queued waiting for the session to
27 * unblock. The top qio block is removed from the tp block's
28 * queue and is sent. It is assumed that for UDP data the
29 * unit data structure was created and contains the buffer and
30 * address and is pointed to by the qio block. The block and
31 * associated buffers are then freed.
33 * tpptr- Pointer to the tp block
37 * Author: E. Scott Daniels
38 * Mod: 22 Feb 2002 - To support sendqueue tail
40 ******************************************************************************
42 #include "sisetup.h" // get include files etc
43 #include "sitransport.h"
45 extern void SIsend( struct ginfo_blk *gptr, struct tp_blk *tpptr ) {
46 struct t_unitdata *udata; // pointer at UDP unit data
47 struct ioq_blk *qptr; // pointer at qio block for free
49 //static int announced = 0; // TESTING
51 if( tpptr->squeue == NULL ) // who knows why we were called
52 return; // nothing queued - just leave
55 if( tpptr->type == SOCK_DGRAM ) { // udp send?
56 sendto( tpptr->fd, tpptr->squeue->data, tpptr->squeue->dlen, 0, tpptr->squeue->addr, sizeof( struct sockaddr ) );
57 if( tpptr->squeue->addr != NULL )
58 free( tpptr->squeue->data );
59 tpptr->squeue->addr = NULL;
62 status= SEND( tpptr->fd, tpptr->squeue->data, tpptr->squeue->dlen, 0 );
70 if( !announced && status < tpptr->squeue->dlen ) {
72 fprintf( stderr, ">>>>>>> !!!!!! SIsend: short send: %d != %d\n", status, tpptr->squeue->dlen );
75 free( tpptr->squeue->data ); // trash buffer or the udp block
76 qptr = tpptr->squeue; // hold pointer for free
77 tpptr->squeue = tpptr->squeue->next; // next in queue becommes head
79 tpptr->sqtail = NULL; // no tail left either
83 if( (tpptr->flags & TPF_DRAIN) && tpptr->squeue == NULL ) // done w/ drain?
85 SIterm( gptr, tpptr ); // trash the tp block