1 #ifndef __ISDS_SERVER_H
2 #define __ISDS_SERVER_H
4 extern const char *server_error
;
6 /* Save pointer to static error message if not yet set */
7 void set_server_error(const char *message
);
10 /* Creates listening TCP socket on localhost.
11 * Returns the socket descriptor or -1. */
12 int listen_on_socket(void);
15 /* Format socket address as printable string.
16 * @return allocated string or NULL in case of error. */
17 char *socket2address(int socket
);
20 struct arguments_basic_authentication
{
21 const char *username
; /* Sets required user name server has to require.
22 Set NULL to disable HTTP authentication. */
23 const char *password
; /* sets required password server has to require */
24 _Bool isds_deviations
; /* is flag to set conformance level. If false,
25 server is compliant to standards (HTTP, SOAP)
26 if not conflicts with ISDS specification.
27 Otherwise server mimics real ISDS implementation
28 as much as possible. */
31 /* Do the server protocol.
32 * @server_socket is listening TCP socket of the server
33 * @server_arguments is pointer to structure:
34 * Never returns. Terminates by exit(). */
35 void server_basic_authentication(int server_socket
,
36 const void *server_arguments
);
39 /* One-time password authentication method */
40 enum auth_otp_method
{
41 AUTH_OTP_HMAC
= 0, /* HMAC-based OTP */
42 AUTH_OTP_TIME
/* Time-based OTP */
45 struct arguments_otp_authentication
{
46 enum auth_otp_method method
; /* Selects OTP method to enable */
47 const char *username
; /* Sets required user name server has to require.
48 Set NULL to disable HTTP authentication. */
49 const char *password
; /* Sets password server has to require */
50 const char *otp
; /* Sets OTP code server has to requiere */
51 _Bool isds_deviations
; /* Is flag to set conformance level. If false,
52 server is compliant to standards (HTTP, SOAP)
53 if not conflicts with ISDS specification.
54 Otherwise server mimics real ISDS implementation
55 as much as possible. */
58 /* Do the server protocol with OTP authentication.
59 * @server_socket is listening TCP socket of the server
60 * @server_arguments is pointer to structure arguments_otp_authentication. It
61 * selects OTP method to enable.
62 * Never returns. Terminates by exit(). */
63 void server_otp_authentication(int server_socket
,
64 const void *server_arguments
);
66 /* Implementation of server that is out of order.
67 * It always sends back SOAP Fault with HTTP error 503.
68 * @server_socket is listening TCP socket of the server
69 * @server_arguments is ununsed pointer
70 * Never returns. Terminates by exit(). */
71 void server_out_of_order(int server_socket
,
72 const void *server_arguments
);
75 /* Start sever in separate process.
76 * @server_process is PID of forked server
77 * @server_address is automatically allocated TCP address of listening server
78 * @username sets required user name server has to require. Set NULL to
79 * disable HTTP authentication.
80 * @password sets required password server has to require
82 * @isds_deviations is flag to set conformance level. If false, server is
83 * compliant to standards (HTTP, SOAP) if not conflicts with ISDS
84 * specification. Otherwise server mimics real ISDS implementation as much
86 * @return -1 in case of error. */
87 int start_server(pid_t
*server_process
, char **server_address
,
88 void (*server_implementation
)(int, const void *),
89 const void *server_arguments
);
92 /* Kill the server process.
93 * Return -1 in case of error. */
94 int stop_server(pid_t server_process
);