Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/include/net-server.h
34879 views
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
#include <gssrpc/rpc.h>
34
35
/* The delimiter characters supported by the addresses string. */
36
#define ADDRESSES_DELIM ",; "
37
38
/* exported from net-server.c */
39
verto_ctx *loop_init(verto_ev_type types);
40
41
/*
42
* Add listener addresses to the loop configuration.
43
*
44
* Arguments:
45
*
46
* - default_port
47
* The port for the sockets if not specified in addresses.
48
* - addresses
49
* The optional addresses for the listener sockets. Pass NULL for the
50
* wildcard address. Addresses may be delimited by the characters in
51
* ADDRESSES_DELIM. Addresses are parsed with k5_parse_host_string().
52
* - prognum, versnum, dispatchfn
53
* For RPC listener sockets, the svc_register() arguments to use when new
54
* TCP connections are created.
55
*/
56
krb5_error_code loop_add_udp_address(int default_port, const char *addresses);
57
krb5_error_code loop_add_tcp_address(int default_port, const char *addresses);
58
krb5_error_code loop_add_rpc_service(int default_port, const char *addresses,
59
u_long prognum, u_long versnum,
60
void (*dispatchfn)(struct svc_req *,
61
SVCXPRT *));
62
krb5_error_code loop_add_unix_socket(const char *socket_paths);
63
64
krb5_error_code loop_setup_network(verto_ctx *ctx, void *handle,
65
const char *progname,
66
int tcp_listen_backlog);
67
krb5_error_code loop_setup_signals(verto_ctx *ctx, void *handle,
68
void (*reset)(void *));
69
void loop_free(verto_ctx *ctx);
70
71
/* to be supplied by the server application */
72
73
/*
74
* Two routines for processing an incoming message and getting a
75
* result to send back.
76
*
77
* The first, dispatch(), is for normal processing of a request. The
78
* second, make_toolong_error(), is obviously for generating an error
79
* to send back when the incoming message is bigger than
80
* the main loop can accept.
81
*/
82
typedef void (*loop_respond_fn)(void *arg, krb5_error_code code,
83
krb5_data *response);
84
void dispatch(void *handle, const struct sockaddr *local_addr,
85
const struct sockaddr *remote_addr, krb5_data *request,
86
int is_tcp, verto_ctx *vctx, loop_respond_fn respond, void *arg);
87
krb5_error_code make_toolong_error (void *handle, krb5_data **);
88
89
/*
90
* Contexts are needed in lots of places. Opaque application-provided
91
* handles are passed around in lots of place, but contexts are not.
92
* For now, we'll require that the application provide us an easy way
93
* to get at a context; eventually it should probably be explicitly.
94
*/
95
krb5_context get_context(void *handle);
96
97
#endif /* NET_SERVER_H */
98
99