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
50 if( tpptr->squeue == NULL ) // who knows why we were called
51 return; // nothing queued - just leave
54 if( tpptr->type == SOCK_DGRAM ) { // udp send?
55 sendto( tpptr->fd, tpptr->squeue->data, tpptr->squeue->dlen, 0, tpptr->squeue->addr, sizeof( struct sockaddr ) );
56 if( tpptr->squeue->addr != NULL )
57 free( tpptr->squeue->data );
58 tpptr->squeue->addr = NULL;
61 status= SEND( tpptr->fd, tpptr->squeue->data, tpptr->squeue->dlen, 0 );
66 free( tpptr->squeue->data ); // trash buffer or the udp block
67 qptr = tpptr->squeue; // hold pointer for free
68 tpptr->squeue = tpptr->squeue->next; // next in queue becommes head
70 tpptr->sqtail = NULL; // no tail left either
74 if( (tpptr->flags & TPF_DRAIN) && tpptr->squeue == NULL ) // done w/ drain?
76 SIterm( gptr, tpptr ); // close the session and mark the block for delte