Path: blob/main/crypto/krb5/src/include/net-server.h
34879 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/* include/net-server.h */2/*3* Copyright (C) 2010 by the Massachusetts Institute of Technology.4* All rights reserved.5*6* Export of this software from the United States of America may7* require a specific license from the United States Government.8* It is the responsibility of any person or organization contemplating9* export to obtain such a license before exporting.10*11* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and12* distribute this software and its documentation for any purpose and13* without fee is hereby granted, provided that the above copyright14* notice appear in all copies and that both that copyright notice and15* this permission notice appear in supporting documentation, and that16* the name of M.I.T. not be used in advertising or publicity pertaining17* to distribution of the software without specific, written prior18* permission. Furthermore if you modify this software you must label19* your software as modified software and not distribute it in such a20* fashion that it might be confused with the original M.I.T. software.21* M.I.T. makes no representations about the suitability of22* this software for any purpose. It is provided "as is" without express23* or implied warranty.24*/2526/* Declarations for "API" of network listener/dispatcher in libapputils. */2728#ifndef NET_SERVER_H29#define NET_SERVER_H3031#include <verto.h>32#include <gssrpc/rpc.h>3334/* The delimiter characters supported by the addresses string. */35#define ADDRESSES_DELIM ",; "3637/* exported from net-server.c */38verto_ctx *loop_init(verto_ev_type types);3940/*41* Add listener addresses to the loop configuration.42*43* Arguments:44*45* - default_port46* The port for the sockets if not specified in addresses.47* - addresses48* The optional addresses for the listener sockets. Pass NULL for the49* wildcard address. Addresses may be delimited by the characters in50* ADDRESSES_DELIM. Addresses are parsed with k5_parse_host_string().51* - prognum, versnum, dispatchfn52* For RPC listener sockets, the svc_register() arguments to use when new53* TCP connections are created.54*/55krb5_error_code loop_add_udp_address(int default_port, const char *addresses);56krb5_error_code loop_add_tcp_address(int default_port, const char *addresses);57krb5_error_code loop_add_rpc_service(int default_port, const char *addresses,58u_long prognum, u_long versnum,59void (*dispatchfn)(struct svc_req *,60SVCXPRT *));61krb5_error_code loop_add_unix_socket(const char *socket_paths);6263krb5_error_code loop_setup_network(verto_ctx *ctx, void *handle,64const char *progname,65int tcp_listen_backlog);66krb5_error_code loop_setup_signals(verto_ctx *ctx, void *handle,67void (*reset)(void *));68void loop_free(verto_ctx *ctx);6970/* to be supplied by the server application */7172/*73* Two routines for processing an incoming message and getting a74* result to send back.75*76* The first, dispatch(), is for normal processing of a request. The77* second, make_toolong_error(), is obviously for generating an error78* to send back when the incoming message is bigger than79* the main loop can accept.80*/81typedef void (*loop_respond_fn)(void *arg, krb5_error_code code,82krb5_data *response);83void dispatch(void *handle, const struct sockaddr *local_addr,84const struct sockaddr *remote_addr, krb5_data *request,85int is_tcp, verto_ctx *vctx, loop_respond_fn respond, void *arg);86krb5_error_code make_toolong_error (void *handle, krb5_data **);8788/*89* Contexts are needed in lots of places. Opaque application-provided90* handles are passed around in lots of place, but contexts are not.91* For now, we'll require that the application provide us an easy way92* to get at a context; eventually it should probably be explicitly.93*/94krb5_context get_context(void *handle);9596#endif /* NET_SERVER_H */979899