|
Packit |
fd8b60 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
Packit |
fd8b60 |
/* include/net-server.h */
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Copyright (C) 2010 by the Massachusetts Institute of Technology.
|
|
Packit |
fd8b60 |
* All rights reserved.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Export of this software from the United States of America may
|
|
Packit |
fd8b60 |
* require a specific license from the United States Government.
|
|
Packit |
fd8b60 |
* It is the responsibility of any person or organization contemplating
|
|
Packit |
fd8b60 |
* export to obtain such a license before exporting.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
|
|
Packit |
fd8b60 |
* distribute this software and its documentation for any purpose and
|
|
Packit |
fd8b60 |
* without fee is hereby granted, provided that the above copyright
|
|
Packit |
fd8b60 |
* notice appear in all copies and that both that copyright notice and
|
|
Packit |
fd8b60 |
* this permission notice appear in supporting documentation, and that
|
|
Packit |
fd8b60 |
* the name of M.I.T. not be used in advertising or publicity pertaining
|
|
Packit |
fd8b60 |
* to distribution of the software without specific, written prior
|
|
Packit |
fd8b60 |
* permission. Furthermore if you modify this software you must label
|
|
Packit |
fd8b60 |
* your software as modified software and not distribute it in such a
|
|
Packit |
fd8b60 |
* fashion that it might be confused with the original M.I.T. software.
|
|
Packit |
fd8b60 |
* M.I.T. makes no representations about the suitability of
|
|
Packit |
fd8b60 |
* this software for any purpose. It is provided "as is" without express
|
|
Packit |
fd8b60 |
* or implied warranty.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* Declarations for "API" of network listener/dispatcher in libapputils. */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#ifndef NET_SERVER_H
|
|
Packit |
fd8b60 |
#define NET_SERVER_H
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#include <verto.h>
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* The delimeter characters supported by the addresses string. */
|
|
Packit |
fd8b60 |
#define ADDRESSES_DELIM ",; "
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
typedef struct _krb5_fulladdr {
|
|
Packit |
fd8b60 |
krb5_address * address;
|
|
Packit |
fd8b60 |
krb5_ui_4 port;
|
|
Packit |
fd8b60 |
} krb5_fulladdr;
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* exported from network.c */
|
|
Packit |
fd8b60 |
void init_addr(krb5_fulladdr *, struct sockaddr *);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* exported from net-server.c */
|
|
Packit |
fd8b60 |
verto_ctx *loop_init(verto_ev_type types);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Add listener addresses to the loop configuration.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* Arguments:
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* - default_port
|
|
Packit |
fd8b60 |
* The port for the sockets if not specified in addresses.
|
|
Packit |
fd8b60 |
* - addresses
|
|
Packit |
fd8b60 |
* The optional addresses for the listener sockets. Pass NULL for the
|
|
Packit |
fd8b60 |
* wildcard address. Addresses may be delimited by the characters in
|
|
Packit |
fd8b60 |
* ADDRESSES_DELIM. Addresses are parsed with k5_parse_host_string().
|
|
Packit |
fd8b60 |
* - prognum, versnum, dispatchfn
|
|
Packit |
fd8b60 |
* For RPC listener sockets, the svc_register() arguments to use when new
|
|
Packit |
fd8b60 |
* TCP connections are created.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
krb5_error_code loop_add_udp_address(int default_port, const char *addresses);
|
|
Packit |
fd8b60 |
krb5_error_code loop_add_tcp_address(int default_port, const char *addresses);
|
|
Packit |
fd8b60 |
krb5_error_code loop_add_rpc_service(int default_port, const char *addresses,
|
|
Packit |
fd8b60 |
u_long prognum, u_long versnum,
|
|
Packit |
fd8b60 |
void (*dispatchfn)());
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
krb5_error_code loop_setup_network(verto_ctx *ctx, void *handle,
|
|
Packit |
fd8b60 |
const char *progname,
|
|
Packit |
fd8b60 |
int tcp_listen_backlog);
|
|
Packit |
fd8b60 |
krb5_error_code loop_setup_signals(verto_ctx *ctx, void *handle,
|
|
Packit |
fd8b60 |
void (*reset)());
|
|
Packit |
fd8b60 |
void loop_free(verto_ctx *ctx);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/* to be supplied by the server application */
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Two routines for processing an incoming message and getting a
|
|
Packit |
fd8b60 |
* result to send back.
|
|
Packit |
fd8b60 |
*
|
|
Packit |
fd8b60 |
* The first, dispatch(), is for normal processing of a request. The
|
|
Packit |
fd8b60 |
* second, make_toolong_error(), is obviously for generating an error
|
|
Packit |
fd8b60 |
* to send back when the incoming message is bigger than
|
|
Packit |
fd8b60 |
* the main loop can accept.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
typedef void (*loop_respond_fn)(void *arg, krb5_error_code code,
|
|
Packit |
fd8b60 |
krb5_data *response);
|
|
Packit |
fd8b60 |
void dispatch(void *handle, const krb5_fulladdr *local_addr,
|
|
Packit |
fd8b60 |
const krb5_fulladdr *remote_addr, krb5_data *request,
|
|
Packit |
fd8b60 |
int is_tcp, verto_ctx *vctx, loop_respond_fn respond, void *arg);
|
|
Packit |
fd8b60 |
krb5_error_code make_toolong_error (void *handle, krb5_data **);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
/*
|
|
Packit |
fd8b60 |
* Contexts are needed in lots of places. Opaque application-provided
|
|
Packit |
fd8b60 |
* handles are passed around in lots of place, but contexts are not.
|
|
Packit |
fd8b60 |
* For now, we'll require that the application provide us an easy way
|
|
Packit |
fd8b60 |
* to get at a context; eventually it should probably be explicity.
|
|
Packit |
fd8b60 |
*/
|
|
Packit |
fd8b60 |
krb5_context get_context(void *handle);
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
#endif /* NET_SERVER_H */
|