116. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:03 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

116.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\snmp SnmpEngineId.java Mon Jan 22 14:46:50 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\snmp SnmpEngineId.java Wed Sep 12 16:26:22 2018 UTC

116.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 976
Changed 1 2
Inserted 0 0
Removed 0 0

116.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

116.4 Active regular expressions

No regular expressions were active.

116.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 200 1, 2006, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25   package co m.sun.jmx. snmp;
  26  
  27   import jav a.net.Inet Address;
  28   import jav a.io.Seria lizable;
  29   import jav a.net.Unkn ownHostExc eption;
  30   import jav a.util.Str ingTokeniz er;
  31   import jav a.util.Arr ays;
  32   import jav a.util.NoS uchElement Exception;
  33  
  34   import com .sun.jmx.s nmp.intern al.SnmpToo ls;
  35  
  36   /**
  37    * This cl ass is han dling an < CODE>SnmpE ngineId</C ODE> data.  It copes  with binar y as well  as <CODE>S tring</COD E> represe ntation of  an engine  Id. A str ing format  engine is  an hex st ring start ing with 0 x.
  38    * <p><b>T his API is  a Sun Mic rosystems  internal A PI  and is  subject
  39    * to chan ge without  notice.</ b></p>
  40    * @since  1.5
  41    */
  42   public cla ss SnmpEng ineId impl ements Ser ializable  {
  43       privat e static f inal long  serialVers ionUID = 5 4347296558 30763317L;
  44  
  45       byte[]  engineId  = null;
  46       String  hexString  = null;
  47       String  humanStri ng = null;
  48       /**
  49        * New  <CODE>Snm pEngineId< /CODE> wit h an hex s tring valu e. Can han dle engine  Id format  &lt;host& gt:&lt;por t&gt.
  50        * @pa ram hexStr ing Hexa s tring.
  51        */
  52       SnmpEn gineId(Str ing hexStr ing) {
  53           en gineId = S nmpTools.a scii2binar y(hexStrin g);
  54           th is.hexStri ng = hexSt ring.toLow erCase();
  55       }
  56       /**
  57        * New  <CODE>Snm pEngineId< /CODE> wit h a binary  value. Yo u can use  <CODE> Snm pTools </C ODE> to co nvert from  hex strin g to binar y format.
  58        * @pa ram bin Bi nary value
  59        */
  60       SnmpEn gineId(byt e[] bin) {
  61           en gineId = b in;
  62           he xString =  SnmpTools. binary2asc ii(bin).to LowerCase( );
  63       }
  64  
  65       /**
  66        * If  a string o f the form at &lt;add ress&gt;:& lt;port&gt ;:&lt;IANA  number&gt ; has been  provided  at creatio n time, th is string  is returne d.
  67        * @re turn The I d as a rea dable stri ng or null  if not pr ovided.
  68        */
  69       public  String ge tReadableI d() {
  70           re turn human String;
  71       }
  72  
  73       /**
  74        * Ret urns a str ing format  engine Id .
  75        * @re turn Strin g format v alue.
  76        */
  77       public  String to String() {
  78           re turn hexSt ring;
  79       }
  80       /**
  81        * Ret urns a bin ary engine  Id.
  82        * @re turn Binar y value.
  83        */
  84       public  byte[] ge tBytes() {
  85           re turn engin eId;
  86       }
  87  
  88       /**
  89        * In  order to s tore the s tring used  to create  the engin eId.
  90        */
  91       void s etStringVa lue(String  val) {
  92           hu manString  = val;
  93       }
  94  
  95       static  void vali dateId(Str ing str) t hrows Ille galArgumen tException  {
  96           by te[] arr =  SnmpTools .ascii2bin ary(str);
  97           va lidateId(a rr);
  98       }
  99  
  100       static  void vali dateId(byt e[] arr) t hrows Ille galArgumen tException  {
  101  
  102           if (arr.lengt h < 5) thr ow new Ill egalArgume ntExceptio n("Id size  lower tha n 5 bytes. ");
  103           if (arr.lengt h > 32) th row new Il legalArgum entExcepti on("Id siz e greater  than 32 by tes.");
  104  
  105           // octet stri ngs with v ery first  bit = 0 an d length ! = 12 octet s
  106           if ( ((arr[0]  & 0x80) = = 0) && ar r.length ! = 12)
  107                throw ne w IllegalA rgumentExc eption("Ve ry first b it = 0 and  length !=  12 octets ");
  108  
  109           by te[] zeroe dArrays =  new byte[a rr.length] ;
  110           if (Arrays.eq uals(zeroe dArrays, a rr)) throw  new Illeg alArgument Exception( "Zeroed Id .");
  111           by te[] FFArr ays = new  byte[arr.l ength];
  112           Ar rays.fill( FFArrays,  (byte)0xFF );
  113           if (Arrays.eq uals(FFArr ays, arr))  throw new  IllegalAr gumentExce ption("0xF F Id.");
  114  
  115       }
  116  
  117       /**
  118        * Gen erates an  engine Id  based on t he passed  array.
  119        * @re turn The c reated eng ine Id or  null if gi ven arr is  null or i ts length  == 0;
  120        * @ex ception Il legalArgum entExcepti on when:
  121        * <ul >
  122        *  <l i>octet st ring lower  than 5 by tes.</li>
  123        *  <l i>octet st ring great er than 32  bytes.</l i>
  124        *  <l i>octet st ring = all  zeros.</l i>
  125        *  <l i>octet st ring = all  'ff'H.</l i>
  126        *  <l i>octet st rings with  very firs t bit = 0  and length  != 12 oct ets</li>
  127        * </u l>
  128        */
  129       public  static Sn mpEngineId  createEng ineId(byte [] arr) th rows Illeg alArgument Exception  {
  130           if ( (arr ==  null) || a rr.length  == 0) retu rn null;
  131           va lidateId(a rr);
  132           re turn new S nmpEngineI d(arr);
  133       }
  134  
  135       /**
  136        * Gen erates an  engine Id  that is un ique to th e host the  agent is  running on . The engi ne Id unic ity is sys tem time b ased. The  creation a lgorithm u ses the SU N Microsys tems IANA  number (42 ).
  137        * @re turn The g enerated e ngine Id.
  138        */
  139       public  static Sn mpEngineId  createEng ineId() {
  140           by te[] addre ss = null;
  141           by te[] engin eid = new  byte[13];
  142           in t iana = 4 2;
  143           lo ng mask =  0xFF;
  144           lo ng time =  System.cur rentTimeMi llis();
  145  
  146           en gineid[0]  = (byte) (  (iana & 0 xFF000000)  >> 24 );
  147           en gineid[0]  |= 0x80;
  148           en gineid[1]  = (byte) (  (iana & 0 x00FF0000)  >> 16 );
  149           en gineid[2]  = (byte) (  (iana & 0 x0000FF00)  >> 8 );
  150           en gineid[3]  = (byte) ( iana & 0x0 00000FF);
  151           en gineid[4]  = 0x05;
  152  
  153           en gineid[5]  =  (byte)  ( (time &  (mask << 5 6)) >>> 56  );
  154           en gineid[6]  =  (byte)  ( (time &  (mask << 4 8) ) >>> 4 8 );
  155           en gineid[7]  =  (byte)  ( (time &  (mask << 4 0) ) >>> 4 0 );
  156           en gineid[8]  =  (byte)  ( (time &  (mask << 3 2) ) >>> 3 2 );
  157           en gineid[9]  =  (byte)  ( (time &  (mask << 2 4) ) >>> 2 4 );
  158           en gineid[10]  = (byte)  ( (time &  (mask << 1 6) ) >>> 1 6 );
  159           en gineid[11]  = (byte)  ( (time &  (mask << 8 ) ) >>> 8  );
  160           en gineid[12]  = (byte)  (time & ma sk);
  161  
  162           re turn new S nmpEngineI d(engineid );
  163       }
  164  
  165       /**
  166        * Tra nslates an  engine Id  in an Snm pOid forma t. This is  useful wh en dealing  with USM  MIB indexe s.
  167        * The  oid forma t is : <en gine Id le ngth>.<eng ine Id bin ary octet1 >....<engi ne Id bina ry octetn  - 1>.<engi ne Id bina ry octetn>
  168        * Eg:  "0x800000 2a05819dcb 6e00001f96 " ==> 13.1 28.0.0.42. 5.129.157. 203.110.0. 0.31.150
  169        *
  170        * @re turn SnmpO id The oid .
  171        */
  172       public  SnmpOid t oOid() {
  173           lo ng[] oid =  new long[ engineId.l ength + 1] ;
  174           oi d[0] = eng ineId.leng th;
  175           fo r(int i =  1; i <= en gineId.len gth; i++)
  176                oid[i] =  (long) (e ngineId[i- 1] & 0xFF) ;
  177           re turn new S nmpOid(oid );
  178       }
  179  
  180      /**
  181       * <P>G enerates a  unique en gine Id. H exadecimal  strings a s well as  a textual  descriptio n are supp orted. The  textual f ormat is a s follow:
  182       * <BR>   &lt;addr ess&gt;:&l t;port&gt; :&lt;IANA  number&gt; </P>
  183       * <P>T he allowed  formats : </P>
  184       * <ul>
  185       * <li>  &lt;addre ss&gt;:&lt ;port&gt;: &lt;IANA n umber&gt
  186       * <BR>    All the se paramet ers are us ed to gene rate the I d. WARNING , this met hod is not  compliant  with IPv6  address f ormat. Use  { @link c om.sun.jmx .snmp.Snmp EngineId#c reateEngin eId(java.l ang.String ,java.lang .String) }  instead.< /li>
  187       * <li>  &lt;addre ss&gt;:&lt ;port&gt;
  188       * <BR>    The IAN A number w ill be the  SUN Micro systems on e (42). </ li>
  189       * <li>  address
  190       * <BR>    The por t 161 will  be used t o generate  the Id. I ANA number  will be t he SUN Mic rosystems  one (42).  </li>
  191       * <li>  :port
  192       * <BR>    The hos t to use i s localhos t. IANA nu mber will  be the SUN  Microsyst ems one (4 2). </li>
  193       * <li>  ::&lt;IAN A number&g t &nbsp;&n bsp;&nbsp;
  194       * <BR>    The por t 161 and  localhost  will be us ed to gene rate the I d. </li>
  195       * <li>  :&lt;port &gt;:&lt;I ANA number &gt;
  196       * <BR>    The hos t to use i s localhos t. </li>
  197       * <li>  &lt;addre ss&gt;::&l t;IANA num ber&gt
  198       * <BR>    The por t 161 will  be used t o generate  the Id. < /li>
  199       * <li>  :: &nbsp; &nbsp;&nbs p;
  200       * <BR>    The por t 161, loc alhost and  the SUN M icrosystem s IANA num ber will b e used to  generate t he Id. </l i>
  201       * </ul >
  202       * @exc eption Unk nownHostEx ception if  the host  name conta ined in th e textual  format is  unknown.
  203       * @exc eption Ill egalArgume ntExceptio n when :
  204       * <ul>
  205       *  <li >octet str ing lower  than 5 byt es.</li>
  206       *  <li >octet str ing greate r than 32  bytes.</li >
  207       *  <li >octet str ing = all  zeros.</li >
  208       *  <li >octet str ing = all  'ff'H.</li >
  209       *  <li >octet str ings with  very first  bit = 0 a nd length  != 12 octe ts</li>
  210       *  <li >An IPv6 a ddress for mat is use d in conjo nction wit h the ":"  separator< /li>
  211       * </ul >
  212       * @par am str The  string to  parse.
  213       * @ret urn The ge nerated en gine Id or  null if t he passed  string is  null.
  214       *
  215       */
  216       public  static Sn mpEngineId  createEng ineId(Stri ng str)
  217           th rows Illeg alArgument Exception,  UnknownHo stExceptio n {
  218           re turn creat eEngineId( str, null) ;
  219       }
  220  
  221       /**
  222        * Ide m { @link
  223        * com .sun.jmx.s nmp.SnmpEn gineId#cre ateEngineI d(java.lan g.String)  }
  224        * wit h the abil ity to pro vide your  own separa tor. This  allows IPv 6
  225        * add ress forma t handling  (eg: prov iding @ as  separator ).
  226        * @pa ram str Th e string t o parse.
  227        * @pa ram separa tor the se parator to  use. If n ull is pro vided, the  default
  228        * sep arator ":"  is used.
  229        * @re turn The g enerated e ngine Id o r null if  the passed  string is  null.
  230        * @ex ception Un knownHostE xception i f the host  name cont ained in t he
  231        * tex tual forma t is unkno wn.
  232        * @ex ception Il legalArgum entExcepti on when :
  233        * <ul >
  234        *  <l i>octet st ring lower  than 5 by tes.</li>
  235        *  <l i>octet st ring great er than 32  bytes.</l i>
  236        *  <l i>octet st ring = all  zeros.</l i>
  237        *  <l i>octet st ring = all  'ff'H.</l i>
  238        *  <l i>octet st rings with  very firs t bit = 0  and length  != 12 oct ets</li>
  239        *  <l i>An IPv6  address fo rmat is us ed in conj onction wi th the ":"
  240        *       separato r</li>
  241        * </u l>
  242        * @si nce 1.5
  243        */
  244       public  static Sn mpEngineId  createEng ineId(Stri ng str, St ring separ ator)
  245           th rows Illeg alArgument Exception,  UnknownHo stExceptio n {
  246           if (str == nu ll) return  null;
  247  
  248           if (str.start sWith("0x" ) || str.s tartsWith( "0X")) {
  249                validate Id(str);
  250                return n ew SnmpEng ineId(str) ;
  251           }
  252           se parator =  separator  == null ?  ":" : sepa rator;
  253           St ringTokeni zer token  = new Stri ngTokenize r(str,
  254                                                            separato r,
  255                                                            true);
  256  
  257           St ring addre ss = null;
  258           St ring port  = null;
  259           St ring iana  = null;
  260             int objP ORT        
;
  261           in t objIana  = 42;
  262           In etAddress  objAddress  = null;
  263           Sn mpEngineId  eng = nul l;
  264           tr y {
  265                //Deal w ith addres s
  266                try {
  267                    addr ess = toke n.nextToke n();
  268                }catch(N oSuchEleme ntExceptio n e) {
  269                    thro w new Ille galArgumen tException ("Passed s tring is i nvalid : [ "+str+"]") ;
  270                }
  271                if(!addr ess.equals (separator )) {
  272                    objA ddress = I netAddress .getByName (address);
  273                    try  {
  274                         token.next Token();
  275                    }cat ch(NoSuchE lementExce ption e) {
  276                         //No need  to go furt her, no po rt.
  277                         eng = Snmp EngineId.c reateEngin eId(objAdd ress,
  278                                                              objPor t,
  279                                                              objIan a);
  280                         eng.setStr ingValue(s tr);
  281                         return eng ;
  282                    }
  283                }
  284                else
  285                    objA ddress = I netAddress .getLocalH ost();
  286  
  287                //Deal w ith port
  288                try {
  289                    port  = token.n extToken() ;
  290                }catch(N oSuchEleme ntExceptio n e) {
  291                    //No  need to g o further,  no port.
  292                    eng  = SnmpEngi neId.creat eEngineId( objAddress ,
  293                                                          objPort,
  294                                                          objIana);
  295                    eng. setStringV alue(str);
  296                    retu rn eng;
  297                }
  298  
  299                if(!port .equals(se parator))  {
  300                    objP ort = Inte ger.parseI nt(port);
  301                    try  {
  302                         token.next Token();
  303                    }cat ch(NoSuchE lementExce ption e) {
  304                         //No need  to go furt her, no ia na.
  305                         eng = Snmp EngineId.c reateEngin eId(objAdd ress,
  306                                                              objPor t,
  307                                                              objIan a);
  308                         eng.setStr ingValue(s tr);
  309                         return eng ;
  310                    }
  311                }
  312  
  313                //Deal w ith iana
  314                try {
  315                    iana  = token.n extToken() ;
  316                }catch(N oSuchEleme ntExceptio n e) {
  317                    //No  need to g o further,  no port.
  318                    eng  = SnmpEngi neId.creat eEngineId( objAddress ,
  319                                                          objPort,
  320                                                          objIana);
  321                    eng. setStringV alue(str);
  322                    retu rn eng;
  323                }
  324  
  325                if(!iana .equals(se parator))
  326                    objI ana = Inte ger.parseI nt(iana);
  327  
  328                eng = Sn mpEngineId .createEng ineId(objA ddress,
  329                                                     objP ort,
  330                                                     objI ana);
  331                eng.setS tringValue (str);
  332  
  333                return e ng;
  334  
  335           }  catch(Exce ption e) {
  336                throw ne w IllegalA rgumentExc eption("Pa ssed strin g is inval id : ["+st r+"]. Chec k that the  used sepa rator ["+  separator  + "] is co mpatible w ith IPv6 a ddress for mat.");
  337           }
  338  
  339       }
  340  
  341       /**
  342        * Gen erates a u nique engi ne Id. The  engine Id  unicity i s based on
  343        * the  host IP a ddress and  port. The  IP addres s used is  the
  344        * loc alhost one . The crea tion algor ithm uses  the SUN Mi crosystems  IANA
  345        * num ber (42).
  346        * @pa ram port T he TCP/IP  port the S NMPv3 Adap tor Server  is listen ing to.
  347        * @re turn The g enerated e ngine Id.
  348        * @ex ception Un knownHostE xception i f the loca l host nam e
  349        *             us ed to calc ulate the  id is unkn own.
  350        */
  351       public  static Sn mpEngineId  createEng ineId(int  port)
  352           th rows Unkno wnHostExce ption {
  353           in t suniana  = 42;
  354           In etAddress  address =  null;
  355           ad dress = In etAddress. getLocalHo st();
  356           re turn creat eEngineId( address, p ort, sunia na);
  357       }
  358       /**
  359        * Gen erates a u nique engi ne Id. The  engine Id  unicity i s based on
  360        * the  host IP a ddress and  port. The  IP addres s used is  the passed
  361        * one . The crea tion algor ithm uses  the SUN Mi crosystems  IANA
  362        * num ber (42).
  363        * @pa ram addres s The IP a ddress the  SNMPv3 Ad aptor Serv er is list ening to.
  364        * @pa ram port T he TCP/IP  port the S NMPv3 Adap tor Server  is listen ing to.
  365        * @re turn The g enerated e ngine Id.
  366        * @ex ception Un knownHostE xception.  if the pro vided addr ess is nul l.
  367        */
  368       public  static Sn mpEngineId  createEng ineId(Inet Address ad dress, int  port)
  369           th rows Illeg alArgument Exception  {
  370           in t suniana  = 42;
  371           if (address = = null)
  372                throw ne w IllegalA rgumentExc eption("In etAddress  is null.") ;
  373           re turn creat eEngineId( address, p ort, sunia na);
  374       }
  375  
  376       /**
  377        * Gen erates a u nique engi ne Id. The  engine Id  unicity i s based on
  378        * the  host IP a ddress and  port. The  IP addres s is the l ocalhost o ne.
  379        * The  creation  algorithm  uses the p assed IANA  number.
  380        * @pa ram port T he TCP/IP  port the S NMPv3 Adap tor Server  is listen ing to.
  381        * @pa ram iana Y our enterp rise IANA  number.
  382        * @ex ception Un knownHostE xception i f the loca l host nam e used to  calculate  the id is  unknown.
  383        * @re turn The g enerated e ngine Id.
  384        */
  385       public  static Sn mpEngineId  createEng ineId(int  port, int  iana) thro ws Unknown HostExcept ion {
  386           In etAddress  address =  null;
  387           ad dress = In etAddress. getLocalHo st();
  388           re turn creat eEngineId( address, p ort, iana) ;
  389       }
  390  
  391       /**
  392        * Gen erates a u nique engi ne Id. The  engine Id  unicity i s based on  the host  IP address  and port.  The IP ad dress is t he passed  one, it ha ndles IPv4  and IPv6  hosts. The  creation  algorithm  uses the p assed IANA  number.
  393        * @pa ram addr T he IP addr ess the SN MPv3 Adapt or Server  is listeni ng to.
  394        * @pa ram port T he TCP/IP  port the S NMPv3 Adap tor Server  is listen ing to.
  395        * @pa ram iana Y our enterp rise IANA  number.
  396        * @re turn The g enerated e ngine Id.
  397        * @ex ception Un knownHostE xception i f the prov ided <CODE >InetAddre ss </CODE>  is null.
  398        */
  399       public  static Sn mpEngineId  createEng ineId(Inet Address ad dr,
  400                                                     int  port,
  401                                                     int  iana) {
  402           if (addr == n ull) throw  new Illeg alArgument Exception( "InetAddre ss is null .");
  403           by te[] addre ss = addr. getAddress ();
  404           by te[] engin eid = new  byte[9 + a ddress.len gth];
  405           en gineid[0]  = (byte) (  (iana & 0 xFF000000)  >> 24 );
  406           en gineid[0]  |= 0x80;
  407           en gineid[1]  = (byte) (  (iana & 0 x00FF0000)  >> 16 );
  408           en gineid[2]  = (byte) (  (iana & 0 x0000FF00)  >> 8 );
  409  
  410   engineid[3 ] = (byte)  (iana & 0 x000000FF) ;
  411           en gineid[4]  = 0x05;
  412  
  413           if (address.l ength == 4 )
  414                engineid [4] = 0x01 ;
  415  
  416           if (address.l ength == 1 6)
  417                engineid [4] = 0x02 ;
  418  
  419           fo r(int i =  0; i < add ress.lengt h; i++) {
  420                engineid [i + 5] =  address[i] ;
  421           }
  422  
  423           en gineid[5 +  address.l ength] = ( byte)  ( ( port & 0xF F000000) > > 24 );
  424           en gineid[6 +  address.l ength] = ( byte) ( (p ort & 0x00 FF0000) >>  16 );
  425           en gineid[7 +  address.l ength] = ( byte) ( (p ort & 0x00 00FF00) >>  8 );
  426           en gineid[8 +  address.l ength] = ( byte) (  p ort & 0x00 0000FF );
  427  
  428           re turn new S nmpEngineI d(engineid );
  429       }
  430  
  431        /**
  432        * Gen erates an  engine Id  based on a n InetAddr ess. Handl es IPv4 an d IPv6 add resses. Th e creation  algorithm  uses the  passed IAN A number.
  433        * @pa ram iana Y our enterp rise IANA  number.
  434        * @pa ram addr T he IP addr ess the SN MPv3 Adapt or Server  is listeni ng to.
  435        * @re turn The g enerated e ngine Id.
  436        * @si nce 1.5
  437        * @ex ception Un knownHostE xception i f the prov ided <CODE >InetAddre ss </CODE>  is null.
  438        */
  439       public  static Sn mpEngineId  createEng ineId(int  iana, Inet Address ad dr)
  440       {
  441           if (addr == n ull) throw  new Illeg alArgument Exception( "InetAddre ss is null .");
  442           by te[] addre ss = addr. getAddress ();
  443           by te[] engin eid = new  byte[5 + a ddress.len gth];
  444           en gineid[0]  = (byte) (  (iana & 0 xFF000000)  >> 24 );
  445           en gineid[0]  |= 0x80;
  446           en gineid[1]  = (byte) (  (iana & 0 x00FF0000)  >> 16 );
  447           en gineid[2]  = (byte) (  (iana & 0 x0000FF00)  >> 8 );
  448  
  449           en gineid[3]  = (byte) ( iana & 0x0 00000FF);
  450           if (address.l ength == 4 )
  451                engineid [4] = 0x01 ;
  452  
  453           if (address.l ength == 1 6)
  454                engineid [4] = 0x02 ;
  455  
  456           fo r(int i =  0; i < add ress.lengt h; i++) {
  457                engineid [i + 5] =  address[i] ;
  458           }
  459  
  460           re turn new S nmpEngineI d(engineid );
  461       }
  462  
  463       /**
  464        * Gen erates an  engine Id  based on a n InetAddr ess. Handl es IPv4 an d IPv6
  465        * add resses. Th e creation  algorithm  uses the  sun IANA n umber (42) .
  466        * @pa ram addr T he IP addr ess the SN MPv3 Adapt or Server  is listeni ng to.
  467        * @re turn The g enerated e ngine Id.
  468        * @si nce 1.5
  469        * @ex ception Un knownHostE xception i f the prov ided
  470        *             <C ODE>InetAd dress</COD E> is null .
  471        */
  472       public  static Sn mpEngineId  createEng ineId(Inet Address ad dr) {
  473           re turn creat eEngineId( 42, addr);
  474       }
  475  
  476  
  477       /**
  478        * Tes ts <CODE>S nmpEngineI d</CODE> i nstance eq uality. Tw o <CODE>Sn mpEngineId </CODE> ar e equal if  they have  the same  value.
  479        * @re turn <CODE >true</COD E> if the  two <CODE> SnmpEngine Id</CODE>  are equals , <CODE>fa lse</CODE>  otherwise .
  480        */
  481       public  boolean e quals(Obje ct a) {
  482           if (!(a insta nceof Snmp EngineId)  ) return f alse;
  483           re turn hexSt ring.equal s(((SnmpEn gineId) a) .toString( ));
  484       }
  485  
  486       public  int hashC ode() {
  487           re turn hexSt ring.hashC ode();
  488       }
  489   }