1#ifndef _BASE_H_ 2#define _BASE_H_ 3 4#ifdef HAVE_CONFIG_H 5# include "config.h" 6#endif 7#include "settings.h" 8 9#include <sys/types.h> 10#include <sys/time.h> 11#include <sys/stat.h> 12 13#include <limits.h> 14 15#ifdef HAVE_STDINT_H 16# include <stdint.h> 17#endif 18 19#ifdef HAVE_INTTYPES_H 20# include <inttypes.h> 21#endif 22 23#include "buffer.h" 24#include "array.h" 25#include "chunk.h" 26#include "keyvalue.h" 27#include "fdevent.h" 28#include "sys-socket.h" 29#include "splaytree.h" 30#include "etag.h" 31 32 33#if defined HAVE_LIBSSL && defined HAVE_OPENSSL_SSL_H 34# define USE_OPENSSL 35# include <openssl/ssl.h> 36# if ! defined OPENSSL_NO_TLSEXT && ! defined SSL_CTRL_SET_TLSEXT_HOSTNAME 37# define OPENSSL_NO_TLSEXT 38# endif 39#endif 40 41#ifdef HAVE_FAM_H 42# include <fam.h> 43#endif 44 45#ifndef O_BINARY 46# define O_BINARY 0 47#endif 48 49#ifndef O_LARGEFILE 50# define O_LARGEFILE 0 51#endif 52 53#ifndef SIZE_MAX 54# ifdef SIZE_T_MAX 55# define SIZE_MAX SIZE_T_MAX 56# else 57# define SIZE_MAX ((size_t)~0) 58# endif 59#endif 60 61#ifndef SSIZE_MAX 62# define SSIZE_MAX ((size_t)~0 >> 1) 63#endif 64 65#ifdef __APPLE__ 66#include <crt_externs.h> 67#define environ (* _NSGetEnviron()) 68#else 69extern char **environ; 70#endif 71 72/* for solaris 2.5 and NetBSD 1.3.x */ 73#ifndef HAVE_SOCKLEN_T 74typedef int socklen_t; 75#endif 76 77/* solaris and NetBSD 1.3.x again */ 78#if (!defined(HAVE_STDINT_H)) && (!defined(HAVE_INTTYPES_H)) && (!defined(uint32_t)) 79# define uint32_t u_int32_t 80#endif 81 82 83#ifndef SHUT_WR 84# define SHUT_WR 1 85#endif 86 87typedef enum { T_CONFIG_UNSET, 88 T_CONFIG_STRING, 89 T_CONFIG_SHORT, 90 T_CONFIG_INT, 91 T_CONFIG_BOOLEAN, 92 T_CONFIG_ARRAY, 93 T_CONFIG_LOCAL, 94 T_CONFIG_DEPRECATED, 95 T_CONFIG_UNSUPPORTED 96} config_values_type_t; 97 98typedef enum { T_CONFIG_SCOPE_UNSET, 99 T_CONFIG_SCOPE_SERVER, 100 T_CONFIG_SCOPE_CONNECTION 101} config_scope_type_t; 102 103typedef struct { 104 const char *key; 105 void *destination; 106 107 config_values_type_t type; 108 config_scope_type_t scope; 109} config_values_t; 110 111typedef enum { 112 DIRECT, 113 EXTERNAL, 114 SMB_BASIC, 115 SMB_NTLM 116} connection_type; 117 118typedef struct { 119 char *key; 120 connection_type type; 121 char *value; 122} request_handler; 123 124typedef struct { 125 char *key; 126 char *host; 127 unsigned short port; 128 int used; 129 short factor; 130} fcgi_connections; 131 132 133typedef union { 134#ifdef HAVE_IPV6 135 struct sockaddr_in6 ipv6; 136#endif 137 struct sockaddr_in ipv4; 138#ifdef HAVE_SYS_UN_H 139 struct sockaddr_un un; 140#endif 141 struct sockaddr plain; 142} sock_addr; 143 144/* fcgi_response_header contains ... */ 145#define HTTP_STATUS BV(0) 146#define HTTP_CONNECTION BV(1) 147#define HTTP_CONTENT_LENGTH BV(2) 148#define HTTP_DATE BV(3) 149#define HTTP_LOCATION BV(4) 150 151typedef struct { 152 /** HEADER */ 153 /* the request-line */ 154 buffer *request; 155 buffer *uri; 156 157 buffer *orig_uri; 158 159 http_method_t http_method; 160 http_version_t http_version; 161 162 buffer *request_line; 163 164 /* strings to the header */ 165 buffer *http_host; /* not alloced */ 166 const char *http_range; 167 const char *http_content_type; 168 const char *http_if_modified_since; 169 const char *http_if_none_match; 170 171 array *headers; 172 173 /* CONTENT */ 174 size_t content_length; /* returned by strtoul() */ 175 176 /* internal representation */ 177 int accept_encoding; 178 179 /* internal */ 180 buffer *pathinfo; 181} request; 182 183typedef struct { 184 off_t content_length; 185 int keep_alive; /* used by the subrequests in proxy, cgi and fcgi to say the subrequest was keep-alive or not */ 186 187 array *headers; 188 189 enum { 190 HTTP_TRANSFER_ENCODING_IDENTITY, HTTP_TRANSFER_ENCODING_CHUNKED 191 } transfer_encoding; 192} response; 193 194typedef struct { 195 buffer *scheme; /* scheme without colon or slashes ( "http" or "https" ) */ 196 197 /* authority with optional portnumber ("site.name" or "site.name:8080" ) NOTE: without "username:password@" */ 198 buffer *authority; 199 200 /* path including leading slash ("/" or "/index.html") - urldecoded, and sanitized ( buffer_path_simplify() && buffer_urldecode_path() ) */ 201 buffer *path; 202 buffer *path_raw; /* raw path, as sent from client. no urldecoding or path simplifying */ 203 buffer *query; /* querystring ( everything after "?", ie: in "/index.php?foo=1", query is "foo=1" ) */ 204} request_uri; 205 206typedef struct { 207 buffer *path; 208 buffer *basedir; /* path = "(basedir)(.*)" */ 209 210 buffer *doc_root; /* path = doc_root + rel_path */ 211 buffer *rel_path; 212 213 buffer *etag; 214} physical; 215 216typedef struct { 217 buffer *name; 218 buffer *etag; 219 220 struct stat st; 221 222 time_t stat_ts; 223 224#ifdef HAVE_LSTAT 225 char is_symlink; 226#endif 227 228#ifdef HAVE_FAM_H 229 int dir_version; 230#endif 231 232 buffer *content_type; 233} stat_cache_entry; 234 235typedef struct { 236 splay_tree *files; /* the nodes of the tree are stat_cache_entry's */ 237 238 buffer *dir_name; /* for building the dirname from the filename */ 239#ifdef HAVE_FAM_H 240 splay_tree *dirs; /* the nodes of the tree are fam_dir_entry */ 241 242 FAMConnection fam; 243 int fam_fcce_ndx; 244#endif 245 buffer *hash_key; /* temp-store for the hash-key */ 246} stat_cache; 247 248typedef struct { 249 array *mimetypes; 250 251 /* virtual-servers */ 252 buffer *document_root; 253 buffer *server_name; 254 buffer *error_handler; 255 buffer *server_tag; 256 buffer *dirlist_encoding; 257 buffer *errorfile_prefix; 258 259#ifdef HAVE_LIBSMBCLIENT 260 //- Sungmin add 20111017 261 buffer *auth_ntlm_list; 262#endif 263 264 unsigned short max_keep_alive_requests; 265 unsigned short max_keep_alive_idle; 266 unsigned short max_read_idle; 267 unsigned short max_write_idle; 268 unsigned short use_xattr; 269 unsigned short follow_symlink; 270 unsigned short range_requests; 271 272 /* debug */ 273 274 unsigned short log_file_not_found; 275 unsigned short log_request_header; 276 unsigned short log_request_handling; 277 unsigned short log_response_header; 278 unsigned short log_condition_handling; 279 unsigned short log_ssl_noise; 280 unsigned short log_timeouts; 281 282 283 /* server wide */ 284 buffer *ssl_pemfile; 285 buffer *ssl_ca_file; 286 buffer *ssl_cipher_list; 287 buffer *ssl_dh_file; 288 buffer *ssl_ec_curve; 289 unsigned short ssl_honor_cipher_order; /* determine SSL cipher in server-preferred order, not client-order */ 290 unsigned short ssl_empty_fragments; /* whether to not set SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS */ 291 unsigned short ssl_use_sslv2; 292 unsigned short ssl_use_sslv3; 293 unsigned short ssl_verifyclient; 294 unsigned short ssl_verifyclient_enforce; 295 unsigned short ssl_verifyclient_depth; 296 buffer *ssl_verifyclient_username; 297 unsigned short ssl_verifyclient_export_cert; 298 unsigned short ssl_disable_client_renegotiation; 299 300 unsigned short use_ipv6, set_v6only; /* set_v6only is only a temporary option */ 301 unsigned short defer_accept; 302 unsigned short ssl_enabled; /* only interesting for setting up listening sockets. don't use at runtime */ 303 unsigned short allow_http11; 304 unsigned short etag_use_inode; 305 unsigned short etag_use_mtime; 306 unsigned short etag_use_size; 307 unsigned short force_lowercase_filenames; /* if the FS is case-insensitive, force all files to lower-case */ 308 unsigned int max_request_size; 309 310 unsigned short kbytes_per_second; /* connection kb/s limit */ 311 312 /* configside */ 313 unsigned short global_kbytes_per_second; /* */ 314 315 off_t global_bytes_per_second_cnt; 316 /* server-wide traffic-shaper 317 * 318 * each context has the counter which is inited once 319 * a second by the global_kbytes_per_second config-var 320 * 321 * as soon as global_kbytes_per_second gets below 0 322 * the connected conns are "offline" a little bit 323 * 324 * the problem: 325 * we somehow have to loose our "we are writable" signal 326 * on the way. 327 * 328 */ 329 off_t *global_bytes_per_second_cnt_ptr; /* */ 330 331#ifdef USE_OPENSSL 332 SSL_CTX *ssl_ctx; /* not patched */ 333 /* SNI per host: with COMP_SERVER_SOCKET, COMP_HTTP_SCHEME, COMP_HTTP_HOST */ 334 EVP_PKEY *ssl_pemfile_pkey; 335 X509 *ssl_pemfile_x509; 336 STACK_OF(X509_NAME) *ssl_ca_file_cert_names; 337#endif 338} specific_config; 339 340/* the order of the items should be the same as they are processed 341 * read before write as we use this later */ 342typedef enum { 343 CON_STATE_CONNECT, 344 CON_STATE_REQUEST_START, 345 CON_STATE_READ, 346 CON_STATE_REQUEST_END, 347 CON_STATE_READ_POST, 348 CON_STATE_HANDLE_REQUEST, 349 CON_STATE_RESPONSE_START, 350 CON_STATE_WRITE, 351 CON_STATE_RESPONSE_END, 352 CON_STATE_ERROR, 353 CON_STATE_CLOSE 354} connection_state_t; 355 356typedef enum { COND_RESULT_UNSET, COND_RESULT_FALSE, COND_RESULT_TRUE } cond_result_t; 357typedef struct { 358 cond_result_t result; 359 int patterncount; 360 int matches[3 * 10]; 361 buffer *comp_value; /* just a pointer */ 362 363 comp_key_t comp_type; 364} cond_cache_t; 365 366//- Sungmin add 367#ifdef HAVE_LIBSMBCLIENT 368#include <libsmbclient.h> 369#define uint32 unsigned int 370 371#define NMB_PORT 137 372#define SMB_PORT 445 373 374/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */ 375#define CAP_RAW_MODE 0x0001 376#define CAP_MPX_MODE 0x0002 377#define CAP_UNICODE 0x0004 378#define CAP_LARGE_FILES 0x0008 379#define CAP_NT_SMBS 0x0010 380#define CAP_RPC_REMOTE_APIS 0x0020 381#define CAP_STATUS32 0x0040 382#define CAP_LEVEL_II_OPLOCKS 0x0080 383#define CAP_LOCK_AND_READ 0x0100 384#define CAP_NT_FIND 0x0200 385#define CAP_DFS 0x1000 386#define CAP_W2K_SMBS 0x2000 387#define CAP_LARGE_READX 0x4000 388#define CAP_LARGE_WRITEX 0x8000 389#define CAP_UNIX 0x800000 /* Capabilities for UNIX extensions. Created by HP. */ 390#define CAP_EXTENDED_SECURITY 0x80000000 391 392/* CreateDisposition field. */ 393#define FILE_SUPERSEDE 0 /* File exists overwrite/supersede. File not exist create. */ 394#define FILE_OPEN 1 /* File exists open. File not exist fail. */ 395#define FILE_CREATE 2 /* File exists fail. File not exist create. */ 396#define FILE_OPEN_IF 3 /* File exists open. File not exist create. */ 397#define FILE_OVERWRITE 4 /* File exists overwrite. File not exist fail. */ 398#define FILE_OVERWRITE_IF 5 /* File exists overwrite. File not exist create. */ 399 400/* CreateOptions field. */ 401#define FILE_DIRECTORY_FILE 0x0001 402#define FILE_WRITE_THROUGH 0x0002 403#define FILE_SEQUENTIAL_ONLY 0x0004 404#define FILE_NO_INTERMEDIATE_BUFFERING 0x0008 405#define FILE_SYNCHRONOUS_IO_ALERT 0x0010 /* may be ignored */ 406#define FILE_SYNCHRONOUS_IO_NONALERT 0x0020 /* may be ignored */ 407#define FILE_NON_DIRECTORY_FILE 0x0040 408#define FILE_CREATE_TREE_CONNECTION 0x0080 /* ignore, should be zero */ 409#define FILE_COMPLETE_IF_OPLOCKED 0x0100 /* ignore, should be zero */ 410#define FILE_NO_EA_KNOWLEDGE 0x0200 411#define FILE_EIGHT_DOT_THREE_ONLY 0x0400 /* aka OPEN_FOR_RECOVERY: ignore, should be zero */ 412#define FILE_RANDOM_ACCESS 0x0800 413#define FILE_DELETE_ON_CLOSE 0x1000 414#define FILE_OPEN_BY_FILE_ID 0x2000 415#define FILE_OPEN_FOR_BACKUP_INTENT 0x4000 416#define FILE_NO_COMPRESSION 0x8000 417#define FILE_RESERVER_OPFILTER 0x00100000 /* ignore, should be zero */ 418#define FILE_OPEN_REPARSE_POINT 0x00200000 419#define FILE_OPEN_NO_RECALL 0x00400000 420#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 /* ignore should be zero */ 421 422/* File Specific access rights */ 423#define FILE_READ_DATA 0x00000001 424#define FILE_WRITE_DATA 0x00000002 425#define FILE_APPEND_DATA 0x00000004 426#define FILE_READ_EA 0x00000008 /* File and directory */ 427#define FILE_WRITE_EA 0x00000010 /* File and directory */ 428#define FILE_EXECUTE 0x00000020 429#define FILE_DELETE_CHILD 0x00000040 430#define FILE_READ_ATTRIBUTES 0x00000080 431#define FILE_WRITE_ATTRIBUTES 0x00000100 432 433#define FILE_ALL_ACCESS 0x000001FF 434 435typedef enum auth_type { 436 SMB_AUTH_UNSET, 437 SMB_AUTH_BASIC, 438 SMB_AUTH_NTLM 439}SMB_AUTH_TYPE; 440 441typedef enum ntlm_message_type 442{ 443 NTLMSSP_INITIAL = 0 /* samba internal state */, 444 NTLMSSP_NEGOTIATE = 1, 445 NTLMSSP_CHALLENGE = 2, 446 NTLMSSP_AUTH = 3, 447 NTLMSSP_UNKNOWN = 4, 448 NTLMSSP_DONE = 5 /* samba final state */ 449}NTLM_MESSAGE_TYPE; 450 451typedef enum { 452 SMB_FILE_QUERY, 453 SMB_SHARE_QUERY, 454 SMB_HOST_QUERY 455}URI_QUERY_TYPE; 456 457/* protocol types. It assumes that higher protocols include lower protocols 458 as subsets */ 459enum protocol_types { 460 PROTOCOL_NONE, 461 PROTOCOL_CORE, 462 PROTOCOL_COREPLUS, 463 PROTOCOL_LANMAN1, 464 PROTOCOL_LANMAN2, 465 PROTOCOL_NT1, 466 PROTOCOL_SMB2 467}; 468 469typedef struct smb_info_s { 470 471 SMB_AUTH_TYPE auth_type; 472 473 //common part 474 buffer *workgroup; 475 buffer *server; 476 buffer *share; 477 buffer *path; 478 URI_QUERY_TYPE qflag; 479 buffer *user_agent; 480 buffer *src_ip; 481 int auth_right; 482 483 int login_count; 484 time_t login_begin_time; 485 486 //for Basic 487 buffer *username; 488 buffer *password; 489 time_t auth_time; 490 //unsigned char is_authed; 491 492 //for NTLM 493 struct cli_state *cli; 494 NTLM_MESSAGE_TYPE state; 495 void *ntlmssp_state; 496 497 buffer *asus_token; 498 499 struct smb_info_s *prev, *next; 500 501}smb_info_t; 502#endif 503 504typedef struct { 505 connection_state_t state; 506 507 /* timestamps */ 508 time_t read_idle_ts; 509 time_t close_timeout_ts; 510 time_t write_request_ts; 511 512 time_t connection_start; 513 time_t request_start; 514 515 struct timeval start_tv; 516 517 size_t request_count; /* number of requests handled in this connection */ 518 size_t loops_per_request; /* to catch endless loops in a single request 519 * 520 * used by mod_rewrite, mod_fastcgi, ... and others 521 * this is self-protection 522 */ 523 524 int fd; /* the FD for this connection */ 525 int fde_ndx; /* index for the fdevent-handler */ 526 int ndx; /* reverse mapping to server->connection[ndx] */ 527 528 /* fd states */ 529 int is_readable; 530 int is_writable; 531 532 int keep_alive; /* only request.c can enable it, all other just disable */ 533 int keep_alive_idle; /* remember max_keep_alive_idle from config */ 534 535 int file_started; 536 int file_finished; 537 538 chunkqueue *write_queue; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */ 539 chunkqueue *read_queue; /* a small queue for low-level read ( HTTP request ) [ mem ] */ 540 chunkqueue *request_content_queue; /* takes request-content into tempfile if necessary [ tempfile, mem ]*/ 541 542 int traffic_limit_reached; 543 544 off_t bytes_written; /* used by mod_accesslog, mod_rrd */ 545 off_t bytes_written_cur_second; /* used by mod_accesslog, mod_rrd */ 546 off_t bytes_read; /* used by mod_accesslog, mod_rrd */ 547 off_t bytes_header; 548 549 int http_status; 550 551 sock_addr dst_addr; 552 buffer *dst_addr_buf; 553 554 buffer *asus_token; 555 556 /* request */ 557 buffer *parse_request; 558 unsigned int parsed_response; /* bitfield which contains the important header-fields of the parsed response header */ 559 560 request request; 561 request_uri uri; 562 physical physical; 563 response response; 564 565 size_t header_len; 566 567 array *environment; /* used to pass lighttpd internal stuff to the FastCGI/CGI apps, setenv does that */ 568 569 /* response */ 570 int got_response; 571 572 int in_joblist; 573 574 connection_type mode; 575 576 void **plugin_ctx; /* plugin connection specific config */ 577 578 specific_config conf; /* global connection specific config */ 579 cond_cache_t *cond_cache; 580 581 buffer *server_name; 582 583 /* error-handler */ 584 buffer *error_handler; 585 int error_handler_saved_status; 586 int in_error_handler; 587 588 struct server_socket *srv_socket; /* reference to the server-socket */ 589 590#ifdef USE_OPENSSL 591 SSL *ssl; 592# ifndef OPENSSL_NO_TLSEXT 593 buffer *tlsext_server_name; 594# endif 595 unsigned int renegotiations; /* count of SSL_CB_HANDSHAKE_START */ 596#endif 597 /* etag handling */ 598 etag_flags_t etag_flags; 599 600 int conditional_is_valid[COMP_LAST_ELEMENT]; 601#ifdef HAVE_LIBSMBCLIENT 602 buffer* share_link_basic_auth; 603 buffer* share_link_shortpath; 604 buffer* share_link_realpath; 605 buffer* share_link_filename; 606 int share_link_type; 607 buffer* physical_auth_url; 608 physical url; //- start with smb:// or http:// 609 buffer* url_options; 610 smb_info_t *smb_info; 611 int cur_fd;// samba r/w fd 612 613 buffer *aidisk_username; 614 buffer *aidisk_passwd; 615 616 buffer *match_smb_ip; 617 buffer *replace_smb_name; 618#endif 619 620} connection; 621 622typedef struct { 623 connection **ptr; 624 size_t size; 625 size_t used; 626} connections; 627 628 629#ifdef HAVE_IPV6 630typedef struct { 631 int family; 632 union { 633 struct in6_addr ipv6; 634 struct in_addr ipv4; 635 } addr; 636 char b2[INET6_ADDRSTRLEN + 1]; 637 time_t ts; 638} inet_ntop_cache_type; 639#endif 640 641 642typedef struct { 643 buffer *uri; 644 time_t mtime; 645 int http_status; 646} realpath_cache_type; 647 648typedef struct { 649 time_t mtime; /* the key */ 650 buffer *str; /* a buffer for the string represenation */ 651} mtime_cache_type; 652 653typedef struct { 654 void *ptr; 655 size_t used; 656 size_t size; 657} buffer_plugin; 658 659typedef struct { 660 unsigned short port; 661 buffer *bindhost; 662 663 buffer *errorlog_file; 664 unsigned short errorlog_use_syslog; 665 buffer *breakagelog_file; 666 667 unsigned short dont_daemonize; 668 buffer *changeroot; 669 buffer *username; 670 buffer *groupname; 671 672 buffer *pid_file; 673 674 buffer *event_handler; 675 676 buffer *modules_dir; 677 buffer *network_backend; 678 array *modules; 679 array *upload_tempdirs; 680 unsigned int upload_temp_file_size; 681 682 unsigned short max_worker; 683 unsigned short max_fds; 684 unsigned short max_conns; 685 unsigned int max_request_size; 686 687 unsigned short log_request_header_on_error; 688 unsigned short log_state_handling; 689 690 enum { STAT_CACHE_ENGINE_UNSET, 691 STAT_CACHE_ENGINE_NONE, 692 STAT_CACHE_ENGINE_SIMPLE 693#ifdef HAVE_FAM_H 694 , STAT_CACHE_ENGINE_FAM 695#endif 696 } stat_cache_engine; 697 unsigned short enable_cores; 698 unsigned short reject_expect_100_with_417; 699 700#ifdef HAVE_LIBSMBCLIENT 701 //- Sungmin add 20111018 702 buffer *arpping_interface; 703 buffer *syslog_file; 704 buffer *product_image; 705 buffer *aicloud_version; 706 buffer *smartsync_version; 707 buffer *app_installation_url; 708 unsigned int max_sharelink; 709#endif 710} server_config; 711 712typedef struct server_socket { 713 sock_addr addr; 714 int fd; 715 int fde_ndx; 716 717 unsigned short is_ssl; 718 719 buffer *srv_token; 720 721#ifdef USE_OPENSSL 722 SSL_CTX *ssl_ctx; 723#endif 724} server_socket; 725 726typedef struct { 727 server_socket **ptr; 728 729 size_t size; 730 size_t used; 731} server_socket_array; 732 733typedef struct server { 734 server_socket_array srv_sockets; 735 736 /* the errorlog */ 737 int errorlog_fd; 738 enum { ERRORLOG_FILE, ERRORLOG_FD, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode; 739 buffer *errorlog_buf; 740 741 fdevents *ev, *ev_ins; 742 743 buffer_plugin plugins; 744 void *plugin_slots; 745 746 /* counters */ 747 int con_opened; 748 int con_read; 749 int con_written; 750 int con_closed; 751 752 int ssl_is_init; 753 754 int max_fds; /* max possible fds */ 755 int cur_fds; /* currently used fds */ 756 int want_fds; /* waiting fds */ 757 int sockets_disabled; 758 759 size_t max_conns; 760 761 /* buffers */ 762 buffer *parse_full_path; 763 buffer *response_header; 764 buffer *response_range; 765 buffer *tmp_buf; 766 767 buffer *tmp_chunk_len; 768 769 buffer *empty_string; /* is necessary for cond_match */ 770 771 buffer *cond_check_buf; 772 773 /* caches */ 774#ifdef HAVE_IPV6 775 inet_ntop_cache_type inet_ntop_cache[INET_NTOP_CACHE_MAX]; 776#endif 777 mtime_cache_type mtime_cache[FILE_CACHE_MAX]; 778 779 array *split_vals; 780 781 /* Timestamps */ 782 time_t cur_ts; 783 time_t last_generated_date_ts; 784 time_t last_generated_debug_ts; 785 time_t startup_ts; 786 787 char entropy[8]; /* from /dev/[u]random if possible, otherwise rand() */ 788 char is_real_entropy; /* whether entropy is from /dev/[u]random */ 789 790 buffer *ts_debug_str; 791 buffer *ts_date_str; 792 793 /* config-file */ 794 array *config; 795 array *config_touched; 796 797 array *config_context; 798 specific_config **config_storage; 799 800 server_config srvconf; 801 802 short int config_deprecated; 803 short int config_unsupported; 804 805 connections *conns; 806 connections *joblist; 807 connections *fdwaitqueue; 808 809 stat_cache *stat_cache; 810 811 /** 812 * The status array can carry all the status information you want 813 * the key to the array is <module-prefix>.<name> 814 * and the values are counters 815 * 816 * example: 817 * fastcgi.backends = 10 818 * fastcgi.active-backends = 6 819 * fastcgi.backend.<key>.load = 24 820 * fastcgi.backend.<key>.... 821 * 822 * fastcgi.backend.<key>.disconnects = ... 823 */ 824 array *status; 825 826 fdevent_handler_t event_handler; 827 828 int (* network_backend_write)(struct server *srv, connection *con, int fd, chunkqueue *cq, off_t max_bytes); 829#ifdef USE_OPENSSL 830 int (* network_ssl_backend_write)(struct server *srv, connection *con, SSL *ssl, chunkqueue *cq, off_t max_bytes); 831#endif 832 833 uid_t uid; 834 gid_t gid; 835 836//- Sungmin add 837#ifdef HAVE_LIBSMBCLIENT 838 smb_info_t *smb_srv_info_list; 839 int syslog_fd; 840 buffer *syslog_buf; 841 buffer *cur_login_info; 842 buffer *last_login_info; 843 time_t last_no_ssl_connection_ts; 844 int is_streaming_port_opend; 845#endif 846 847} server; 848 849//- Sungmin add 850#ifdef HAVE_LIBSMBCLIENT 851typedef struct smb_srv_info_s { 852 int id; 853 buffer *ip; 854 buffer *mac; 855 buffer *name; 856 int online; 857 struct smb_srv_info_s *prev, *next; 858}smb_srv_info_t; 859smb_srv_info_t *smb_srv_info_list; 860 861typedef struct share_link_info_s { 862 buffer *shortpath; 863 buffer *realpath; 864 buffer *filename; 865 buffer *auth; 866 unsigned long createtime; 867 unsigned long expiretime; 868 int toshare; 869 struct share_link_info_s *prev, *next; 870}share_link_info_t; 871share_link_info_t *share_link_info_list; 872 873typedef struct aicloud_acc_info_s { 874 buffer *username; 875 buffer *password; 876 struct aicloud_acc_info_s *prev, *next; 877}aicloud_acc_info_t; 878aicloud_acc_info_t *aicloud_acc_info_list; 879 880typedef struct aicloud_acc_invite_info_s { 881 buffer *productid; 882 buffer *deviceid; 883 buffer *token; 884 buffer *permission; 885 unsigned long bytes_in_avail; 886 int smart_access; 887 buffer *security_code; 888 int status; 889 int auth_type; 890 unsigned long createtime; 891 struct aicloud_acc_invite_info_s *prev, *next; 892}aicloud_acc_invite_info_t; 893aicloud_acc_invite_info_t *aicloud_acc_invite_info_list; 894 895typedef enum { 896 T_ACCOUNT_SAMBA, 897 T_ACCOUNT_AICLOUD 898} account_type; 899 900typedef enum { 901 T_ADMIN, 902 T_USER 903} account_permission_type; 904#endif 905 906#endif 907