1 /* 2 ** ident.h 3 ** 4 ** Author: Peter Eriksson <pen@lysator.liu.se> 5 ** Intruder: P�r Emanuelsson <pell@lysator.liu.se> 6 ** Perturbed by: R�mi Denis-Courmont <rdenis@simphalempin.com> 7 */ 8 9 #ifndef __IDENT_H__ 10 # define __IDENT_H__ 11 12 # ifdef __cplusplus 13 extern "C" { 14 # endif 15 16 /* 17 * Unfortunately, we can't use HAVE_*_H constants because this header 18 * might be used by not-autoconf-igured software. :-( 19 */ 20 # include <sys/types.h> 21 # include <sys/select.h> /* struct timeval (new POSIX) */ 22 # include <sys/time.h> /* struct timeval (old POSIX) */ 23 # include <sys/socket.h> /* struct sockaddr */ 24 # include <netinet/in.h> /* struct in_addr */ 25 26 # ifndef FD_SETSIZE 27 # define FD_SETSIZE 64 28 # endif 29 30 # ifndef IDBUFSIZE 31 # define IDBUFSIZE 2048 32 # endif 33 34 # ifndef IPPORT_IDENT 35 # define IPPORT_IDENT 113 36 # endif 37 38 typedef struct 39 { 40 int fd; 41 char buf[IDBUFSIZE]; 42 } ident_t; 43 44 typedef struct { 45 int lport; /* Local port */ 46 int fport; /* Far (remote) port */ 47 char *identifier; /* Normally user name */ 48 char *opsys; /* OS */ 49 char *charset; /* Charset (what did you expect?) */ 50 } IDENT; /* For higher-level routines */ 51 52 /* Low-level calls and macros */ 53 # define id_fileno(ID) ((ID)->fd) 54 55 extern ident_t *id_open_addr (const struct sockaddr *laddr, 56 const struct sockaddr *faddr, 57 struct timeval *timeout); 58 extern ident_t *id_open (const struct in_addr *laddr, 59 const struct in_addr *faddr, 60 struct timeval *timeout); 61 62 extern int id_close (ident_t *id); 63 64 extern int id_query (ident_t *id, int lport, int fport, 65 struct timeval *timeout); 66 67 extern int id_parse (ident_t *id, struct timeval *timeout, 68 int *lport, int *fport, char **identifier, 69 char **opsys, char **charset); 70 71 /* High-level calls */ 72 73 extern IDENT *ident_lookup (int fd, int timeout); 74 75 extern char *ident_id (int fd, int timeout); // result should be free()d 76 77 extern IDENT *ident_query_addr (const struct sockaddr *laddr, 78 const struct sockaddr *raddr, int timeout); 79 80 extern IDENT *ident_query (const struct in_addr *laddr, 81 const struct in_addr *faddr, 82 int lport, int rport, int timeout); 83 84 extern void ident_free (IDENT *id); 85 86 extern const char *id_version; 87 88 # ifdef IN_LIBIDENT_SRC 89 90 extern char *id_strdup (char *str); 91 extern char *id_strtok (char *cp, char *cs, char *dc); 92 93 # endif 94 95 # ifdef __cplusplus 96 } 97 # endif 98 99 #endif 100