File: ident.h

package info (click to toggle)
libident 0.32-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,464 kB
  • sloc: sh: 8,260; ansic: 840; makefile: 27
file content (99 lines) | stat: -rw-r--r-- 2,408 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
/*
** ident.h
**
** Author: Peter Eriksson <pen@lysator.liu.se>
** Intruder: Pr Emanuelsson <pell@lysator.liu.se>
** Perturbed by: Rmi Denis-Courmont <rdenis@simphalempin.com>
*/

#ifndef __IDENT_H__
# define __IDENT_H__

# ifdef	__cplusplus
extern "C" {
# endif

/*
 * Unfortunately, we can't use HAVE_*_H constants because this header
 * might be used by not-autoconf-igured software. :-(
 */
# include <sys/types.h>
# include <sys/select.h> /* struct timeval (new POSIX) */
# include <sys/time.h> /* struct timeval (old POSIX) */
# include <sys/socket.h> /* struct sockaddr */
# include <netinet/in.h> /* struct in_addr */

# ifndef FD_SETSIZE
#  define FD_SETSIZE 64
# endif

# ifndef IDBUFSIZE
#  define IDBUFSIZE 2048
# endif

# ifndef IPPORT_IDENT
#  define IPPORT_IDENT	113
# endif

typedef struct
{
  int fd;
  char buf[IDBUFSIZE];
} ident_t;

typedef struct {
  int lport;                    /* Local port */
  int fport;                    /* Far (remote) port */
  char *identifier;             /* Normally user name */
  char *opsys;                  /* OS */
  char *charset;                /* Charset (what did you expect?) */
} IDENT;                        /* For higher-level routines */

/* Low-level calls and macros */
# define id_fileno(ID)	((ID)->fd)

extern ident_t *id_open_addr (const struct sockaddr *laddr,
				const struct sockaddr *faddr,
				struct timeval *timeout);
extern ident_t *id_open (const struct in_addr *laddr,
				const struct in_addr *faddr,
				struct timeval *timeout);

extern int id_close (ident_t *id);
  
extern int id_query (ident_t *id, int lport, int fport,
			struct timeval *timeout);

extern int id_parse (ident_t *id, struct timeval *timeout,
			int *lport, int *fport, char **identifier,
			char **opsys, char **charset);
  
/* High-level calls */

extern IDENT *ident_lookup (int fd, int timeout);

extern char *ident_id (int fd, int timeout); // result should be free()d

extern IDENT *ident_query_addr (const struct sockaddr *laddr,
				const struct sockaddr *raddr, int timeout);

extern IDENT *ident_query (const struct in_addr *laddr,
				const struct in_addr *faddr,
				int lport, int rport, int timeout);

extern void ident_free (IDENT *id);

extern const char *id_version;

# ifdef IN_LIBIDENT_SRC

extern char *id_strdup (char *str);
extern char *id_strtok (char *cp, char *cs, char *dc);

# endif

# ifdef	__cplusplus
}
# endif

#endif