GNU libmicrohttpd  0.9.29
structures.h
Go to the documentation of this file.
1 /*
2  This file is part of libmicrospdy
3  Copyright (C) 2012 Andrey Uzunov
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
26 #ifndef STRUCTURES_H
27 #define STRUCTURES_H
28 
29 #include "platform.h"
30 #include "microspdy.h"
31 #include "io.h"
32 
33 
39 {
45 
51 
60 
71 
81 
88 
97 
107 
121 };
122 
123 
130 {
136 
141 
148 
154 
159 
166 };
167 
168 
173 {
178 
183 };
184 
185 
190 {
195 };
196 
197 
202 {
207 
214 };
215 
220 {
226 
232 
238 
244 
250 
256 
262 
267 
273 
279 
289 };
290 
291 
296 {
301 
307 
313 };
314 
315 
316 struct SPDYF_Stream;
317 
318 struct SPDYF_Response_Queue;
319 
320 
334 typedef int
335 (*SPDYF_NewDataCallback) (void * cls,
336  struct SPDYF_Stream *stream,
337  const void * buf,
338  size_t size,
339  bool more);
340 
341 
351 typedef int
353  struct SPDYF_Stream * stream);
354 
355 
369 typedef void
371  struct SPDYF_Response_Queue *response_queue,
372  enum SPDY_RESPONSE_RESULT status);
373 
374 
379 struct __attribute__((__packed__)) SPDYF_Control_Frame
380 {
381  uint16_t version : 15;
382  uint16_t control_bit : 1; /* always 1 for control frames */
383  uint16_t type;
384  uint32_t flags : 8;
385  uint32_t length : 24;
386 };
387 
388 
392 struct __attribute__((__packed__)) SPDYF_Data_Frame
393 {
394  uint32_t stream_id : 31;
395  uint32_t control_bit : 1; /* always 0 for data frames */
396  uint32_t flags : 8;
397  uint32_t length : 24;
398 };
399 
400 
405 {
410 
415 
420 
425 
430  struct SPDYF_Control_Frame *control_frame;
431 
436  struct SPDYF_Data_Frame *data_frame;
437 
441  void *data;
442 
446  int (* process_response_handler)(struct SPDY_Session *session);
447 
453 
457  void *frqcb_cls;
458 
463 
467  void *rrcb_cls;
468 
472  size_t data_size;
473 
478  bool is_data;
479 };
480 
481 
482 
487 {
492 
497 
501  char *name;
502 
507  char **value;
508 
512  unsigned int num_values;
513 };
514 
515 
520 {
525 
530 
535 
540 
544  void *cls;
545 
549  uint32_t stream_id;
550 
554  uint32_t assoc_stream_id;
555 
559  uint32_t window_size;
560 
564  uint8_t priority;
565 
571  uint8_t slot;
572 
577 
584 
591 
596 };
597 
598 
603 {
611 
619 
624 
629 
634 
638  struct sockaddr *addr;
639 
645 
650 
655  void *io_context;
656 
661 
666 
670  void *read_buffer;
671 
676 
680  void (*frame_handler) (struct SPDY_Session * session);
681 
686 
691  void *user_cls;
692 
697 
702 
707 
712 
717 
722 
727 
735 
743 
749 
754 
760 
766 
771 
776  unsigned long long last_activity;
777 
784 
788  socklen_t addr_len;
789 
795 
801 
810 
817 
825  uint32_t max_num_frames;
826 
832 
841 
847 
854 };
855 
856 
861 {
862 
867 
872 
877 
882 
886  void *io_context;
887 
891  char *certfile;
892 
897  char *keyfile;
898 
899 
903  struct sockaddr *address;
904 
910 
915 
920 
926 
931 
935  void *cls;
936 
941 
945  void *fcls;
946 
951 
956 
961  unsigned long long session_timeout;
962 
967 
976  uint32_t max_num_frames;
977 
982 
987 
992 
996  uint16_t port;
997 };
998 
999 
1004 {
1009  void *headers;
1010 
1015  void *data;
1016 
1023 
1027  void *rcb_cls;
1028 
1033 
1037  size_t data_size;
1038 
1044  uint32_t rcb_block_size;
1045 };
1046 
1047 
1048 /* Macros for handling data and structures */
1049 
1050 
1059 #define DLL_insert(head,tail,element) do { \
1060  (element)->next = (head); \
1061  (element)->prev = NULL; \
1062  if ((tail) == NULL) \
1063  (tail) = element; \
1064  else \
1065  (head)->prev = element; \
1066  (head) = (element); } while (0)
1067 
1068 
1078 #define DLL_remove(head,tail,element) do { \
1079  if ((element)->prev == NULL) \
1080  (head) = (element)->next; \
1081  else \
1082  (element)->prev->next = (element)->next; \
1083  if ((element)->next == NULL) \
1084  (tail) = (element)->prev; \
1085  else \
1086  (element)->next->prev = (element)->prev; \
1087  (element)->next = NULL; \
1088  (element)->prev = NULL; } while (0)
1089 
1090 
1097 #if HAVE_BIG_ENDIAN
1098 #define SPDYF_CONTROL_FRAME_HTON(frame)
1099 #else
1100 #define SPDYF_CONTROL_FRAME_HTON(frame) do { \
1101  (*((uint16_t *) frame )) = (*((uint8_t *) (frame) +1 )) | ((*((uint8_t *) frame ))<<8);\
1102  (frame)->type = htons((frame)->type); \
1103  (frame)->length = HTON24((frame)->length); \
1104  } while (0)
1105 #endif
1106 
1107 
1114 #if HAVE_BIG_ENDIAN
1115 #define SPDYF_CONTROL_FRAME_NTOH(frame)
1116 #else
1117 #define SPDYF_CONTROL_FRAME_NTOH(frame) do { \
1118  (*((uint16_t *) frame )) = (*((uint8_t *) (frame) +1 )) | ((*((uint8_t *) frame ))<<8);\
1119  (frame)->type = ntohs((frame)->type); \
1120  (frame)->length = NTOH24((frame)->length); \
1121  } while (0)
1122 #endif
1123 
1124 
1131 #if HAVE_BIG_ENDIAN
1132 #define SPDYF_DATA_FRAME_HTON(frame)
1133 #else
1134 #define SPDYF_DATA_FRAME_HTON(frame) do { \
1135  *((uint32_t *) frame ) = htonl(*((uint32_t *) frame ));\
1136  (frame)->length = HTON24((frame)->length); \
1137  } while (0)
1138 #endif
1139 
1140 
1147 #if HAVE_BIG_ENDIAN
1148 #define SPDYF_DATA_FRAME_NTOH(frame)
1149 #else
1150 #define SPDYF_DATA_FRAME_NTOH(frame) do { \
1151  *((uint32_t *) frame ) = ntohl(*((uint32_t *) frame ));\
1152  (frame)->length = NTOH24((frame)->length); \
1153  } while (0)
1154 #endif
1155 
1156 
1178 struct SPDYF_Response_Queue *
1180  void *data,
1181  size_t data_size,
1182  struct SPDY_Response *response,
1183  struct SPDYF_Stream *stream,
1184  bool closestream,
1186  void *frqcb_cls,
1188  void *rrcb_cls);
1189 
1190 
1196 void
1197 SPDYF_response_queue_destroy(struct SPDYF_Response_Queue *response_queue);
1198 
1199 
1208 int
1209 SPDYF_name_value_is_empty(struct SPDY_NameValue *container);
1210 
1211 
1224 int
1225 SPDYF_name_value_from_stream(void *stream,
1226  size_t size,
1227  struct SPDY_NameValue ** container);
1228 
1229 
1241 ssize_t
1242 SPDYF_name_value_to_stream(struct SPDY_NameValue * container[],
1243  int num_containers,
1244  void **stream);
1245 
1246 #endif
size_t read_buffer_size
Definition: structures.h:742
SPDY_NewSessionCallback new_session_cb
Definition: structures.h:909
uint16_t port
Definition: structures.h:996
struct SPDYF_Response_Queue * response_queue_tail
Definition: structures.h:665
struct SPDYF_Stream * streams_head
Definition: structures.h:644
SPDY_DAEMON_OPTION
Definition: microspdy.h:346
z_stream zlib_recv_stream
Definition: structures.h:610
SPDYF_IORecv fio_recv
Definition: structures.h:706
void * read_buffer
Definition: structures.h:670
struct SPDY_Daemon * daemon
Definition: structures.h:633
public interface to libmicrospdy
unsigned long long session_timeout
Definition: structures.h:961
uint32_t current_stream_id
Definition: structures.h:816
bool is_server_initiator
Definition: structures.h:595
void * cls
Definition: structures.h:935
int(* SPDYF_NewDataCallback)(void *cls, struct SPDYF_Stream *stream, const void *buf, size_t size, bool more)
Definition: structures.h:335
int SPDYF_name_value_is_empty(struct SPDY_NameValue *container)
Definition: structures.c:35
struct SPDY_Session * next
Definition: structures.h:623
SPDY_RST_STREAM_STATUS
Definition: structures.h:219
void * fcls
Definition: structures.h:945
SPDYF_IODeinit fio_deinit
Definition: structures.h:955
struct SPDYF_Response_Queue * response_queue_head
Definition: structures.h:660
void * cls
Definition: structures.h:544
SPDYF_IOCloseSession fio_close_session
Definition: structures.h:701
SPDYF_IONewSession fio_new_session
Definition: structures.h:696
void * io_context
Definition: structures.h:655
int(* SPDYF_IONewSession)(struct SPDY_Session *session)
Definition: io.h:105
uint32_t last_replied_to_stream_id
Definition: structures.h:809
struct SPDYF_Control_Frame * control_frame
Definition: structures.h:430
ssize_t(* SPDY_ResponseCallback)(void *cls, void *buffer, size_t max, bool *more)
Definition: microspdy.h:724
uint32_t last_out_stream_id
Definition: structures.h:800
size_t write_buffer_beginning
Definition: structures.h:770
SPDY_NewRequestCallback new_request_cb
Definition: structures.h:919
socklen_t addr_len
Definition: structures.h:788
struct SPDYF_Response_Queue * SPDYF_response_queue_create(bool is_data, void *data, size_t data_size, struct SPDY_Response *response, struct SPDYF_Stream *stream, bool closestream, SPDYF_ResponseQueueResultCallback frqcb, void *frqcb_cls, SPDY_ResponseResultCallback rrcb, void *rrcb_cls)
Definition: structures.c:290
SPDYF_IOInit fio_init
Definition: structures.h:950
void(* frame_handler)(struct SPDY_Session *session)
Definition: structures.h:680
bool is_out_closed
Definition: structures.h:590
ssize_t SPDYF_name_value_to_stream(struct SPDY_NameValue *container[], int num_containers, void **stream)
Definition: structures.c:457
struct sockaddr * address
Definition: structures.h:903
void * write_buffer
Definition: structures.h:675
SPDY_SessionClosedCallback session_closed_cb
Definition: structures.h:914
void(* SPDY_NewRequestCallback)(void *cls, struct SPDY_Request *request, uint8_t priority, const char *method, const char *path, const char *version, const char *host, const char *scheme, struct SPDY_NameValue *headers, bool more)
Definition: microspdy.h:670
platform-specific includes for libmicrohttpd
uint32_t max_num_frames
Definition: structures.h:976
unsigned long long last_activity
Definition: structures.h:776
int(* SPDYF_IOBeforeWrite)(struct SPDY_Session *session)
Definition: io.h:174
Signatures for IO functions.
struct SPDYF_Response_Queue * prev
Definition: structures.h:414
uint32_t assoc_stream_id
Definition: structures.h:554
uint32_t max_num_frames
Definition: structures.h:825
enum SPDY_IO_SUBSYSTEM io_subsystem
Definition: structures.h:991
void(* SPDYF_ResponseQueueResultCallback)(void *cls, struct SPDYF_Response_Queue *response_queue, enum SPDY_RESPONSE_RESULT status)
Definition: structures.h:370
SPDY_CONTROL_FRAME_TYPES
Definition: structures.h:38
char * keyfile
Definition: structures.h:897
bool is_goaway_received
Definition: structures.h:853
void(* SPDY_ResponseResultCallback)(void *cls, struct SPDY_Response *response, struct SPDY_Request *request, enum SPDY_RESPONSE_RESULT status, bool streamopened)
Definition: microspdy.h:753
SPDYF_ResponseQueueResultCallback frqcb
Definition: structures.h:452
SPDY_ResponseCallback rcb
Definition: structures.h:1022
void(* SPDY_NewSessionCallback)(void *cls, struct SPDY_Session *session)
Definition: microspdy.h:606
struct SPDY_Session * cleanup_head
Definition: structures.h:876
void(* SPDYF_IOCloseSession)(struct SPDY_Session *session)
Definition: io.h:115
struct SPDY_NameValue * next
Definition: structures.h:491
void * headers
Definition: structures.h:1009
SPDY_GOAWAY_STATUS
Definition: structures.h:295
bool read_closed
Definition: structures.h:840
void * rcb_cls
Definition: structures.h:1027
unsigned int num_values
Definition: structures.h:512
uint32_t last_in_stream_id
Definition: structures.h:794
bool is_in_closed
Definition: structures.h:583
char * certfile
Definition: structures.h:891
SPDY_SYN_REPLY_FLAG
Definition: structures.h:189
struct SPDYF_Stream * next
Definition: structures.h:524
size_t read_ignore_bytes
Definition: structures.h:734
int SPDYF_name_value_from_stream(void *stream, size_t size, struct SPDY_NameValue **container)
Definition: structures.c:554
int(* SPDYF_IOIsPending)(struct SPDY_Session *session)
Definition: io.h:162
SPDY_DATA_FLAG
Definition: structures.h:201
enum SPDY_DAEMON_OPTION options
Definition: structures.h:981
int(* SPDYF_IORecv)(struct SPDY_Session *session, void *buffer, size_t size)
Definition: io.h:130
bool is_goaway_sent
Definition: structures.h:846
struct SPDY_Session * sessions_head
Definition: structures.h:866
int(* SPDY_NewDataCallback)(void *cls, struct SPDY_Request *request, const void *buf, size_t size, bool more)
Definition: microspdy.h:698
SPDYF_IOAfterWrite fio_after_write
Definition: structures.h:726
char ** value
Definition: structures.h:507
uint8_t slot
Definition: structures.h:571
void(* SPDY_SessionClosedCallback)(void *cls, struct SPDY_Session *session, int by_client)
Definition: microspdy.h:623
int(* SPDYF_NewStreamCallback)(void *cls, struct SPDYF_Stream *stream)
Definition: structures.h:352
struct SPDYF_Stream * prev
Definition: structures.h:529
struct sockaddr * addr
Definition: structures.h:638
uint32_t rcb_block_size
Definition: structures.h:1044
size_t write_buffer_size
Definition: structures.h:759
struct SPDYF_Data_Frame * data_frame
Definition: structures.h:436
SPDYF_NewStreamCallback fnew_stream_cb
Definition: structures.h:940
bool flag_unidirectional
Definition: structures.h:576
size_t read_buffer_beginning
Definition: structures.h:753
void * user_cls
Definition: structures.h:691
enum SPDY_SESSION_STATUS status
Definition: structures.h:831
struct SPDY_Session * cleanup_tail
Definition: structures.h:881
struct SPDY_NameValue * prev
Definition: structures.h:496
size_t write_buffer_offset
Definition: structures.h:765
SPDY_RESPONSE_RESULT
Definition: microspdy.h:561
SPDY_SYN_STREAM_FLAG
Definition: structures.h:172
struct SPDY_Session * prev
Definition: structures.h:628
uint32_t window_size
Definition: structures.h:559
size_t headers_size
Definition: structures.h:1032
uint8_t priority
Definition: structures.h:564
SPDY_DAEMON_FLAG
Definition: microspdy.h:401
int(* SPDYF_IOInit)(struct SPDY_Daemon *daemon)
Definition: io.h:84
struct SPDY_NameValue * headers
Definition: structures.h:539
int(* process_response_handler)(struct SPDY_Session *session)
Definition: structures.h:446
SPDYF_IOSend fio_send
Definition: structures.h:711
SPDY_SESSION_STATUS
Definition: structures.h:129
struct __attribute__((__packed__)) SPDYF_Control_Frame
Definition: structures.h:379
size_t data_size
Definition: structures.h:1037
SPDY_ResponseResultCallback rrcb
Definition: structures.h:462
int(* SPDYF_IOAfterWrite)(struct SPDY_Session *session, int was_written)
Definition: io.h:187
uint32_t stream_id
Definition: structures.h:549
struct SPDY_Session * sessions_tail
Definition: structures.h:871
void * io_context
Definition: structures.h:886
void(* SPDYF_IODeinit)(struct SPDY_Daemon *daemon)
Definition: io.h:94
enum SPDY_DAEMON_FLAG flags
Definition: structures.h:986
struct SPDYF_Stream * streams_tail
Definition: structures.h:649
void * frame_handler_cls
Definition: structures.h:685
int(* SPDYF_IOSend)(struct SPDY_Session *session, const void *buffer, size_t size)
Definition: io.h:148
SPDYF_IOIsPending fio_is_pending
Definition: structures.h:716
size_t read_buffer_offset
Definition: structures.h:748
struct SPDYF_Response_Queue * next
Definition: structures.h:409
SPDY_IO_SUBSYSTEM
Definition: microspdy.h:318
struct SPDYF_Stream * stream
Definition: structures.h:419
SPDYF_NewDataCallback freceived_data_cb
Definition: structures.h:930
z_stream zlib_send_stream
Definition: structures.h:618
SPDYF_IOBeforeWrite fio_before_write
Definition: structures.h:721
struct SPDY_Response * response
Definition: structures.h:424
SPDY_NewDataCallback received_data_cb
Definition: structures.h:925
struct SPDY_Session * session
Definition: structures.h:534
void SPDYF_response_queue_destroy(struct SPDYF_Response_Queue *response_queue)
Definition: structures.c:435