|
|
/home/brennan/Software/sensix/source/C^4/corba/gov/lanl/isr/sensix/discovery/DiscoverMessage.javaGo to the documentation of this file.00001 00010 /* 00011 * Copyright 2008. Los Alamos National Security, LLC. This material 00012 * was produced under U.S. Government contract DE-AC52-06NA25396 for 00013 * Los Alamos National Laboratory (LANL), which is operated by Los 00014 * Alamos National Security, LLC, for the Department of Energy. The 00015 * U.S. Government has rights to use, reproduce, and distribute this 00016 * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, 00017 * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL 00018 * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to 00019 * produce derivative works, such modified software should be clearly 00020 * marked, so as not to confuse it with the version available from LANL. 00021 * 00022 * Additionally, this program is free software; you can redistribute 00023 * it and/or modify it under the terms of the GNU General Public 00024 * License as published by the Free Software Foundation; version 2 of 00025 * the License. Accordingly, this program is distributed in the hope 00026 * it will be useful, but WITHOUT ANY WARRANTY; without even the 00027 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00028 * PURPOSE. See the GNU General Public License for more details. 00029 * 00030 * You should have received a copy of the GNU General Public License 00031 * along with this program; if not, write to the Free Software 00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00033 */ 00034 00035 package gov.lanl.isr.sensix.discovery; 00036 00037 public class DiscoverMessage 00038 { 00039 public int nodeIdent; 00040 public byte hLevel; 00041 public byte cType; 00042 public String ior; 00043 public int targetIdent; 00044 00045 public DiscoverMessage(DiscoverMessageHeader hdr, byte[] bytes) 00046 throws DiscoverMessageException { 00047 nodeIdent = 0; 00048 hLevel = 0; 00049 cType = 0; 00050 ior = null; 00051 targetIdent = 0; 00052 00053 switch (hdr.announceType) { 00054 case 1: 00055 if (hdr.announceSize < 5) 00056 throw new DiscoverMessageException("Incomplete message"); 00057 00058 if (hdr.little_endian) 00059 nodeIdent = DiscoveryService.b2i_le(bytes); 00060 else 00061 nodeIdent = DiscoveryService.b2i(bytes); 00062 hLevel = bytes[4]; 00063 break; 00064 case 2: 00065 if (hdr.announceSize < 6) 00066 throw new DiscoverMessageException("Incomplete message"); 00067 00068 if (hdr.little_endian) 00069 nodeIdent = DiscoveryService.b2i_le(bytes); 00070 else 00071 nodeIdent = DiscoveryService.b2i(bytes); 00072 hLevel = bytes[4]; 00073 cType = bytes[5]; 00074 break; 00075 case 3: 00076 if (hdr.announceSize < 10) 00077 throw new DiscoverMessageException("Incomplete message"); 00078 00079 if (hdr.little_endian) 00080 nodeIdent = DiscoveryService.b2i_le(bytes); 00081 else 00082 nodeIdent = DiscoveryService.b2i(bytes); 00083 hLevel = bytes[4]; 00084 cType = bytes[5]; 00085 00086 byte[] target = new byte[4]; 00087 System.arraycopy(bytes, 6, target, 0, target.length); 00088 if (hdr.little_endian) 00089 targetIdent = DiscoveryService.b2i_le(target); 00090 else 00091 targetIdent = DiscoveryService.b2i(target); 00092 00093 break; 00094 case 4: 00095 if (hdr.announceSize < 7) 00096 throw new DiscoverMessageException("Incomplete message"); 00097 00098 if (hdr.little_endian) 00099 nodeIdent = DiscoveryService.b2i_le(bytes); 00100 else 00101 nodeIdent = DiscoveryService.b2i(bytes); 00102 hLevel = bytes[4]; 00103 cType = bytes[5]; 00104 00105 byte[] ior_bytes = new byte[hdr.announceSize - 6]; 00106 System.arraycopy(bytes, 6, ior_bytes, 0, ior_bytes.length); 00107 ior = new String(ior_bytes); 00108 break; 00109 default: 00110 throw new DiscoverMessageException("Unsupported announcement type"); 00111 } 00112 } 00113 } 00114 |