22#include <sys/socket.h>
26#include <netinet/tcp.h>
27#include <netinet/in.h>
36#define SA_ONESHOT SA_RESETHAND
42 ((((x) & 0xff00000000000000ull) >> 56) \
43 | (((x) & 0x00ff000000000000ull) >> 40) \
44 | (((x) & 0x0000ff0000000000ull) >> 24) \
45 | (((x) & 0x000000ff00000000ull) >> 8) \
46 | (((x) & 0x00000000ff000000ull) << 8) \
47 | (((x) & 0x0000000000ff0000ull) << 24) \
48 | (((x) & 0x000000000000ff00ull) << 40) \
49 | (((x) & 0x00000000000000ffull) << 56))
55#define AFP_ENUMERATE 9
57#define AFP_GETSRVINFO 15
58#define AFP_GETSRVPARAM 16
64#define AFP_OPENFORK 26
74#define DIRPBIT_CDATE 2
75#define DIRPBIT_MDATE 3
76#define DIRPBIT_BDATE 4
77#define DIRPBIT_FINFO 5
78#define DIRPBIT_LNAME 6
79#define DIRPBIT_SNAME 7
81#define DIRPBIT_OFFCNT 9
84#define DIRPBIT_ACCESS 12
85#define DIRPBIT_PDINFO 13
86#define DIRPBIT_UNIXPR 15
89#define ATTRBIT_EXPFOLDER (1 << 1)
90#define ATTRBIT_MOUNTED (1 << 3)
91#define ATTRBIT_INEXPFOLDER (1 << 4)
93#define FILDIRBIT_ISDIR (1 << 7)
94#define FILDIRBIT_ISFILE (0)
97#define DIRDID_ROOT_PARENT htonl(1)
98#define DIRDID_ROOT htonl(2)
102#define FILPBIT_ATTR 0
103#define FILPBIT_PDID 1
104#define FILPBIT_CDATE 2
105#define FILPBIT_MDATE 3
106#define FILPBIT_BDATE 4
107#define FILPBIT_FINFO 5
108#define FILPBIT_LNAME 6
109#define FILPBIT_SNAME 7
110#define FILPBIT_FNUM 8
111#define FILPBIT_DFLEN 9
112#define FILPBIT_RFLEN 10
113#define FILPBIT_EXTDFLEN 11
114#define FILPBIT_PDINFO 13
115#define FILPBIT_EXTRFLEN 14
116#define FILPBIT_UNIXPR 15
119#define ATTRBIT_INVISIBLE (1<<0)
120#define ATTRBIT_MULTIUSER (1<<1)
121#define ATTRBIT_SYSTEM (1<<2)
122#define ATTRBIT_DOPEN (1<<3)
123#define ATTRBIT_ROPEN (1<<4)
124#define ATTRBIT_SHARED (1<<4)
125#define ATTRBIT_NOWRITE (1<<5)
126#define ATTRBIT_BACKUP (1<<6)
127#define ATTRBIT_NORENAME (1<<7)
128#define ATTRBIT_NODELETE (1<<8)
129#define ATTRBIT_NOCOPY (1<<10)
130#define ATTRBIT_SETCLR (1<<15)
134#define VOLPBIT_ATTR_RO (1 << 0)
135#define VOLPBIT_ATTR_PASSWD (1 << 1)
136#define VOLPBIT_ATTR_FILEID (1 << 2)
137#define VOLPBIT_ATTR_CATSEARCH (1 << 3)
138#define VOLPBIT_ATTR_BLANKACCESS (1 << 4)
139#define VOLPBIT_ATTR_UNIXPRIV (1 << 5)
140#define VOLPBIT_ATTR_UTF8 (1 << 6)
141#define VOLPBIT_ATTR_NONETUID (1 << 7)
142#define VOLPBIT_ATTR_PRIVPARENT (1 << 8)
143#define VOLPBIT_ATTR_NOEXCHANGE (1 << 9)
144#define VOLPBIT_ATTR_EXTATTRS (1 << 10)
145#define VOLPBIT_ATTR_ACLS (1 << 11)
147#define VOLPBIT_ATTR 0
149#define VOLPBIT_CDATE 2
150#define VOLPBIT_MDATE 3
151#define VOLPBIT_BDATE 4
153#define VOLPBIT_BFREE 6
154#define VOLPBIT_BTOTAL 7
155#define VOLPBIT_NAME 8
157#define VOLPBIT_XBFREE 9
158#define VOLPBIT_XBTOTAL 10
159#define VOLPBIT_BSIZE 11
163#define AFPOF_DFORK 0x00
164#define AFPOF_RFORK 0x80
166#define OPENFORK_DATA (0)
167#define OPENFORK_RSCS (1<<7)
169#define OPENACC_RD (1<<0)
170#define OPENACC_WR (1<<1)
171#define OPENACC_DRD (1<<4)
172#define OPENACC_DWR (1<<5)
174#define AFPFORK_OPEN (1<<0)
175#define AFPFORK_RSRC (1<<1)
176#define AFPFORK_DATA (1<<2)
177#define AFPFORK_DIRTY (1<<3)
178#define AFPFORK_ACCRD (1<<4)
179#define AFPFORK_ACCWR (1<<5)
180#define AFPFORK_ACCMASK (AFPFORK_ACCRD | AFPFORK_ACCWR)
184#if _FILE_OFFSET_BITS == 64
185#define AD_FILELOCK_BASE (UINT64_C(0x7FFFFFFFFFFFFFFF) - 9)
187#define AD_FILELOCK_BASE (UINT32_C(0x7FFFFFFF) - 9)
201#define min(a,b) ((a) < (b) ? (a) : (b))
205#define dsi_clientID(x) ((x)->clientID++)
207#define my_dsi_send(x) do { \
208 (x)->header.dsi_len = htonl((x)->cmdlen); \
209 my_dsi_stream_send((x), (x)->commands, (x)->cmdlen); \
260 uint16_t rfbitmap, uint16_t rdbitmap);
262 uint16_t rfbitmap, uint16_t rdbitmap);
301 int offset,
int size);
303 off_t offset, off_t size);
316 int did,
char *name, uint16_t access);
327 char *
data,
char whence);
329 char *
data,
char whence);
330unsigned int AFPWrite(
CONN *conn, uint16_t fork,
int offset,
int size,
331 char *
data,
char whence);
332unsigned int AFPWrite_ext(
CONN *conn, uint16_t fork, off_t offset, off_t size,
333 char *
data,
char whence);
335 off_t size,
char *
data,
char whence);
341unsigned int AFPRead(
CONN *conn, uint16_t fork,
int offset,
int size,
343unsigned int AFPRead_ext(
CONN *conn, uint16_t fork, off_t offset, off_t size,
346 off_t size,
char *
data);
359 uint32_t tag,
char *name);
360unsigned int AFPGetAPPL(
CONN *conn, uint16_t dt,
char *name, uint16_t index,
369 uint16_t f_bitmap, uint16_t d_bitmap,
374 uint16_t f_bitmap, uint16_t d_bitmap,
384 int maxsize,
char *pathname);
386 int maxsize,
char *pathname,
char *attrname);
388 char *pathname,
char *attrname,
char *
data);
390 uint16_t bitmap,
char *pathname,
char *attrname);
393void u2mac(uint8_t *dst,
char *name,
int len);
CONN * Conn2
Definition afparg.c:57
char * vers
Definition afparg.c:53
char * uam
Definition afparg.c:54
static DSI * dsi
Definition afparg.c:39
CONN * Conn
Definition afparg.c:40
unsigned int AFPGetAPPL(CONN *conn, uint16_t dt, char *name, uint16_t index, uint16_t f_bitmap)
Definition afpclient.c:2182
int my_dsi_data_receive(DSI *x)
Definition afpclient.c:325
unsigned int AFPRemoveAPPL(CONN *conn, uint16_t dt, int did, char *creator, char *name)
Definition afpclient.c:2240
unsigned int AFPCloseFork(CONN *conn, uint16_t fork)
Definition afpclient.c:731
unsigned int AFPFlush(CONN *conn, uint16_t vol)
Definition afpclient.c:853
unsigned int AFPByteLock_ext(CONN *conn, uint16_t fork, int end, int mode, off_t offset, off_t size)
Definition afpclient.c:807
unsigned int AFPWriteFooter(DSI *dsi, uint16_t fork, int offset, int size, char *data, char whence)
Definition afpclient.c:1628
unsigned int DSIGetStatus(CONN *conn)
Definition afpclient.c:439
unsigned int AFPopenLoginExt(CONN *conn, char *vers, char *uam, char *usr, char *pwd)
Definition afpclient.c:521
unsigned int DSIOpenSession(CONN *conn)
Definition afpclient.c:399
unsigned int AFPSetVolParam(CONN *conn, uint16_t vol, uint16_t bitmap, struct afp_volume_parms *parms)
Definition afpclient.c:1497
unsigned int AFPGetForkParam(CONN *conn, uint16_t fork, uint16_t bitmap)
Definition afpclient.c:2159
unsigned int DSICloseSession(CONN *conn)
Definition afpclient.c:457
unsigned int AFPByteLock(CONN *conn, uint16_t fork, int end, int mode, int offset, int size)
Definition afpclient.c:741
unsigned int AFPGetSrvrInfo(CONN *conn)
Definition afpclient.c:669
unsigned int AFPSetExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap, char *pathname, char *attrname, char *data)
Definition afpclient.c:2482
unsigned int AFPAddAPPL(CONN *conn, uint16_t dt, int did, char *creator, uint32_t tag, char *name)
Definition afpclient.c:2212
unsigned int AFPGetSrvrMsg(CONN *conn, uint16_t type, uint16_t bitmap)
Definition afpclient.c:689
uint16_t my_dsi_cmd_nwriterply_async(CONN *conn, uint64_t n)
unsigned int AFPCloseVol(CONN *conn, uint16_t vol)
Definition afpclient.c:711
uint16_t AFPOpenFork(CONN *conn, uint16_t vol, char type, uint16_t bitmap, int did, char *name, uint16_t access)
Definition afpclient.c:1739
unsigned int AFPGetComment(CONN *conn, uint16_t vol, int did, char *name)
Definition afpclient.c:1784
void afp_filedir_unpack(struct afp_filedir_parms *filedir, unsigned char *b, uint16_t rfbitmap, uint16_t rdbitmap)
Definition afpclient.c:1135
int OpenClientSocket(char *host, int port)
Definition afpclient.c:20
unsigned int AFPCatSearch(CONN *conn, uint16_t vol, uint32_t nbe, char *pos, uint16_t f_bitmap, uint16_t d_bitmap, uint32_t rbitmap, struct afp_filedir_parms *filedir, struct afp_filedir_parms *filedir2)
Definition afpclient.c:2266
unsigned int AFPMapName(CONN *conn, char fn, char *name)
Definition afpclient.c:1939
uint16_t AFPOpenVol(CONN *conn, char *vol, uint16_t bitmap)
Definition afpclient.c:873
unsigned int AFPMapID(CONN *conn, char fn, int id)
Definition afpclient.c:1918
unsigned int AFPCreateDir(CONN *conn, uint16_t vol, int did, char *name)
Definition afpclient.c:2127
unsigned int AFPWriteHeader(DSI *dsi, uint16_t fork, int offset, int size, char *data, char whence)
Definition afpclient.c:1597
unsigned int AFPCatSearchExt(CONN *conn, uint16_t vol, uint32_t nbe, char *pos, uint16_t f_bitmap, uint16_t d_bitmap, uint32_t rbitmap, struct afp_filedir_parms *filedir, struct afp_filedir_parms *filedir2)
Definition afpclient.c:2314
unsigned int AFPChangePW(CONN *conn, char *uam, char *usr, char *opwd, char *pwd)
Definition afpclient.c:592
unsigned int AFPGetSrvrParms(CONN *conn)
Definition afpclient.c:679
unsigned int AFPWrite_ext_async(CONN *conn, uint16_t fork, off_t offset, off_t size, char *data, char whence)
Definition afpclient.c:1711
int my_dsi_stream_send(DSI *dsi, void *buf, size_t length)
Definition afpclient.c:183
size_t my_dsi_stream_write(DSI *dsi, void *data, const size_t length)
Definition afpclient.c:152
unsigned int AFPListExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap, int maxsize, char *pathname)
Definition afpclient.c:2448
unsigned int AFPBadPacket(CONN *conn, char fn, char *name)
Definition afpclient.c:1977
unsigned int AFPRead(CONN *conn, uint16_t fork, int offset, int size, char *data)
Definition afpclient.c:2045
unsigned int AFPGetExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap, int maxsize, char *pathname, char *attrname)
Definition afpclient.c:2394
void afp_volume_unpack(struct afp_volume_parms *parms, unsigned char *b, uint16_t rbitmap)
Definition afpclient.c:981
int afp_filedir_pack(unsigned char *b, struct afp_filedir_parms *filedir, uint16_t rfbitmap, uint16_t rdbitmap)
Definition afpclient.c:1309
unsigned int AFPReadHeader(DSI *dsi, uint16_t fork, int offset, int size, char *data)
Definition afpclient.c:2000
char * strp2cdup(unsigned char *src)
Definition afpclient.c:952
unsigned int AFPFlushFork(CONN *conn, uint16_t fork)
Definition afpclient.c:863
unsigned int AFPRead_ext(CONN *conn, uint16_t fork, off_t offset, off_t size, char *data)
Definition afpclient.c:2057
void dump_header(DSI *dsi)
Definition afpcmd.c:489
void u2mac(uint8_t *dst, char *name, int len)
Definition afpclient.c:1524
unsigned int AFPDelete(CONN *conn, uint16_t vol, int did, char *name)
Definition afpclient.c:1778
unsigned int AFPDisconnectOldSession(CONN *conn, uint16_t type, int len, char *token)
Definition afpclient.c:1867
unsigned int AFPGetACL(CONN *conn, uint16_t vol, int did, uint16_t bitmap, char *name)
Definition afpclient.c:2365
unsigned int AFPSetForkParam(CONN *conn, uint16_t fork, uint16_t bitmap, off_t size)
Definition afpclient.c:828
size_t my_dsi_stream_read(DSI *dsi, void *data, const size_t length)
Definition afpclient.c:76
int FPset_name(CONN *conn, int ofs, char *name)
Definition afpclient.c:1544
unsigned int AFPzzz(CONN *conn, int)
Definition afpclient.c:649
unsigned int AFPReadFooter(DSI *dsi, uint16_t fork, int offset, int size, char *data)
Definition afpclient.c:2025
unsigned int AFPGetUserInfo(CONN *conn, char flag, int id, uint16_t bitmap)
Definition afpclient.c:1894
int my_dsi_stream_receive(DSI *dsi, void *buf, const size_t ilength, size_t *rlength)
Definition afpclient.c:132
unsigned int AFPCreateFile(CONN *conn, uint16_t vol, char type, int did, char *name)
Definition afpclient.c:1574
unsigned int AFPCloseDT(CONN *conn, uint16_t vol)
Definition afpclient.c:721
unsigned int AFPRead_ext_async(CONN *conn, uint16_t fork, off_t offset, off_t size, char *data)
Definition afpclient.c:2107
unsigned int AFPGetVolParam(CONN *conn, uint16_t vol, uint16_t bitmap)
Definition afpclient.c:1475
unsigned int AFPLogOut(CONN *conn)
Definition afpclient.c:638
unsigned int AFPWrite_ext(CONN *conn, uint16_t fork, off_t offset, off_t size, char *data, char whence)
Definition afpclient.c:1664
unsigned int AFPRemoveComment(CONN *conn, uint16_t vol, int did, char *name)
Definition afpclient.c:1790
unsigned int AFPWrite(CONN *conn, uint16_t fork, int offset, int size, char *data, char whence)
Definition afpclient.c:1654
unsigned int AFPRemoveExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap, char *pathname, char *attrname)
Definition afpclient.c:2532
unsigned int AFPAddComment(CONN *conn, uint16_t vol, int did, char *name, char *cmt)
Definition afpclient.c:1796
int CloseClientSocket(int fd)
Definition afpclient.c:69
unsigned int AFPGetSessionToken(CONN *conn, int type, uint32_t time, int len, char *token)
Definition afpclient.c:1829
int my_dsi_cmd_receive(DSI *x)
Definition afpclient.c:319
unsigned int AFPopenLogin(CONN *conn, char *vers, char *uam, char *usr, char *pwd)
Definition afpclient.c:474
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:75
#define data
Definition hash.c:37
cnid_t did
Definition nad_cp.c:93
static enum op type
Definition nad_cp.c:96
#define flag(x)
Definition netacnv.c:15
static unsigned char port
Definition pap.c:504
Definition afpclient.h:190
int afp_version
Definition afpclient.h:196
int type
Definition afpclient.h:195
DSI dsi
Definition afpclient.h:191
Definition include/atalk/dsi.h:58
Definition afpclient.h:219
uint16_t offcnt
Definition afpclient.h:230
int isdir
Definition afpclient.h:220
uint16_t attr
Definition afpclient.h:222
int name_type
Definition afpclient.h:237
uint32_t cdate
Definition afpclient.h:226
uint32_t rflen
Definition afpclient.h:227
char * sname
Definition afpclient.h:239
uint32_t mdate
Definition afpclient.h:226
uint32_t gid
Definition afpclient.h:231
char * utf8_name
Definition afpclient.h:240
char finder_info[32]
Definition afpclient.h:236
uint32_t bdate
Definition afpclient.h:226
uint16_t vid
Definition afpclient.h:223
uint8_t pdinfo[6]
Definition afpclient.h:234
uint64_t ext_dflen
Definition afpclient.h:228
uint64_t ext_rflen
Definition afpclient.h:229
uint32_t did
Definition afpclient.h:225
uint32_t uid
Definition afpclient.h:231
uint32_t dflen
Definition afpclient.h:227
char * lname
Definition afpclient.h:238
uint32_t pdid
Definition afpclient.h:224
uint32_t unix_priv
Definition afpclient.h:232
uint16_t bitmap
Definition afpclient.h:221
uint8_t access[4]
Definition afpclient.h:233
Definition afpclient.h:243
uint8_t flags
Definition afpclient.h:246
uint16_t vid
Definition afpclient.h:250
uint8_t state
Definition afpclient.h:245
uint32_t mdate
Definition afpclient.h:249
uint16_t attr
Definition afpclient.h:247
uint32_t btotal
Definition afpclient.h:251
uint32_t cdate
Definition afpclient.h:249
uint32_t bdate
Definition afpclient.h:249
char * utf8_name
Definition afpclient.h:253
char * name
Definition afpclient.h:252
uint32_t bfree
Definition afpclient.h:251
uint16_t sig
Definition afpclient.h:248
uint32_t bsize
Definition afpclient.h:251
Definition include/atalk/volume.h:30
DSI (Data Stream Interface) protocol definitions modified for the afptest test-suite.