server: specify port as a string
[openocd.git] / src / server / server.h
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * Copyright (C) 2008 by Spencer Oliver *
9 * spen@spen-soft.co.uk *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 ***************************************************************************/
26 #ifndef SERVER_H
27 #define SERVER_H
28
29 #include <helper/log.h>
30
31 #ifdef HAVE_NETINET_IN_H
32 #include <netinet/in.h>
33 #endif
34
35 enum connection_type
36 {
37 CONNECTION_TCP,
38 CONNECTION_PIPE
39 };
40
41 struct connection
42 {
43 int fd;
44 int fd_out; /* When using pipes we're writing to a different fd */
45 struct sockaddr_in sin;
46 struct command_context *cmd_ctx;
47 struct service *service;
48 int input_pending;
49 void *priv;
50 struct connection *next;
51 };
52
53 typedef int (*new_connection_handler_t)(struct connection *connection);
54 typedef int (*input_handler_t)(struct connection *connection);
55 typedef int (*connection_closed_handler_t)(struct connection *connection);
56
57 struct service
58 {
59 char *name;
60 enum connection_type type;
61 unsigned short port;
62 int fd;
63 struct sockaddr_in sin;
64 int max_connections;
65 struct connection *connections;
66 new_connection_handler_t new_connection;
67 input_handler_t input;
68 connection_closed_handler_t connection_closed;
69 void *priv;
70 struct service *next;
71 };
72
73 int add_service(char *name, enum connection_type type, unsigned short port,
74 int max_connections, new_connection_handler_t new_connection_handler,
75 input_handler_t in_handler, connection_closed_handler_t close_handler,
76 void *priv);
77
78 int add_service_pipe(char *name, const char *port,
79 int max_connections, new_connection_handler_t new_connection_handler,
80 input_handler_t in_handler, connection_closed_handler_t close_handler,
81 void *priv);
82
83 int server_preinit(void);
84 int server_init(struct command_context *cmd_ctx);
85 int server_quit(void);
86
87 int server_loop(struct command_context *command_context);
88
89 int server_register_commands(struct command_context *context);
90
91 int connection_write(struct connection *connection, const void *data, int len);
92 int connection_read(struct connection *connection, void *data, int len);
93
94 /**
95 * Used by server_loop(), defined in server_stubs.c, httpd.c, or ecosboard.c
96 */
97 void openocd_sleep_prelude(void);
98 /**
99 * Used by server_loop(), defined in server_stubs.c, httpd.c, or ecosboard.c
100 */
101 void openocd_sleep_postlude(void);
102
103 /**
104 * Defines an extended command handler function declaration to enable
105 * access to (and manipulation of) the server port number.
106 * Call server_port like a normal COMMAND_HANDLER with an extra @a out parameter
107 * to receive the specified port number.
108 */
109 #define SERVER_PIPE_COMMAND() \
110 COMMAND_HELPER(server_pipe_command, const char **out)
111 SERVER_PIPE_COMMAND();
112
113 #define SERVER_PORT_COMMAND() \
114 COMMAND_HELPER(server_port_command, unsigned short *out)
115
116 SERVER_PORT_COMMAND();
117
118 extern int server_use_pipes;
119
120 #define ERROR_SERVER_REMOTE_CLOSED (-400)
121 #define ERROR_CONNECTION_REJECTED (-401)
122
123 #endif /* SERVER_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)