Imported Upstream version 2.4.5
[debian/amanda] / common-src / protocol.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /*
27  * $Id: protocol.h,v 1.8.10.2.2.2 2004/04/29 20:47:22 martinea Exp $
28  *
29  * interfaces for amanda protocol
30  */
31 #ifndef PROTOCOL_H
32 #define PROTOCOL_H
33
34 #include "amanda.h"
35 #include "dgram.h"
36
37 typedef enum {
38     S_BOGUS,
39     S_STARTUP, S_SENDREQ, S_ACKWAIT, S_REPWAIT, S_SUCCEEDED, S_FAILED
40 } pstate_t;
41
42 typedef enum { A_BOGUS, A_START, A_TIMEOUT, A_RCVDATA } action_t;
43
44 typedef enum { P_BOGUS, P_REQ, P_REP, P_PREP, P_ACK, P_NAK } pktype_t;
45
46 typedef struct {                        /* a predigested datagram */
47     pktype_t type;
48     struct sockaddr_in peer;
49     uint32_t cksum;
50     int version_major, version_minor;
51     int sequence;
52     char *handle;
53     char *service;
54     char *security;
55     char *body;
56     dgram_t dgram;
57 } pkt_t;
58
59 typedef struct proto_s {
60     pstate_t state;
61     pstate_t prevstate;
62     struct sockaddr_in peer;
63     time_t timeout;
64     time_t repwait;
65     time_t origtime, curtime;
66     int reqtries, acktries;
67     int origseq, curseq;
68     int handleofs;
69     char *security;
70     uint32_t auth_cksum;
71     char *req;                                  /* body of request msg */
72     void (*continuation) P((struct proto_s *, pkt_t *));
73     void *datap;
74     struct proto_s *prev,*next;
75 } proto_t;
76
77 void proto_init P((int sock, int startseq, int handles));
78 int make_request P((char *hostname, int port, char *req, void *datap,
79                     time_t repwait, 
80                     void (*continuation) P((proto_t *p, pkt_t *pkt))
81                     ));
82
83 void check_protocol P((void));
84 void run_protocol P((void));
85
86 void parse_pkt_header P((pkt_t *pkt));
87
88 #ifdef KRB4_SECURITY
89 int make_krb_request P((char *hostname, int port, char *req,
90                         void *datap, time_t repwait,
91                         void (*continuation) P((proto_t *p, pkt_t *pkt))
92                         ));
93 #endif
94
95 extern char *parse_errmsg;
96
97 #endif /* PROTOCOL_H */