1 17 package org.alfresco.filesys.smb.mailslot; 18 19 import org.alfresco.filesys.util.DataPacker; 20 21 24 public final class MailSlot 25 { 26 27 29 public static final int WRITE = 0x01; 30 31 33 public static final int UNRELIABLE = 0x02; 34 35 37 public static final int HostAnnounce = 1; 38 public static final int AnnouncementRequest = 2; 39 public static final int RequestElection = 8; 40 public static final int GetBackupListReq = 9; 41 public static final int GetBackupListResp = 10; 42 public static final int BecomeBackup = 11; 43 public static final int DomainAnnouncement = 12; 44 public static final int MasterAnnouncement = 13; 45 public static final int LocalMasterAnnouncement = 15; 46 47 59 public final static int createHostAnnouncement(byte[] buf, int off, String host, String comment, int typ, 60 int interval, int upd) 61 { 62 63 65 buf[off] = MailSlot.HostAnnounce; 66 buf[off + 1] = 0; 68 70 DataPacker.putIntelInt(interval * 60000, buf, off + 2); 71 72 74 byte[] hostByt = host.getBytes(); 75 for (int i = 0; i < 16; i++) 76 { 77 if (i < hostByt.length) 78 buf[off + 6 + i] = hostByt[i]; 79 else 80 buf[off + 6 + i] = 0; 81 } 82 83 85 buf[off + 22] = 5; buf[off + 23] = 1; 88 90 DataPacker.putIntelInt(typ, buf, off + 24); 91 92 94 DataPacker.putIntelShort(0x010F, buf, off + 28); 95 DataPacker.putIntelShort(0xAA55, buf, off + 30); 96 97 99 int pos = off + 33; 100 101 if (comment != null) 102 pos = DataPacker.putString(comment, buf, off + 32, true); 103 104 106 return pos; 107 } 108 109 117 public final static int createAnnouncementRequest(byte[] buf, int off, String host) 118 { 119 120 122 buf[off] = MailSlot.AnnouncementRequest; 123 buf[off + 1] = 0; 124 125 127 byte[] hostByt = host.getBytes(); 128 for (int i = 0; i < 16; i++) 129 { 130 if (i < hostByt.length) 131 buf[off + 2 + i] = hostByt[i]; 132 else 133 buf[off + 2 + i] = 0; 134 } 135 136 138 return off + 17; 139 } 140 } | Popular Tags |