1 17 package org.alfresco.filesys.smb.dcerpc.info; 18 19 import org.alfresco.filesys.smb.dcerpc.DCEBuffer; 20 import org.alfresco.filesys.smb.dcerpc.DCEBufferException; 21 import org.alfresco.filesys.smb.dcerpc.DCEReadable; 22 23 28 public class ConnectionInfo implements DCEReadable 29 { 30 31 33 private int m_infoLevel; 34 35 37 private int m_connId; 38 private int m_connType; 39 40 42 private int m_openFiles; 43 44 46 private int m_numUsers; 47 48 50 private int m_connTime; 51 52 54 private String m_userName; 55 56 58 private String m_clientName; 59 60 63 public ConnectionInfo() 64 { 65 } 66 67 72 public ConnectionInfo(int infoLevel) 73 { 74 m_infoLevel = infoLevel; 75 } 76 77 82 public final int getInformationLevel() 83 { 84 return m_infoLevel; 85 } 86 87 92 public final int getConnectionId() 93 { 94 return m_connId; 95 } 96 97 102 public final int getConnectionType() 103 { 104 return m_connType; 105 } 106 107 112 public final int getOpenFileCount() 113 { 114 return m_openFiles; 115 } 116 117 122 public final int getNumberOfUsers() 123 { 124 return m_numUsers; 125 } 126 127 132 public final int getConnectionTime() 133 { 134 return m_connTime; 135 } 136 137 142 public final String getUserName() 143 { 144 return m_userName; 145 } 146 147 152 public final String getClientName() 153 { 154 return m_clientName; 155 } 156 157 163 public void readObject(DCEBuffer buf) throws DCEBufferException 164 { 165 166 168 switch (getInformationLevel()) 169 { 170 171 173 case 0: 174 m_connId = buf.getInt(); 175 m_userName = null; 176 m_clientName = null; 177 break; 178 179 181 case 1: 182 m_connId = buf.getInt(); 183 m_connType = buf.getInt(); 184 m_openFiles = buf.getInt(); 185 m_numUsers = buf.getInt(); 186 m_connTime = buf.getInt(); 187 188 m_userName = buf.getPointer() != 0 ? "" : null; 189 m_clientName = buf.getPointer() != 0 ? "" : null; 190 break; 191 } 192 } 193 194 200 public void readStrings(DCEBuffer buf) throws DCEBufferException 201 { 202 203 205 switch (getInformationLevel()) 206 { 207 208 210 case 1: 211 if (getUserName() != null) 212 m_userName = buf.getString(DCEBuffer.ALIGN_INT); 213 if (getClientName() != null) 214 m_clientName = buf.getString(DCEBuffer.ALIGN_INT); 215 break; 216 } 217 } 218 219 224 public String toString() 225 { 226 StringBuffer str = new StringBuffer (); 227 228 str.append("[ID="); 229 str.append(getConnectionId()); 230 str.append(":Level="); 231 str.append(getInformationLevel()); 232 str.append(":"); 233 234 if (getInformationLevel() == 1) 235 { 236 str.append("Type="); 237 str.append(getConnectionType()); 238 str.append(",OpenFiles="); 239 str.append(getOpenFileCount()); 240 str.append(",NumUsers="); 241 str.append(getNumberOfUsers()); 242 str.append(",Connected="); 243 str.append(getConnectionTime()); 244 str.append(",User="); 245 str.append(getUserName()); 246 str.append(",Client="); 247 str.append(getClientName()); 248 } 249 250 str.append("]"); 251 return str.toString(); 252 } 253 } 254 | Popular Tags |