xdr.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. /*
  2. * linux/fs/lockd/xdr.c
  3. *
  4. * XDR support for lockd and the lock client.
  5. *
  6. * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #include <linux/config.h>
  9. #include <linux/types.h>
  10. #include <linux/sched.h>
  11. #include <linux/utsname.h>
  12. #include <linux/nfs.h>
  13. #include <linux/sunrpc/xdr.h>
  14. #include <linux/sunrpc/clnt.h>
  15. #include <linux/sunrpc/svc.h>
  16. #include <linux/sunrpc/stats.h>
  17. #include <linux/lockd/lockd.h>
  18. #include <linux/lockd/sm_inter.h>
  19. #define NLMDBG_FACILITY NLMDBG_XDR
  20. static inline loff_t
  21. s32_to_loff_t(__s32 offset)
  22. {
  23. return (loff_t)offset;
  24. }
  25. static inline __s32
  26. loff_t_to_s32(loff_t offset)
  27. {
  28. __s32 res;
  29. if (offset >= NLM_OFFSET_MAX)
  30. res = NLM_OFFSET_MAX;
  31. else if (offset <= -NLM_OFFSET_MAX)
  32. res = -NLM_OFFSET_MAX;
  33. else
  34. res = offset;
  35. return res;
  36. }
  37. /*
  38. * XDR functions for basic NLM types
  39. */
  40. static inline u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c)
  41. {
  42. unsigned int len;
  43. len = ntohl(*p++);
  44. if(len==0)
  45. {
  46. c->len=4;
  47. memset(c->data, 0, 4); /* hockeypux brain damage */
  48. }
  49. else if(len<=NLM_MAXCOOKIELEN)
  50. {
  51. c->len=len;
  52. memcpy(c->data, p, len);
  53. p+=XDR_QUADLEN(len);
  54. }
  55. else
  56. {
  57. printk(KERN_NOTICE
  58. "lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN);
  59. return NULL;
  60. }
  61. return p;
  62. }
  63. static inline u32 *
  64. nlm_encode_cookie(u32 *p, struct nlm_cookie *c)
  65. {
  66. *p++ = htonl(c->len);
  67. memcpy(p, c->data, c->len);
  68. p+=XDR_QUADLEN(c->len);
  69. return p;
  70. }
  71. static inline u32 *
  72. nlm_decode_fh(u32 *p, struct nfs_fh *f)
  73. {
  74. unsigned int len;
  75. if ((len = ntohl(*p++)) != NFS2_FHSIZE) {
  76. printk(KERN_NOTICE
  77. "lockd: bad fhandle size %d (should be %d)\n",
  78. len, NFS2_FHSIZE);
  79. return NULL;
  80. }
  81. f->size = NFS2_FHSIZE;
  82. memset(f->data, 0, sizeof(f->data));
  83. memcpy(f->data, p, NFS2_FHSIZE);
  84. return p + XDR_QUADLEN(NFS2_FHSIZE);
  85. }
  86. static inline u32 *
  87. nlm_encode_fh(u32 *p, struct nfs_fh *f)
  88. {
  89. *p++ = htonl(NFS2_FHSIZE);
  90. memcpy(p, f->data, NFS2_FHSIZE);
  91. return p + XDR_QUADLEN(NFS2_FHSIZE);
  92. }
  93. /*
  94. * Encode and decode owner handle
  95. */
  96. static inline u32 *
  97. nlm_decode_oh(u32 *p, struct xdr_netobj *oh)
  98. {
  99. return xdr_decode_netobj(p, oh);
  100. }
  101. static inline u32 *
  102. nlm_encode_oh(u32 *p, struct xdr_netobj *oh)
  103. {
  104. return xdr_encode_netobj(p, oh);
  105. }
  106. static inline u32 *
  107. nlm_decode_lock(u32 *p, struct nlm_lock *lock)
  108. {
  109. struct file_lock *fl = &lock->fl;
  110. s32 start, len, end;
  111. if (!(p = xdr_decode_string_inplace(p, &lock->caller,
  112. &lock->len,
  113. NLM_MAXSTRLEN))
  114. || !(p = nlm_decode_fh(p, &lock->fh))
  115. || !(p = nlm_decode_oh(p, &lock->oh)))
  116. return NULL;
  117. locks_init_lock(fl);
  118. fl->fl_owner = current->files;
  119. fl->fl_pid = ntohl(*p++);
  120. fl->fl_flags = FL_POSIX;
  121. fl->fl_type = F_RDLCK; /* as good as anything else */
  122. start = ntohl(*p++);
  123. len = ntohl(*p++);
  124. end = start + len - 1;
  125. fl->fl_start = s32_to_loff_t(start);
  126. if (len == 0 || end < 0)
  127. fl->fl_end = OFFSET_MAX;
  128. else
  129. fl->fl_end = s32_to_loff_t(end);
  130. return p;
  131. }
  132. /*
  133. * Encode a lock as part of an NLM call
  134. */
  135. static u32 *
  136. nlm_encode_lock(u32 *p, struct nlm_lock *lock)
  137. {
  138. struct file_lock *fl = &lock->fl;
  139. __s32 start, len;
  140. if (!(p = xdr_encode_string(p, lock->caller))
  141. || !(p = nlm_encode_fh(p, &lock->fh))
  142. || !(p = nlm_encode_oh(p, &lock->oh)))
  143. return NULL;
  144. if (fl->fl_start > NLM_OFFSET_MAX
  145. || (fl->fl_end > NLM_OFFSET_MAX && fl->fl_end != OFFSET_MAX))
  146. return NULL;
  147. start = loff_t_to_s32(fl->fl_start);
  148. if (fl->fl_end == OFFSET_MAX)
  149. len = 0;
  150. else
  151. len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
  152. *p++ = htonl(fl->fl_pid);
  153. *p++ = htonl(start);
  154. *p++ = htonl(len);
  155. return p;
  156. }
  157. /*
  158. * Encode result of a TEST/TEST_MSG call
  159. */
  160. static u32 *
  161. nlm_encode_testres(u32 *p, struct nlm_res *resp)
  162. {
  163. s32 start, len;
  164. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  165. return NULL;
  166. *p++ = resp->status;
  167. if (resp->status == nlm_lck_denied) {
  168. struct file_lock *fl = &resp->lock.fl;
  169. *p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
  170. *p++ = htonl(fl->fl_pid);
  171. /* Encode owner handle. */
  172. if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
  173. return NULL;
  174. start = loff_t_to_s32(fl->fl_start);
  175. if (fl->fl_end == OFFSET_MAX)
  176. len = 0;
  177. else
  178. len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
  179. *p++ = htonl(start);
  180. *p++ = htonl(len);
  181. }
  182. return p;
  183. }
  184. /*
  185. * First, the server side XDR functions
  186. */
  187. int
  188. nlmsvc_decode_testargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
  189. {
  190. u32 exclusive;
  191. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  192. return 0;
  193. exclusive = ntohl(*p++);
  194. if (!(p = nlm_decode_lock(p, &argp->lock)))
  195. return 0;
  196. if (exclusive)
  197. argp->lock.fl.fl_type = F_WRLCK;
  198. return xdr_argsize_check(rqstp, p);
  199. }
  200. int
  201. nlmsvc_encode_testres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
  202. {
  203. if (!(p = nlm_encode_testres(p, resp)))
  204. return 0;
  205. return xdr_ressize_check(rqstp, p);
  206. }
  207. int
  208. nlmsvc_decode_lockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
  209. {
  210. u32 exclusive;
  211. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  212. return 0;
  213. argp->block = ntohl(*p++);
  214. exclusive = ntohl(*p++);
  215. if (!(p = nlm_decode_lock(p, &argp->lock)))
  216. return 0;
  217. if (exclusive)
  218. argp->lock.fl.fl_type = F_WRLCK;
  219. argp->reclaim = ntohl(*p++);
  220. argp->state = ntohl(*p++);
  221. argp->monitor = 1; /* monitor client by default */
  222. return xdr_argsize_check(rqstp, p);
  223. }
  224. int
  225. nlmsvc_decode_cancargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
  226. {
  227. u32 exclusive;
  228. if (!(p = nlm_decode_cookie(p, &argp->cookie)))
  229. return 0;
  230. argp->block = ntohl(*p++);
  231. exclusive = ntohl(*p++);
  232. if (!(p = nlm_decode_lock(p, &argp->lock)))
  233. return 0;
  234. if (exclusive)
  235. argp->lock.fl.fl_type = F_WRLCK;
  236. return xdr_argsize_check(rqstp, p);
  237. }
  238. int
  239. nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
  240. {
  241. if (!(p = nlm_decode_cookie(p, &argp->cookie))
  242. || !(p = nlm_decode_lock(p, &argp->lock)))
  243. return 0;
  244. argp->lock.fl.fl_type = F_UNLCK;
  245. return xdr_argsize_check(rqstp, p);
  246. }
  247. int
  248. nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp)
  249. {
  250. struct nlm_lock *lock = &argp->lock;
  251. memset(lock, 0, sizeof(*lock));
  252. locks_init_lock(&lock->fl);
  253. lock->fl.fl_pid = ~(u32) 0;
  254. if (!(p = nlm_decode_cookie(p, &argp->cookie))
  255. || !(p = xdr_decode_string_inplace(p, &lock->caller,
  256. &lock->len, NLM_MAXSTRLEN))
  257. || !(p = nlm_decode_fh(p, &lock->fh))
  258. || !(p = nlm_decode_oh(p, &lock->oh)))
  259. return 0;
  260. argp->fsm_mode = ntohl(*p++);
  261. argp->fsm_access = ntohl(*p++);
  262. return xdr_argsize_check(rqstp, p);
  263. }
  264. int
  265. nlmsvc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
  266. {
  267. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  268. return 0;
  269. *p++ = resp->status;
  270. *p++ = xdr_zero; /* sequence argument */
  271. return xdr_ressize_check(rqstp, p);
  272. }
  273. int
  274. nlmsvc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
  275. {
  276. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  277. return 0;
  278. *p++ = resp->status;
  279. return xdr_ressize_check(rqstp, p);
  280. }
  281. int
  282. nlmsvc_decode_notify(struct svc_rqst *rqstp, u32 *p, struct nlm_args *argp)
  283. {
  284. struct nlm_lock *lock = &argp->lock;
  285. if (!(p = xdr_decode_string_inplace(p, &lock->caller,
  286. &lock->len, NLM_MAXSTRLEN)))
  287. return 0;
  288. argp->state = ntohl(*p++);
  289. return xdr_argsize_check(rqstp, p);
  290. }
  291. int
  292. nlmsvc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp)
  293. {
  294. if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
  295. return 0;
  296. argp->state = ntohl(*p++);
  297. /* Preserve the address in network byte order */
  298. argp->addr = *p++;
  299. argp->vers = *p++;
  300. argp->proto = *p++;
  301. return xdr_argsize_check(rqstp, p);
  302. }
  303. int
  304. nlmsvc_decode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp)
  305. {
  306. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  307. return 0;
  308. resp->status = ntohl(*p++);
  309. return xdr_argsize_check(rqstp, p);
  310. }
  311. int
  312. nlmsvc_decode_void(struct svc_rqst *rqstp, u32 *p, void *dummy)
  313. {
  314. return xdr_argsize_check(rqstp, p);
  315. }
  316. int
  317. nlmsvc_encode_void(struct svc_rqst *rqstp, u32 *p, void *dummy)
  318. {
  319. return xdr_ressize_check(rqstp, p);
  320. }
  321. /*
  322. * Now, the client side XDR functions
  323. */
  324. #ifdef NLMCLNT_SUPPORT_SHARES
  325. static int
  326. nlmclt_decode_void(struct rpc_rqst *req, u32 *p, void *ptr)
  327. {
  328. return 0;
  329. }
  330. #endif
  331. static int
  332. nlmclt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
  333. {
  334. struct nlm_lock *lock = &argp->lock;
  335. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  336. return -EIO;
  337. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  338. if (!(p = nlm_encode_lock(p, lock)))
  339. return -EIO;
  340. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  341. return 0;
  342. }
  343. static int
  344. nlmclt_decode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
  345. {
  346. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  347. return -EIO;
  348. resp->status = ntohl(*p++);
  349. if (resp->status == NLM_LCK_DENIED) {
  350. struct file_lock *fl = &resp->lock.fl;
  351. u32 excl;
  352. s32 start, len, end;
  353. memset(&resp->lock, 0, sizeof(resp->lock));
  354. locks_init_lock(fl);
  355. excl = ntohl(*p++);
  356. fl->fl_pid = ntohl(*p++);
  357. if (!(p = nlm_decode_oh(p, &resp->lock.oh)))
  358. return -EIO;
  359. fl->fl_flags = FL_POSIX;
  360. fl->fl_type = excl? F_WRLCK : F_RDLCK;
  361. start = ntohl(*p++);
  362. len = ntohl(*p++);
  363. end = start + len - 1;
  364. fl->fl_start = s32_to_loff_t(start);
  365. if (len == 0 || end < 0)
  366. fl->fl_end = OFFSET_MAX;
  367. else
  368. fl->fl_end = s32_to_loff_t(end);
  369. }
  370. return 0;
  371. }
  372. static int
  373. nlmclt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
  374. {
  375. struct nlm_lock *lock = &argp->lock;
  376. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  377. return -EIO;
  378. *p++ = argp->block? xdr_one : xdr_zero;
  379. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  380. if (!(p = nlm_encode_lock(p, lock)))
  381. return -EIO;
  382. *p++ = argp->reclaim? xdr_one : xdr_zero;
  383. *p++ = htonl(argp->state);
  384. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  385. return 0;
  386. }
  387. static int
  388. nlmclt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
  389. {
  390. struct nlm_lock *lock = &argp->lock;
  391. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  392. return -EIO;
  393. *p++ = argp->block? xdr_one : xdr_zero;
  394. *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero;
  395. if (!(p = nlm_encode_lock(p, lock)))
  396. return -EIO;
  397. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  398. return 0;
  399. }
  400. static int
  401. nlmclt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp)
  402. {
  403. struct nlm_lock *lock = &argp->lock;
  404. if (!(p = nlm_encode_cookie(p, &argp->cookie)))
  405. return -EIO;
  406. if (!(p = nlm_encode_lock(p, lock)))
  407. return -EIO;
  408. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  409. return 0;
  410. }
  411. static int
  412. nlmclt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
  413. {
  414. if (!(p = nlm_encode_cookie(p, &resp->cookie)))
  415. return -EIO;
  416. *p++ = resp->status;
  417. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  418. return 0;
  419. }
  420. static int
  421. nlmclt_encode_testres(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
  422. {
  423. if (!(p = nlm_encode_testres(p, resp)))
  424. return -EIO;
  425. req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
  426. return 0;
  427. }
  428. static int
  429. nlmclt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp)
  430. {
  431. if (!(p = nlm_decode_cookie(p, &resp->cookie)))
  432. return -EIO;
  433. resp->status = ntohl(*p++);
  434. return 0;
  435. }
  436. /*
  437. * Buffer requirements for NLM
  438. */
  439. #define NLM_void_sz 0
  440. #define NLM_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN)
  441. #define NLM_caller_sz 1+XDR_QUADLEN(sizeof(system_utsname.nodename))
  442. #define NLM_netobj_sz 1+XDR_QUADLEN(XDR_MAX_NETOBJ)
  443. /* #define NLM_owner_sz 1+XDR_QUADLEN(NLM_MAXOWNER) */
  444. #define NLM_fhandle_sz 1+XDR_QUADLEN(NFS2_FHSIZE)
  445. #define NLM_lock_sz 3+NLM_caller_sz+NLM_netobj_sz+NLM_fhandle_sz
  446. #define NLM_holder_sz 4+NLM_netobj_sz
  447. #define NLM_testargs_sz NLM_cookie_sz+1+NLM_lock_sz
  448. #define NLM_lockargs_sz NLM_cookie_sz+4+NLM_lock_sz
  449. #define NLM_cancargs_sz NLM_cookie_sz+2+NLM_lock_sz
  450. #define NLM_unlockargs_sz NLM_cookie_sz+NLM_lock_sz
  451. #define NLM_testres_sz NLM_cookie_sz+1+NLM_holder_sz
  452. #define NLM_res_sz NLM_cookie_sz+1
  453. #define NLM_norep_sz 0
  454. #ifndef MAX
  455. # define MAX(a, b) (((a) > (b))? (a) : (b))
  456. #endif
  457. /*
  458. * For NLM, a void procedure really returns nothing
  459. */
  460. #define nlmclt_decode_norep NULL
  461. #define PROC(proc, argtype, restype) \
  462. [NLMPROC_##proc] = { \
  463. .p_proc = NLMPROC_##proc, \
  464. .p_encode = (kxdrproc_t) nlmclt_encode_##argtype, \
  465. .p_decode = (kxdrproc_t) nlmclt_decode_##restype, \
  466. .p_bufsiz = MAX(NLM_##argtype##_sz, NLM_##restype##_sz) << 2 \
  467. }
  468. static struct rpc_procinfo nlm_procedures[] = {
  469. PROC(TEST, testargs, testres),
  470. PROC(LOCK, lockargs, res),
  471. PROC(CANCEL, cancargs, res),
  472. PROC(UNLOCK, unlockargs, res),
  473. PROC(GRANTED, testargs, res),
  474. PROC(TEST_MSG, testargs, norep),
  475. PROC(LOCK_MSG, lockargs, norep),
  476. PROC(CANCEL_MSG, cancargs, norep),
  477. PROC(UNLOCK_MSG, unlockargs, norep),
  478. PROC(GRANTED_MSG, testargs, norep),
  479. PROC(TEST_RES, testres, norep),
  480. PROC(LOCK_RES, res, norep),
  481. PROC(CANCEL_RES, res, norep),
  482. PROC(UNLOCK_RES, res, norep),
  483. PROC(GRANTED_RES, res, norep),
  484. #ifdef NLMCLNT_SUPPORT_SHARES
  485. PROC(SHARE, shareargs, shareres),
  486. PROC(UNSHARE, shareargs, shareres),
  487. PROC(NM_LOCK, lockargs, res),
  488. PROC(FREE_ALL, notify, void),
  489. #endif
  490. };
  491. static struct rpc_version nlm_version1 = {
  492. .number = 1,
  493. .nrprocs = 16,
  494. .procs = nlm_procedures,
  495. };
  496. static struct rpc_version nlm_version3 = {
  497. .number = 3,
  498. .nrprocs = 24,
  499. .procs = nlm_procedures,
  500. };
  501. #ifdef CONFIG_LOCKD_V4
  502. extern struct rpc_version nlm_version4;
  503. #endif
  504. static struct rpc_version * nlm_versions[] = {
  505. [1] = &nlm_version1,
  506. [3] = &nlm_version3,
  507. #ifdef CONFIG_LOCKD_V4
  508. [4] = &nlm_version4,
  509. #endif
  510. };
  511. static struct rpc_stat nlm_stats;
  512. struct rpc_program nlm_program = {
  513. .name = "lockd",
  514. .number = NLM_PROGRAM,
  515. .nrvers = sizeof(nlm_versions) / sizeof(nlm_versions[0]),
  516. .version = nlm_versions,
  517. .stats = &nlm_stats,
  518. };
  519. #ifdef RPC_DEBUG
  520. const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
  521. {
  522. /*
  523. * We can get away with a static buffer because we're only
  524. * called with BKL held.
  525. */
  526. static char buf[2*NLM_MAXCOOKIELEN+1];
  527. int i;
  528. int len = sizeof(buf);
  529. char *p = buf;
  530. len--; /* allow for trailing \0 */
  531. if (len < 3)
  532. return "???";
  533. for (i = 0 ; i < cookie->len ; i++) {
  534. if (len < 2) {
  535. strcpy(p-3, "...");
  536. break;
  537. }
  538. sprintf(p, "%02x", cookie->data[i]);
  539. p += 2;
  540. len -= 2;
  541. }
  542. *p = '\0';
  543. return buf;
  544. }
  545. #endif