Convert DEBUG_REFERRALS to TRACE_* framework
[krb5.git] / src / include / net-server.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* include/net-server.h */
3 /*
4  * Copyright (C) 2010 by the Massachusetts Institute of Technology.
5  * All rights reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26
27 /* Declarations for "API" of network listener/dispatcher in libapputils. */
28
29 #ifndef NET_SERVER_H
30 #define NET_SERVER_H
31
32 #include <verto.h>
33
34 typedef struct _krb5_fulladdr {
35     krb5_address *      address;
36     krb5_ui_4           port;
37 } krb5_fulladdr;
38
39 /* exported from network.c */
40 void init_addr(krb5_fulladdr *, struct sockaddr *);
41
42 /* exported from net-server.c */
43 verto_ctx *loop_init(verto_ev_type types);
44 krb5_error_code loop_add_udp_port(int port);
45 krb5_error_code loop_add_tcp_port(int port);
46 krb5_error_code loop_add_rpc_service(int port, u_long prognum, u_long versnum,
47                                      void (*dispatch)());
48 krb5_error_code loop_setup_routing_socket(verto_ctx *ctx, void *handle,
49                                           const char *progname);
50 krb5_error_code loop_setup_network(verto_ctx *ctx, void *handle,
51                                    const char *progname);
52 krb5_error_code loop_setup_signals(verto_ctx *ctx, void *handle,
53                                    void (*reset)());
54 void loop_free(verto_ctx *ctx);
55
56 /* to be supplied by the server application */
57
58 /*
59  * Two routines for processing an incoming message and getting a
60  * result to send back.
61  *
62  * The first, dispatch(), is for normal processing of a request.  The
63  * second, make_toolong_error(), is obviously for generating an error
64  * to send back when the incoming message is bigger than
65  * the main loop can accept.
66  */
67 typedef void (*loop_respond_fn)(void *arg, krb5_error_code code,
68                                 krb5_data *response);
69 void dispatch(void *handle, struct sockaddr *local_addr,
70               const krb5_fulladdr *remote_addr, krb5_data *request,
71               int is_tcp, verto_ctx *vctx, loop_respond_fn respond, void *arg);
72 krb5_error_code make_toolong_error (void *handle, krb5_data **);
73
74 /*
75  * Contexts are needed in lots of places.  Opaque application-provided
76  * handles are passed around in lots of place, but contexts are not.
77  * For now, we'll require that the application provide us an easy way
78  * to get at a context; eventually it should probably be explicity.
79  */
80 krb5_context get_context(void *handle);
81
82 #endif /* NET_SERVER_H */