📄 connection.h
字号:
/*
Portserver - Use RTERM protocol to serve serial ports over a network
Copyright (C) 1998 Kenn Humborg
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef CONNECTION_H
#define CONNECTION_H
#include "buffer.h"
#include "port.h"
#define SOCKET_BUFFER_SIZE 512
#define COMMAND_BUFFER_CHUNK_SIZE 128
#define RESPONSE_BUFFER_CHUNK_SIZE 128
struct Connection {
struct Connection *next;
struct Connection *prev;
int fd;
struct Port *port;
int flags;
char *command_buf;
int command_buf_size;
int command_len;
char *response_buf;
int response_buf_size;
int response_len;
struct Buffer *write_buffer;
struct Buffer *read_buffer;
char *remote_host;
char *remote_user;
};
/* Bits in Connection.flags */
#define CONNECTION_COMMAND_MODE 1 /* Currently reading a command */
#define CONNECTION_GOT_COMMAND_START 2 /* Got a COMMAND_START char */
#define CONNECTION_CLOSING 4 /* Got a 'close' command */
void NewConnection(void);
void AddConnection(struct Connection *connection);
void RemoveConnection(struct Connection *connection);
void DeleteConnection(struct Connection *connection);
int SocketDataReceived(struct Connection *connection);
STATUS AssignPort(struct Connection *connection, struct Port *port);
void DeassignPort(struct Connection *connection);
void SocketReady(struct Connection *connection);
int SocketSendData(struct Connection *connection, char *data, int data_len);
void HandleSocketData(struct Connection *connection);
void SendResponse(struct Connection *connection, char *response);
extern struct Connection connection_list;
#endif /* CONNECTION_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -