Skip to content

Commit 3e6d113

Browse files
committed
fix: enhance documentation in control.h for clarity and structure
Signed-off-by: Dengfeng Liu <[email protected]>
1 parent 0a080b4 commit 3e6d113

File tree

1 file changed

+47
-54
lines changed

1 file changed

+47
-54
lines changed

control.h

Lines changed: 47 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,74 @@
44
* modify it under the terms of the GNU General Public License as *
55
* published by the Free Software Foundation; either version 2 of *
66
* the License, or (at your option) any later version. *
7-
* *
8-
* This program is distributed in the hope that it will be useful, *
9-
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
10-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11-
* GNU General Public License for more details. *
12-
* *
13-
* You should have received a copy of the GNU General Public License*
14-
* along with this program; if not, contact: *
15-
* *
16-
* Free Software Foundation Voice: +1-617-542-5942 *
17-
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
18-
* Boston, MA 02111-1307, USA [email protected] *
19-
* *
207
\********************************************************************/
218

22-
/** @file control.h
23-
@brief control related
24-
@author Copyright (C) 2016 Dengfeng Liu <[email protected]>
25-
*/
9+
/**
10+
* @file control.h
11+
* @brief Main control interface for FRP (Fast Reverse Proxy) client
12+
* @author Dengfeng Liu <[email protected]>
13+
* @copyright Copyright (C) 2016 Dengfeng Liu
14+
*
15+
* This file contains the core control structures and functions
16+
* for managing FRP client connections and communications.
17+
*/
2618

27-
#ifndef _CONTROL_H_
28-
#define _CONTROL_H_
19+
#ifndef CONTROL_H_
20+
#define CONTROL_H_
2921

30-
#include "uthash.h"
3122
#include "msg.h"
23+
#include "uthash.h"
3224

33-
struct proxy_client;
34-
struct bufferevent;
35-
struct event_base;
36-
enum msg_type;
37-
25+
/**
26+
* @brief Main control structure for FRP client
27+
*/
3828
struct control {
39-
struct event_base *connect_base; //main netevent
40-
struct evdns_base *dnsbase;
41-
struct bufferevent *connect_bev; //main io evet buf
42-
struct event *ticker_ping; //heartbeat timer
43-
44-
struct event *tcp_mux_ping_event;
45-
uint32_t tcp_mux_ping_id;
46-
struct tmux_stream stream;
29+
struct event_base *connect_base; /* Main event base */
30+
struct evdns_base *dnsbase; /* DNS resolver base */
31+
struct bufferevent *connect_bev; /* Main I/O event buffer */
32+
struct event *ticker_ping; /* Heartbeat timer */
33+
struct event *tcp_mux_ping_event; /* TCP multiplexing ping event */
34+
uint32_t tcp_mux_ping_id; /* TCP multiplexing ping ID */
35+
struct tmux_stream stream; /* Multiplexing stream */
4736
};
4837

49-
void connect_eventcb(struct bufferevent *bev, short events, void *ptr);
50-
51-
void init_main_control();
38+
/* Control lifecycle functions */
39+
void init_main_control(void);
40+
void run_control(void);
41+
struct control *get_main_control(void);
42+
void close_main_control(void);
5243

53-
void run_control();
54-
55-
struct control *get_main_control();
56-
57-
void close_main_control();
44+
/* Server connection functions */
45+
struct bufferevent *connect_server(struct event_base *base, const char *name,
46+
const int port);
47+
struct bufferevent *connect_udp_server(struct event_base *base);
48+
void connect_eventcb(struct bufferevent *bev, short events, void *ptr);
5849

50+
/* Server communication functions */
5951
void start_login_frp_server(struct event_base *base);
60-
6152
void send_login_frp_server(struct bufferevent *bev);
53+
void login(void);
54+
void send_new_proxy(struct proxy_service *ps);
6255

63-
void login();
56+
/* Message handling functions */
57+
void send_msg_frp_server(struct bufferevent *bev, const enum msg_type type,
58+
const char *msg, const size_t msg_len,
59+
struct tmux_stream *stream);
6460

65-
void send_msg_frp_server(struct bufferevent *bev,
66-
const enum msg_type type,
67-
const char *msg,
68-
const size_t msg_len,
69-
struct tmux_stream *stream);
61+
void send_msg_frp_server(struct bufferevent *bev, const enum msg_type type,
62+
const char *msg, const size_t msg_len,
63+
struct tmux_stream *stream);
7064

71-
void send_enc_msg_frp_server(struct bufferevent *bev,
72-
const enum msg_type type,
73-
const char *msg,
74-
const size_t msg_len,
75-
struct tmux_stream *stream);
65+
void send_enc_msg_frp_server(struct bufferevent *bev, const enum msg_type type,
66+
const char *msg, const size_t msg_len,
67+
struct tmux_stream *stream);
7668

7769
void control_process(struct proxy_client *client);
7870

7971
void send_new_proxy(struct proxy_service *ps);
8072

81-
struct bufferevent *connect_server(struct event_base *base, const char *name, const int port);
73+
struct bufferevent *connect_server(struct event_base *base, const char *name,
74+
const int port);
8275

8376
struct bufferevent *connect_udp_server(struct event_base *base);
8477

0 commit comments

Comments
 (0)