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