如何解决struct lws_context在哪里定义?
我是libwebsocket的新手,我有要分析的代码。我找不到在哪里定义struct lws_context。 谁能帮助我。
解决方法
如果您在 /usr/include 文件夹中搜索 lws_context 的定义,您将找不到它(我还对他们的公共 doxygen 进行了快速搜索,但也没有在那里找到定义...)。但是你可以在他们的 git repo 中找到它的定义(他们网站上的链接:https://libwebsockets.org/)。它位于以下文件中:lib/core/private-lib-core.h。值得一提的是,这显然在未来可能会发生变化。为了快速参考,这里是您正在寻找的定义:
struct lws_context {
#if defined(LWS_WITH_SERVER)
char canonical_hostname[96];
#endif
#if defined(LWS_WITH_FILE_OPS)
struct lws_plat_file_ops fops_platform;
#endif
#if defined(LWS_WITH_ZIP_FOPS)
struct lws_plat_file_ops fops_zip;
#endif
lws_system_blob_t system_blobs[LWS_SYSBLOB_TYPE_COUNT];
#if defined(LWS_WITH_SYS_SMD)
lws_smd_t smd;
#endif
#if defined(LWS_WITH_SECURE_STREAMS)
struct lws_ss_handle *ss_cpd;
#endif
lws_sorted_usec_list_t sul_cpd_defer;
#if defined(LWS_WITH_NETWORK)
struct lws_context_per_thread pt[LWS_MAX_SMP];
lws_retry_bo_t default_retry;
lws_sorted_usec_list_t sul_system_state;
lws_lifecycle_group_t lcg[LWSLCG_COUNT];
#if defined(LWS_WITH_NETLINK)
lws_sorted_usec_list_t sul_nl_coldplug;
#endif
#if defined(LWS_PLAT_FREERTOS) || defined(WIN32)
struct sockaddr_in frt_pipe_si;
#endif
#if defined(LWS_WITH_HTTP2)
struct http2_settings set;
#endif
#if LWS_MAX_SMP > 1
struct lws_mutex_refcount mr;
#endif
#if defined(LWS_WITH_SYS_METRICS)
lws_dll2_owner_t owner_mtr_dynpol;
/**< owner for lws_metric_policy_dyn_t (dynamic part of metric pols) */
lws_dll2_owner_t owner_mtr_no_pol;
/**< owner for lws_metric_pub_t with no policy to bind to */
#endif
#if defined(LWS_WITH_NETWORK)
/*
* LWS_WITH_NETWORK =====>
*/
lws_dll2_owner_t owner_vh_being_destroyed;
lws_metric_t *mt_service; /* doing service */
const lws_metric_policy_t *metrics_policies;
const char *metrics_prefix;
#if defined(LWS_WITH_SYS_METRICS) && defined(LWS_WITH_CLIENT)
lws_metric_t *mt_conn_tcp; /* client tcp conns */
lws_metric_t *mt_conn_tls; /* client tcp conns */
lws_metric_t *mt_conn_dns; /* client dns external lookups */
lws_metric_t *mth_conn_failures; /* histogram of conn failure reasons */
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
lws_metric_t *mt_http_txn; /* client http transaction */
#endif
#if defined(LWS_WITH_SYS_ASYNC_DNS)
lws_metric_t *mt_adns_cache; /* async dns lookup lat */
#endif
#if defined(LWS_WITH_SECURE_STREAMS)
lws_metric_t *mt_ss_conn; /* SS connection latency */
#endif
#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
lws_metric_t *mt_ss_cliprox_conn; /* SS cli->prox conn */
lws_metric_t *mt_ss_cliprox_paylat; /* cli->prox payload latency */
lws_metric_t *mt_ss_proxcli_paylat; /* prox->cli payload latency */
#endif
#endif /* client */
#if defined(LWS_WITH_SERVER)
lws_metric_t *mth_srv;
#endif
#if defined(LWS_WITH_EVENT_LIBS)
struct lws_plugin *evlib_plugin_list;
void *evlib_ctx; /* overallocated */
#endif
#if defined(LWS_WITH_TLS)
struct lws_context_tls tls;
#endif
#if defined(LWS_WITH_DRIVERS)
lws_netdevs_t netdevs;
#endif
#if defined(LWS_WITH_SYS_ASYNC_DNS)
lws_async_dns_t async_dns;
#endif
#if defined(LWS_WITH_SYS_NTPCLIENT)
void *ntpclient_priv;
#endif
#if defined(LWS_WITH_SECURE_STREAMS)
struct lws_ss_handle *hss_fetch_policy;
#if defined(LWS_WITH_SECURE_STREAMS_SYS_AUTH_API_AMAZON_COM)
struct lws_ss_handle *hss_auth;
lws_sorted_usec_list_t sul_api_amazon_com;
lws_sorted_usec_list_t sul_api_amazon_com_kick;
#endif
#if !defined(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY)
struct lws_ss_x509 *server_der_list;
#endif
#endif
#if defined(LWS_WITH_SYS_STATE)
lws_state_manager_t mgr_system;
lws_state_notify_link_t protocols_notify;
#endif
#if defined (LWS_WITH_SYS_DHCP_CLIENT)
lws_dll2_owner_t dhcpc_owner;
/**< list of ifaces with dhcpc */
#endif
/* pointers */
struct lws_vhost *vhost_list;
struct lws_vhost *no_listener_vhost_list;
struct lws_vhost *vhost_pending_destruction_list;
struct lws_vhost *vhost_system;
#if defined(LWS_WITH_SERVER)
const char *server_string;
#endif
const struct lws_event_loop_ops *event_loop_ops;
#endif
#if defined(LWS_WITH_TLS)
const struct lws_tls_ops *tls_ops;
#endif
#if defined(LWS_WITH_PLUGINS)
struct lws_plugin *plugin_list;
#endif
#ifdef _WIN32
/* different implementation between unix and windows */
struct lws_fd_hashtable fd_hashtable[FD_HASHTABLE_MODULUS];
#else
struct lws **lws_lookup;
#endif
/*
* <====== LWS_WITH_NETWORK end
*/
#endif /* NETWORK */
#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
const char *ss_proxy_bind;
const char *ss_proxy_address;
#endif
#if defined(LWS_WITH_FILE_OPS)
const struct lws_plat_file_ops *fops;
#endif
struct lws_context **pcontext_finalize;
#if !defined(LWS_PLAT_FREERTOS)
const char *username,*groupname;
#endif
#if defined(LWS_AMAZON_RTOS) && defined(LWS_WITH_MBEDTLS)
mbedtls_entropy_context mec;
mbedtls_ctr_drbg_context mcdc;
#endif
#if defined(LWS_WITH_THREADPOOL)
struct lws_threadpool *tp_list_head;
#endif
#if defined(LWS_WITH_PEER_LIMITS)
struct lws_peer **pl_hash_table;
struct lws_peer *peer_wait_list;
lws_peer_limits_notify_t pl_notify_cb;
time_t next_cull;
#endif
const lws_system_ops_t *system_ops;
#if defined(LWS_WITH_SECURE_STREAMS)
#if !defined(LWS_WITH_SECURE_STREAMS_STATIC_POLICY_ONLY)
const char *pss_policies_json;
struct lwsac *ac_policy;
void *pol_args;
#endif
const lws_ss_policy_t *pss_policies;
const lws_ss_auth_t *pss_auths;
#if defined(LWS_WITH_SSPLUGINS)
const lws_ss_plugin_t **pss_plugins;
#endif
#endif
void *external_baggage_free_on_destroy;
const struct lws_token_limits *token_limits;
void *user_space;
#if defined(LWS_WITH_SERVER)
const struct lws_protocol_vhost_options *reject_service_keywords;
lws_reload_func deprecation_cb;
#endif
#if !defined(LWS_PLAT_FREERTOS)
void (*eventlib_signal_cb)(void *event_lib_handle,int signum);
#endif
#if defined(LWS_HAVE_SYS_CAPABILITY_H) && defined(LWS_HAVE_LIBCAP)
cap_value_t caps[4];
char count_caps;
#endif
lws_usec_t time_up; /* monotonic */
uint64_t options;
time_t last_ws_ping_pong_check_s;
#if defined(LWS_WITH_SECURE_STREAMS)
time_t last_policy;
#endif
#if defined(LWS_PLAT_FREERTOS)
unsigned long time_last_state_dump;
uint32_t last_free_heap;
#endif
unsigned int max_fds;
#if !defined(LWS_NO_DAEMONIZE)
pid_t started_with_parent;
#endif
#if !defined(LWS_PLAT_FREERTOS)
uid_t uid;
gid_t gid;
int fd_random;
int count_cgi_spawned;
#endif
unsigned int fd_limit_per_thread;
unsigned int timeout_secs;
unsigned int pt_serv_buf_size;
unsigned int max_http_header_data;
unsigned int max_http_header_pool;
int simultaneous_ssl_restriction;
int simultaneous_ssl;
#if defined(LWS_WITH_PEER_LIMITS)
uint32_t pl_hash_elements; /* protected by context->lock */
uint32_t count_peers; /* protected by context->lock */
unsigned short ip_limit_ah;
unsigned short ip_limit_wsi;
#endif
unsigned int deprecated:1;
unsigned int inside_context_destroy:1;
unsigned int being_destroyed:1;
unsigned int service_no_longer_possible:1;
unsigned int being_destroyed2:1;
unsigned int requested_stop_internal_loops:1;
unsigned int protocol_init_done:1;
unsigned int doing_protocol_init:1;
unsigned int done_protocol_destroy_cb:1;
unsigned int evlib_finalize_destroy_after_int_loops_stop:1;
unsigned int max_fds_unrelated_to_ulimit:1;
unsigned int policy_updated:1;
#if defined(LWS_WITH_NETLINK)
unsigned int nl_initial_done:1;
#endif
unsigned short count_threads;
unsigned short undestroyed_threads;
short plugin_protocol_count;
short plugin_extension_count;
short server_string_len;
unsigned short deprecation_pending_listen_close_count;
#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
uint16_t ss_proxy_port;
#endif
/* 0 if not known,else us resolution of the poll wait */
uint16_t us_wait_resolution;
uint8_t max_fi;
uint8_t udp_loss_sim_tx_pc;
uint8_t udp_loss_sim_rx_pc;
uint8_t captive_portal_detect;
uint8_t captive_portal_detect_type;
uint8_t destroy_state; /* enum lws_context_destroy */
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。