00001 /* 00002 * Copyright 2005, 2006, Internet2 00003 * Legal conditions are in file LICENSE 00004 * (MD5 = c434f2e53b8089d8b4d0172c7ce07360). 00005 */ 00006 /** 00007 * 00008 * @file vfer_accept_queue.h 00009 * @author Ivan Beschastnikh 00010 * @brief Header file for accept_queue.c 00011 * 00012 * Defines the necessary data structures and prototypes. 00013 * 00014 * - 05/26/05 ivan created 00015 */ 00016 00017 00018 #ifndef VFER_ACCEPT_QUEUE_H 00019 #define VFER_ACCEPT_QUEUE_H 00020 00021 /* 00022 * includes 00023 */ 00024 00025 #include <stdio.h> /* printf & NULL def */ 00026 #include <pthread.h> /* mutex ops */ 00027 #include "vfer_packet.h" 00028 00029 /* 00030 * data structures 00031 */ 00032 00033 /** 00034 * @brief A queued connection link in the accept_queue doubly linked list 00035 * 00036 * Caches the original request packet received and has links to the 00037 * next and previous queued connection in the doubly linked list 00038 * (links in the accept_queue type). 00039 * 00040 */ 00041 typedef struct queued_conn { 00042 /** file descriptor for socket */ 00043 int fd; 00044 /** remote address */ 00045 struct sockaddr sa; 00046 /** request packet pointer */ 00047 struct packet* request; 00048 /** next member in the list */ 00049 struct queued_conn* next; 00050 /** previous member in the list */ 00051 struct queued_conn* prev; 00052 } queued_conn; 00053 00054 /** 00055 * @brief A doubly linked list of backlogged connections waiting to be 00056 * accepted. 00057 */ 00058 typedef struct accept_queue { 00059 /** max number of queued connections allowed in the list */ 00060 int backlog; 00061 /** number of total queued connections in the list */ 00062 int count; 00063 /** list of queued connections (first in the queue)*/ 00064 struct queued_conn* first; 00065 /** last in the list of queued connections (last in the queue)*/ 00066 struct queued_conn* last; 00067 } accept_queue; 00068 00069 /* 00070 * function prototypes 00071 */ 00072 00073 accept_queue* Accept_Queue_Create (int backlog); 00074 void Accept_Queue_Delete (accept_queue* ac); 00075 int Accept_Queue_Enqueue (accept_queue* ac, int fd, struct sockaddr sa, struct packet* request); 00076 queued_conn* Accept_Queue_Dequeue (accept_queue* ac); 00077 00078 #endif /* VFER_ACCEPT_QUEUE_H */