smbbrowse.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "headers.h"
  10. int
  11. smbmailslotsend(NbDgramSendParameters *p, SmbBuffer *msg, char **errmsgp)
  12. {
  13. uint16_t setup[3];
  14. int rv;
  15. SmbTransaction transaction;
  16. SmbBuffer *b;
  17. SmbHeader h;
  18. setup[0] = 1;
  19. setup[1] = 0;
  20. setup[2] = 0;
  21. memset(&transaction, 0, sizeof(transaction));
  22. transaction.in.name = smbglobals.mailslotbrowse;
  23. transaction.in.scount = 3;
  24. transaction.in.setup = setup;
  25. transaction.in.tdcount = smbbufferreadspace(msg);
  26. transaction.in.data = smbbufferreadpointer(msg);
  27. b = smbbuffernew(NbDgramMaxLen);
  28. memset(&h, 0, sizeof(h));
  29. rv = smbtransactionexecute(&transaction, &h, nil, b, &smbtransactionmethoddgram, p, nil, errmsgp);
  30. smbbufferfree(&b);
  31. return rv;
  32. }
  33. int
  34. smbbrowsesendhostannouncement(char *name, uint32_t periodms, uint32_t type,
  35. char *comment, char **errmsgp)
  36. {
  37. NbDgramSendParameters p;
  38. SmbBuffer *b;
  39. int rv;
  40. // NbName msbrowse;
  41. // msbrowse[0] = 1;
  42. // msbrowse[1] = 2;
  43. // memcpy(msbrowse + 2, "__MSBROWSE__", 12);
  44. // msbrowse[14] = 2;
  45. // msbrowse[15] = 1;
  46. // nbnamecpy(p.to, msbrowse);
  47. nbmknamefromstringandtype(p.to, smbglobals.primarydomain, 0x1d);
  48. p.type = NbDgramDirectUnique;
  49. b = smbbuffernew(NbDgramMaxLen);
  50. smbbufferputb(b, 1);
  51. smbbufferputb(b, 0);
  52. smbbufferputl(b, periodms);
  53. smbbufferputstrn(b, name, 16, 1);
  54. smbbufferputb(b, 4);
  55. smbbufferputb(b, 0);
  56. smbbufferputl(b, type);
  57. smbbufferputl(b, 0xaa55011f);
  58. smbbufferputstring(b, nil, 0, comment);
  59. rv = smbmailslotsend(&p, b, errmsgp);
  60. smbbufferfree(&b);
  61. return rv;
  62. }