[go: up one dir, main page]

File: connection.h

package info (click to toggle)
dnprogs 2.37.2-0.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,380 kB
  • ctags: 3,838
  • sloc: ansic: 24,383; cpp: 10,540; makefile: 753; sh: 553; awk: 13
file content (104 lines) | stat: -rw-r--r-- 2,853 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef LIBDAP_CONNECTION_H
#define LIBDAP_CONNECTION_H

// connection.h
//
// Encapsulates a DAP connection. Incoming and Outgoing
//

class dap_connection
{
 public:
    dap_connection(int verbosity);
    dap_connection(int socket, int bs, int verbosity);
    ~dap_connection();

    bool connect(char *node,  char *user, char *password, char *object);
    bool connect(char *node,  char *user, char *password, int   object);
    bool connect(char *fspec, int   object, char *tailspec);
    bool connect(char *fspec, char *object, char *tailspec);

    bool bind(char *object);
    bool bind(int object);
    bool bind_wild();
    
    dap_connection *waitfor();

    char *getbytes(int num);
    char *peekbytes(int num);
    int   putbytes(void *bytes, int num);
    int   check_length(int);
    int   get_length();
    int   read(bool);
    int   read_if_necessary(bool);
    int   write();
    int   send_crc(unsigned short);
    char *get_error();
    void  set_blocksize(int);
    int   get_blocksize();
    bool  have_bytes(int);
    int   set_blocked(bool onoff);
    void  allow_blocking(bool onoff);
    int   verbosity() {return verbose;};
    bool  parse(const char *fname,
		struct accessdata_dn &accessdata, char *node, char *filespec);
    void close();
    int  get_fd() { return sockfd; }
    int  get_remote_os() { return remote_os; };
    bool exchange_config();
    void clear_output_buffer();
    
// Static utility functions
    static void makelower(char *s);
    static void makeupper(char *s);
    
 private:
    char  *buf;
    char  *outbuf;
    int    sockfd;
    int    bufptr;
    int    outbufptr;
    int    buflen;
    int    blocksize;
    int    have_shadow;
    int    verbose;
    bool   connected;
    bool   listening;
    bool   blocked;
    bool   blocking_allowed;
    bool   closed;
    int    last_msg_start;
    int    end_of_msg;
    int    remote_os;
    struct nodeent *binadr;
    
    char *lasterror;
    char  errstring[256];

    static const unsigned int MAX_READ_SIZE = 65535;

    void create_socket();
    void initialise(int);
    bool do_connect(const char *node, const char *user,
		    const char *password, sockaddr_dn &sockaddr);

    bool error_return(char *);
    char *connerror(char *);
    
/* DECnet phase IV limits */
    static const int MAX_NODE     = 6;
    static const int MAX_USER     = 12;
    static const int MAX_PASSWORD = 12;
    static const int MAX_ACCOUNT  = 12;

 public:
    // Some DECnet object numbers
    static const unsigned int FAL_OBJECT    = 17;
    static const unsigned int NML_OBJECT    = 19;
    static const unsigned int MIRROR_OBJECT = 25;
    static const unsigned int EVL_OBJECT    = 26;
    static const unsigned int MAIL_OBJECT   = 27;
    static const unsigned int PHONE_OBJECT  = 29;
    static const unsigned int CTERM_OBJECT  = 42;
};
#endif