Select patches for TCP read and write. TCP support for FIONREAD.
This commit is contained in:
		
							parent
							
								
									11cbb6faae
								
							
						
					
					
						commit
						c60f3ff846
					
				@ -706,8 +706,8 @@ ioreq_t req;
 | 
			
		||||
	tcp_conn_t *tcp_conn;
 | 
			
		||||
	nwio_tcpconf_t *tcp_conf;
 | 
			
		||||
	nwio_tcpopt_t *tcp_opt;
 | 
			
		||||
	acc_t *conf_acc, *opt_acc;
 | 
			
		||||
	int result;
 | 
			
		||||
	acc_t *acc, *conf_acc, *opt_acc;
 | 
			
		||||
	int result, *bytesp;
 | 
			
		||||
 | 
			
		||||
	tcp_fd= &tcp_fd_table[fd];
 | 
			
		||||
 | 
			
		||||
@ -833,6 +833,17 @@ assert (conf_acc->acc_length == sizeof(*tcp_conf));
 | 
			
		||||
		reply_thr_get (tcp_fd, NW_OK, TRUE);
 | 
			
		||||
		result= NW_OK;
 | 
			
		||||
		break;
 | 
			
		||||
	case FIONREAD:
 | 
			
		||||
		acc= bf_memreq(sizeof(*bytesp));
 | 
			
		||||
		bytesp= (int *)ptr2acc_data(acc);
 | 
			
		||||
		tcp_bytesavailable(tcp_fd, bytesp);
 | 
			
		||||
		result= (*tcp_fd->tf_put_userdata)(tcp_fd->tf_srfd,
 | 
			
		||||
			0, acc, TRUE);
 | 
			
		||||
		tcp_fd->tf_flags &= ~TFF_IOCTL_IP;
 | 
			
		||||
		reply_thr_put(tcp_fd, result, TRUE);
 | 
			
		||||
		result= NW_OK;
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		tcp_fd->tf_flags &= ~TFF_IOCTL_IP;
 | 
			
		||||
		reply_thr_get(tcp_fd, EBADIOCTL, TRUE);
 | 
			
		||||
 | 
			
		||||
@ -192,6 +192,7 @@ void tcp_frag2conn ARGS(( tcp_conn_t *tcp_conn, ip_hdr_t *ip_hdr,
 | 
			
		||||
void tcp_fd_read ARGS(( tcp_conn_t *tcp_conn, int enq ));
 | 
			
		||||
unsigned tcp_sel_read ARGS(( tcp_conn_t *tcp_conn ));
 | 
			
		||||
void tcp_rsel_read ARGS(( tcp_conn_t *tcp_conn ));
 | 
			
		||||
void tcp_bytesavailable ARGS(( tcp_fd_t *tcp_fd, int *bytesp ));
 | 
			
		||||
 | 
			
		||||
/* tcp_send.c */
 | 
			
		||||
void tcp_conn_write ARGS(( tcp_conn_t *tcp_conn, int enq ));
 | 
			
		||||
 | 
			
		||||
@ -1442,6 +1442,44 @@ tcp_conn_t *tcp_conn;
 | 
			
		||||
		printf("tcp_rsel_read: no select_res\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PUBLIC void tcp_bytesavailable(tcp_fd, bytesp)
 | 
			
		||||
tcp_fd_t *tcp_fd;
 | 
			
		||||
int *bytesp;
 | 
			
		||||
{
 | 
			
		||||
	tcp_conn_t *tcp_conn;
 | 
			
		||||
	size_t data_size, read_size;
 | 
			
		||||
	acc_t *data;
 | 
			
		||||
	int fin_recv, urg, push, result;
 | 
			
		||||
	i32_t old_window, new_window;
 | 
			
		||||
	u16_t mss;
 | 
			
		||||
 | 
			
		||||
	*bytesp= 0;	/* The default is that nothing is available */
 | 
			
		||||
 | 
			
		||||
	if (!(tcp_fd->tf_flags & TFF_CONNECTED))
 | 
			
		||||
		return;
 | 
			
		||||
	tcp_conn= tcp_fd->tf_conn;
 | 
			
		||||
 | 
			
		||||
	if (tcp_conn->tc_state == TCS_CLOSED)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	urg= tcp_Gmod4G(tcp_conn->tc_RCV_UP, tcp_conn->tc_RCV_LO);
 | 
			
		||||
	push= (tcp_conn->tc_flags & TCF_RCV_PUSH);
 | 
			
		||||
	fin_recv= (tcp_conn->tc_flags & TCF_FIN_RECV);
 | 
			
		||||
 | 
			
		||||
	data_size= tcp_conn->tc_RCV_NXT-tcp_conn->tc_RCV_LO;
 | 
			
		||||
	if (fin_recv)
 | 
			
		||||
		data_size--;
 | 
			
		||||
	if (urg)
 | 
			
		||||
		data_size= tcp_conn->tc_RCV_UP-tcp_conn->tc_RCV_LO;
 | 
			
		||||
 | 
			
		||||
	if (urg && !(tcp_fd->tf_flags & TFF_RECV_URG))
 | 
			
		||||
		return;
 | 
			
		||||
	else if (!urg && (tcp_fd->tf_flags & TFF_RECV_URG))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	*bytesp= data_size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * $PchId: tcp_recv.c,v 1.30 2005/06/28 14:21:35 philip Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@ -26,6 +26,7 @@ Copyright 1995 Philip Homburg
 | 
			
		||||
#else /* Assume at least Minix 3.x */
 | 
			
		||||
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <sys/ioc_file.h>
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
#include <minix/config.h>
 | 
			
		||||
#include <minix/type.h>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user