]> git.sur5r.net Git - openocd/blob - src/server/server.h
- adds two speeds to jtag_speed. reset and post reset speed. Default
[openocd] / src / server / server.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Dominic Rath                                    *
3  *   Dominic.Rath@gmx.de                                                   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 #ifndef SERVER_H
21 #define SERVER_H
22
23 #include "command.h"
24 #include "binarybuffer.h"
25 #include "replacements.h"
26
27 #include <sys/types.h>
28
29 enum connection_type
30 {
31         CONNECTION_GDB,
32         CONNECTION_TELNET,
33 };
34
35 typedef struct connection_s
36 {
37         int fd;
38         struct sockaddr_in sin;
39         command_context_t *cmd_ctx;
40         struct service_s *service;
41         int input_pending;
42         void *priv;
43         struct connection_s *next;
44 } connection_t;
45
46 typedef int (*new_connection_handler_t)(connection_t *connection);
47 typedef int (*input_handler_t)(connection_t *connection);
48 typedef int (*connection_closed_handler_t)(connection_t *connection);
49
50 typedef struct service_s
51 {
52         char *name;
53         enum connection_type type;
54         unsigned short port;
55         int fd;
56         struct sockaddr_in sin;
57         int max_connections;
58         connection_t *connections;
59         new_connection_handler_t new_connection;
60         input_handler_t input;
61         connection_closed_handler_t connection_closed;
62         void *priv;
63         struct service_s *next;
64 } service_t;
65
66 extern int add_service(char *name, enum connection_type type, unsigned short port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv);
67 extern int server_init();
68 extern int server_quit();
69 extern int server_loop(command_context_t *command_context);
70 extern int server_register_commands(command_context_t *context);
71
72 #define ERROR_SERVER_REMOTE_CLOSED      (-400)
73 #define ERROR_CONNECTION_REJECTED       (-401)
74
75 #endif /* SERVER_H */