]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/bnet_pkt.c
Add jcr to BSOCK and BDB SpoolAttr NoAttributs finish up multiple simultaneous jobs...
[bacula/bacula] / bacula / src / lib / bnet_pkt.c
1 /*
2  * Network Packet Utility Routines
3  *
4  *  by Kern Sibbald, July MMII
5  *
6  *
7  *   Version $Id$
8  */
9 /*
10    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License as
14    published by the Free Software Foundation; either version 2 of
15    the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20    General Public License for more details.
21
22    You should have received a copy of the GNU General Public
23    License along with this program; if not, write to the Free
24    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25    MA 02111-1307, USA.
26
27  */
28
29
30 #include "bacula.h"
31
32 /* 
33  * Receive a message from the other end. Each message consists of
34  * two packets. The first is a header that contains the size
35  * of the data that follows in the second packet.
36  * Returns number of bytes read
37  * Returns 0 on end of file
38  * Returns -1 on hard end of file (i.e. network connection close)
39  * Returns -2 on error
40  */
41 int32_t 
42 bnet_recv_pkt(BSOCK *bsock, BPKT *pkt)
43 {
44 }
45
46 /*
47  * Send a message over the network. The send consists of
48  * two network packets. The first is sends a 32 bit integer containing
49  * the length of the data packet which follows.
50  *
51  * Returns: 0 on failure
52  *          1 on success
53  */
54 int
55 bnet_send_pkt(BSOCK *bsock, BPKT *pkt)
56 {
57    ser_declare;
58
59    ser_begin(bsock->msg, 0);
60
61    while (pkt->type != BP_EOF) {
62       ser_int8(pkt->type);
63       switch (pkt->type) {
64       case BP_CHAR:
65          ser_int8(*((int8_t)pkt->value)));
66          break;
67       case BP_INT32:
68          ser_int32(*(int32_t)pkt->value)));
69          break;
70       case BP_UINT32:
71          break;
72       case BP_INT64:
73          break;
74       case BP_STRING:
75          break;
76       case BP_NAME:
77          break;
78       case BP_BYTES:
79          break;
80       case BP_FLOAT32:
81          break;
82       case BP_FLOAT64:
83          break;
84       default:
85          Emsg1(M_ABORT, 0, _("Unknown BPKT type: %d\n"), pkt->type);
86       }
87
88 }