]> arthur.barton.de Git - netatalk.git/blob - include/atalk/server_child.h
AFP statistics via dbus IPC
[netatalk.git] / include / atalk / server_child.h
1 /*
2  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
3  * All rights reserved.
4  */
5
6 #ifndef _ATALK_SERVER_CHILD_H
7 #define _ATALK_SERVER_CHILD_H 1
8
9 #include <sys/types.h>
10 #include <arpa/inet.h>
11
12 /* useful stuff for child processes. most of this is hidden in 
13  * server_child.c to ease changes in implementation */
14
15 #define CHILD_HASHSIZE 32
16
17 /* One AFP session child process */
18 typedef struct afp_child {
19     pid_t           afpch_pid;         /* afpd worker process pid (from the worker afpd process )*/
20     uid_t           afpch_uid;         /* user id of connected client (from the worker afpd process) */
21     int             afpch_valid;       /* 1 if we have a clientid */
22     int             afpch_killed;      /* 1 if we already tried to kill the client */
23     uint32_t        afpch_boottime;    /* client boot time (from the mac client) */
24     time_t          afpch_logintime;   /* time the child was added */
25     uint32_t        afpch_idlen;       /* clientid len (from the Mac client) */
26     char           *afpch_clientid;    /* clientid (from the Mac client) */
27     int             afpch_ipc_fd;      /* socket for IPC bw afpd parent and childs */
28     int16_t         afpch_state;       /* state of AFP session (eg active, sleeping, disconnected) */
29     char           *afpch_volumes;     /* mounted volumes */
30     struct afp_child **afpch_prevp;
31     struct afp_child *afpch_next;
32 } afp_child_t;
33
34 /* Info and table with all AFP session child processes */
35 typedef struct {
36     pthread_mutex_t servch_lock;                    /* Lock */
37     int             servch_count;                   /* Current count of active AFP sessions */
38     int             servch_nsessions;               /* Number of allowed AFP sessions */
39     afp_child_t    *servch_table[CHILD_HASHSIZE];   /* Hashtable with data of AFP sesssions */
40 } server_child_t;
41
42 /* server_child.c */
43 extern server_child_t *server_child_alloc(int);
44 extern afp_child_t *server_child_add(server_child_t *, pid_t, int ipc_fd);
45 extern int  server_child_remove(server_child_t *, pid_t);
46 extern void server_child_free(server_child_t *);
47 extern afp_child_t *server_child_resolve(server_child_t *childs, id_t pid);
48
49 extern void server_child_kill(server_child_t *, int);
50 extern void server_child_kill_one_by_id(server_child_t *children, pid_t pid, uid_t,
51                                         uint32_t len, char *id, uint32_t boottime);
52 extern int  server_child_transfer_session(server_child_t *children, pid_t, uid_t, int, uint16_t);
53 extern void server_child_handler(server_child_t *);
54 extern void server_reset_signal(void);
55
56 #endif