GNU libmicrohttpd  0.9.29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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