| 1 21 22 package ist.coach.coachEmsMibComponents; 23 24 import intt.itu.itut_x780.UIDType; 25 import intt.itu.itut_x780.CreateError; 26 import intt.itu.itut_x780.ApplicationError; 27 import intt.itu.itut_x780.AttributeValueChangeType; 28 import intt.itu.itut_x780.AttributeValueType; 29 import intt.itu.itut_x780.SourceIndicatorType; 30 import intt.itu.itut_x780.OperationalStateTypeHelper; 31 import intt.itu.itut_x780.OperationalStateType; 32 33 import ist.coach.coachEmfCommon.Utils; 34 import ist.coach.coachEmfCommon.StateChangedEventImpl; 35 import ist.coach.coachEmfCommon.StateChangedEventImpl; 36 import ist.coach.coachEmfCommon.ObjectCreationImpl; 37 import ist.coach.coachEmfCommon.ObjectDeletionImpl; 38 import ist.coach.coachEmfCommon.ExceptionMessages; 39 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl; 40 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 41 import ist.coach.coachEmfCommon.DataTypeImpl; 42 import ist.coach.coachEmfServices.SnmpAdapter.DataType; 43 import ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError; 44 45 import ist.coach.coachEmsMib.LogicalInterfaceValueType; 46 import ist.coach.coachEmsMib.LogicalInterface_F; 47 import ist.coach.coachEmsMibComponents.LogicalInterfaceProviderHelper; 48 49 import ist.coach.coachEmsCommon.LogicalInterfaceValueTypeImpl; 50 51 import org.omg.CosNaming.NameComponent ; 52 import org.omg.CORBA.TCKind ; 53 54 import org.opennms.protocols.snmp.SnmpSMI; 55 56 import java.util.Hashtable ; 57 58 62 public class LogicalInterfaceProviderMonolithicImpl 63 extends org.omg.CORBA.LocalObject  64 implements CCM_LogicalInterfaceProvider, 65 ist.coach.coachEmsMibComponents.CCM_LogicalInterfaceMgmt, 66 ist.coach.coachEmfServices.SnmpAdapter.CCM_TrapCallback, 67 org.omg.Components.SessionComponent 68 { 69 77 private CCM_LogicalInterfaceProvider_Context the_context_; 78 79 org.omg.CORBA.ORB orb = null; 80 private String _facade_name; 81 82 private Hashtable elements; 83 private int notifId = 1100; 84 85 public static final String IF_TABLE_OID = ".1.3.6.1.2.1.2.2"; 86 87 private static final String IF_DESCR_OID = ".1.3.6.1.2.1.2.2.1.2"; 88 private static final String IF_TYPE_OID = ".1.3.6.1.2.1.2.2.1.3"; 89 private static final String IF_MTU_OID = ".1.3.6.1.2.1.2.2.1.4"; 90 private static final String IF_SPEED_OID = ".1.3.6.1.2.1.2.2.1.5"; 91 private static final String IF_PHYSADDR_OID = ".1.3.6.1.2.1.2.2.1.6"; 92 private static final String IF_ADMINSTATUS_OID = ".1.3.6.1.2.1.2.2.1.7"; 93 private static final String IF_OPERSTATUS_OID = ".1.3.6.1.2.1.2.2.1.8"; 94 private static final String IF_LASTCHANGE_OID = ".1.3.6.1.2.1.2.2.1.9"; 95 private static final String IF_INOCTETS_OID = ".1.3.6.1.2.1.2.2.1.10"; 96 private static final String IF_INUCASTPKTS_OID = ".1.3.6.1.2.1.2.2.1.11"; 97 private static final String IF_INNUCASTPKTS_OID = ".1.3.6.1.2.1.2.2.1.12"; 98 private static final String IF_INDISCARDS_OID = ".1.3.6.1.2.1.2.2.1.13"; 99 private static final String IF_INERRORS_OID = ".1.3.6.1.2.1.2.2.1.14"; 100 private static final String IF_INUNKNOWNPROTOS_OID = ".1.3.6.1.2.1.2.2.1.15"; 101 private static final String IF_OUTOCTETS_OID = ".1.3.6.1.2.1.2.2.1.16"; 102 private static final String IF_OUTUCASTPKTS_OID = ".1.3.6.1.2.1.2.2.1.17"; 103 private static final String IF_OUTNUCASTPKTS_OID = ".1.3.6.1.2.1.2.2.1.18"; 104 private static final String IF_OUTDISCARDS_OID = ".1.3.6.1.2.1.2.2.1.19"; 105 private static final String IF_OUTERRORS_OID = ".1.3.6.1.2.1.2.2.1.20"; 106 private static final String IF_OUTQLEN_OID = ".1.3.6.1.2.1.2.2.1.21"; 107 private static final String IF_SPECIFIC_OID = ".1.3.6.1.2.1.2.2.1.22"; 108 109 private static final String TIME_OID = ".1.3.6.1.2.1.1.3.0"; 110 private static final int COACH_LINK_UP = 2; 111 private static final int COACH_LINK_DOWN = 3; 112 113 private static final String IF_LAST_CHANGE_PACKAGE = "ifLastChangePackage"; 114 private static final String IF_ADMIN_STATUS_PACKAGE = "ifAdminStatusPackage"; 115 private static final String OPERATIONAL_STATE_PACKAGE = "operationalStatePackage"; 116 private static final String NON_UCAST_PACKAGE = "ifNUcastPackage"; 117 private static final String UNKNOWN_PROTOS_PACKAGE = "ifUnknownProtosPackage"; 118 119 private static final String READ_COMMUNITY = "public"; 120 private static final String WRITE_COMMUNITY = "private"; 121 123 ist.coach.coachEmfServices.SnmpAdapter.SnmpConnector connector = null; 124 ist.coach.coachEmfServices.SnmpAdapter.SnmpTrapDaemon config = null; 125 126 134 public 135 LogicalInterfaceProviderMonolithicImpl() 136 { 137 the_context_ = null; 138 139 this.elements = new Hashtable (); 140 } 141 147 148 159 public CCM_LogicalInterfaceProvider_Context 160 getContext() 161 { 162 return the_context_; 163 } 164 178 public void 179 configuration_complete() 180 throws org.omg.Components.InvalidConfiguration 181 { 182 186 if ((connector = the_context_.get_connection_connector()) == null) 187 throw new org.omg.Components.InvalidConfiguration(); 188 189 if ((config = the_context_.get_connection_config()) == null) 190 throw new org.omg.Components.InvalidConfiguration(); 191 192 orb = org.objectweb.ccm.CORBA.TheORB.getORB(); 193 System.err.println("LogicalInterface configuration completed..."); 194 195 196 } 197 213 public void 214 set_session_context(org.omg.Components.SessionContext context) 215 throws org.omg.Components.CCMException 216 { 217 the_context_ = (CCM_LogicalInterfaceProvider_Context)context; 218 } 219 229 public void 230 ccm_activate() 231 throws org.omg.Components.CCMException 232 { 233 } 237 247 public void 248 ccm_passivate() 249 throws org.omg.Components.CCMException 250 { 251 } 255 265 public void 266 ccm_remove() 267 throws org.omg.Components.CCMException 268 { 269 } 273 284 public ist.coach.coachEmsMibComponents.CCM_LogicalInterfaceMgmt 285 get_mgmt() 286 { 287 return this; 288 } 289 295 public ist.coach.coachEmfServices.SnmpAdapter.CCM_TrapCallback 296 get_snmp_callback() 297 { 298 return this; 299 } 300 306 public java.lang.String  307 facade_name() 308 { 309 return _facade_name; 313 } 314 315 318 public void 319 facade_name(java.lang.String val) 320 { 321 325 if (val != null) 326 _facade_name = new String (val); 327 } 328 334 public int 335 ifIndexGet(org.omg.CosNaming.NameComponent [] name) 336 { 337 341 343 String key = Utils.name2string(name); 344 345 if (this.elements.containsKey(key) == false) { 346 357 358 return -1; 359 } 360 361 LogicalInterfaceDataStructure data = 362 (LogicalInterfaceDataStructure) this.elements.get(key); 363 364 return data.ifIndex; 365 } 366 367 373 public java.lang.String  374 ifDescrGet(org.omg.CosNaming.NameComponent [] name) 375 throws intt.itu.itut_x780.ApplicationError 376 { 377 381 String key = Utils.name2string(name); 382 383 if (this.elements.containsKey(key) == false) { 384 ApplicationErrorInfoTypeImpl error_code = 385 new ApplicationErrorInfoTypeImpl(); 386 387 error_code.error = new UIDType( 388 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 389 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 390 391 error_code.details = new String ("object with name " + 392 key + " does not exist."); 393 394 throw new ApplicationError(error_code); 395 } 396 397 LogicalInterfaceDataStructure data = 398 (LogicalInterfaceDataStructure) this.elements.get(key); 399 400 int ifIndex = data.ifIndex; 401 402 String ifDescrOid = new String (IF_DESCR_OID + "." + ifIndex); 403 404 DataType ifDescrData = null; 405 406 408 try { 409 ifDescrData = this.connector.get( 410 ifDescrOid, 411 new String (data.mgmtIpAddress), 412 data.getSnmpPort(), 413 READ_COMMUNITY); 414 } 415 catch (SnmpApplicationError e) { 416 417 ApplicationErrorInfoTypeImpl error_code = 418 new ApplicationErrorInfoTypeImpl(); 419 420 error_code.error = new UIDType( 421 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 422 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 423 424 if (e.reason.equals(ExceptionMessages.agent_response_error)) 425 error_code.details = ExceptionMessages.agent_response_error; 426 else 427 error_code.details = new String ("Could not retrieve ifDescr " + 428 "for LogicalInterface Object with name " + key + ":" + 429 " Object with Snmp Object Identifier " + ifDescrOid + 430 " does not exist."); 431 throw new ApplicationError (error_code); 432 } 433 434 org.omg.CORBA.Any value = ifDescrData.value; 435 436 if (value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 438 ApplicationErrorInfoTypeImpl error_code = 439 new ApplicationErrorInfoTypeImpl(); 440 441 error_code.error = new UIDType( 442 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 443 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 444 445 error_code.details = new String ("Could not retrieve ifDescr " + 446 "for LogicalInterface Object with name " + key + ":" + 447 " Object with Snmp Object Identifier " + ifDescrOid + 448 " is not of expected type."); 449 450 throw new ApplicationError (error_code); 451 452 } 453 String ifDescr = new String (org.omg.CORBA.OctetSeqHelper.extract(value)); 456 return ifDescr; 457 458 } 459 465 public int 466 ifTypeGet(org.omg.CosNaming.NameComponent [] name) 467 throws intt.itu.itut_x780.ApplicationError 468 { 469 473 String key = Utils.name2string(name); 474 475 if (this.elements.containsKey(key) == false) { 476 ApplicationErrorInfoTypeImpl error_code = 477 new ApplicationErrorInfoTypeImpl(); 478 479 error_code.error = new UIDType( 480 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 481 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 482 483 error_code.details = new String ("object with name " + 484 key + " does not exist."); 485 486 throw new ApplicationError(error_code); 487 } 488 489 LogicalInterfaceDataStructure data = 490 (LogicalInterfaceDataStructure) this.elements.get(key); 491 492 int ifIndex = data.ifIndex; 493 494 String ifTypeOid = new String (IF_TYPE_OID + "." + ifIndex); 495 496 DataType ifTypeData = null; 497 498 500 try { 501 ifTypeData = this.connector.get( 502 ifTypeOid, 503 new String (data.mgmtIpAddress), 504 data.getSnmpPort(), 505 READ_COMMUNITY); 506 } 507 catch (SnmpApplicationError e) { 508 509 ApplicationErrorInfoTypeImpl error_code = 510 new ApplicationErrorInfoTypeImpl(); 511 512 error_code.error = new UIDType( 513 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 514 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 515 516 if (e.reason.equals(ExceptionMessages.agent_response_error)) 517 error_code.details = ExceptionMessages.agent_response_error; 518 else 519 error_code.details = new String ("Could not retrieve ifType " + 520 "for LogicalInterface Object with name " + key + ":" + 521 " Object with Snmp Object Identifier " + ifTypeOid + 522 " does not exist."); 523 throw new ApplicationError (error_code); 524 } 525 526 org.omg.CORBA.Any value = ifTypeData.value; 527 528 if (value.type().kind().value() != TCKind._tk_long) { 529 530 ApplicationErrorInfoTypeImpl error_code = 531 new ApplicationErrorInfoTypeImpl(); 532 533 error_code.error = new UIDType( 534 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 535 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 536 537 error_code.details = new String ("Could not retrieve ifType " + 538 "for LogicalInterface Object with name " + key + ":" + 539 " Object with Snmp Object Identifier " + ifTypeOid + 540 " is not of type integer, as expected."); 541 542 throw new ApplicationError (error_code); 543 544 } 545 546 int ifType = value.extract_long(); 547 548 return ifType; 549 } 550 556 public int 557 ifMtuGet(org.omg.CosNaming.NameComponent [] name) 558 throws intt.itu.itut_x780.ApplicationError 559 { 560 String key = Utils.name2string(name); 564 565 if (this.elements.containsKey(key) == false) { 566 ApplicationErrorInfoTypeImpl error_code = 567 new ApplicationErrorInfoTypeImpl(); 568 569 error_code.error = new UIDType( 570 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 571 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 572 573 error_code.details = new String ("object with name " + 574 key + " does not exist."); 575 576 throw new ApplicationError(error_code); 577 } 578 579 LogicalInterfaceDataStructure data = 580 (LogicalInterfaceDataStructure) this.elements.get(key); 581 582 int ifIndex = data.ifIndex; 583 584 String ifMtuOid = new String (IF_MTU_OID + "." + ifIndex); 585 586 DataType ifMtuData = null; 587 588 590 try { 591 592 ifMtuData = this.connector.get( 593 ifMtuOid, 594 new String (data.mgmtIpAddress), 595 data.getSnmpPort(), 596 READ_COMMUNITY); 597 } 598 catch (SnmpApplicationError e) { 599 600 ApplicationErrorInfoTypeImpl error_code = 601 new ApplicationErrorInfoTypeImpl(); 602 603 error_code.error = new UIDType( 604 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 605 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 606 607 if (e.reason.equals(ExceptionMessages.agent_response_error)) 608 error_code.details = ExceptionMessages.agent_response_error; 609 else 610 error_code.details = new String ("Could not retrieve ifMtu " + 611 "for LogicalInterface Object with name " + key + ":" + 612 " Object with Snmp Object Identifier " + ifMtuOid + 613 " does not exist."); 614 throw new ApplicationError (error_code); 615 } 616 617 org.omg.CORBA.Any value = ifMtuData.value; 618 619 if (value.type().kind().value() != TCKind._tk_long) { 620 621 ApplicationErrorInfoTypeImpl error_code = 622 new ApplicationErrorInfoTypeImpl(); 623 624 error_code.error = new UIDType( 625 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 626 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 627 628 error_code.details = new String ("Could not retrieve ifMtu " + 629 "for LogicalInterface Object with name " + key + ":" + 630 " Object with Snmp Object Identifier " + ifMtuOid + 631 " is not of type integer, as expected."); 632 633 throw new ApplicationError (error_code); 634 635 } 636 637 int ifMtu = value.extract_long(); 638 639 return ifMtu; 640 } 641 647 public long 648 ifSpeedGet(org.omg.CosNaming.NameComponent [] name) 649 throws intt.itu.itut_x780.ApplicationError 650 { 651 String key = Utils.name2string(name); 655 656 if (this.elements.containsKey(key) == false) { 657 ApplicationErrorInfoTypeImpl error_code = 658 new ApplicationErrorInfoTypeImpl(); 659 660 error_code.error = new UIDType( 661 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 662 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 663 664 error_code.details = new String ("object with name " + 665 key + " does not exist."); 666 667 throw new ApplicationError(error_code); 668 } 669 670 LogicalInterfaceDataStructure data = 671 (LogicalInterfaceDataStructure) this.elements.get(key); 672 673 int ifIndex = data.ifIndex; 674 675 String ifSpeedOid = new String (IF_SPEED_OID + "." + ifIndex); 676 677 DataType ifSpeedData = null; 678 679 681 try { 682 ifSpeedData = this.connector.get( 683 ifSpeedOid, 684 new String (data.mgmtIpAddress), 685 data.getSnmpPort(), 686 READ_COMMUNITY); 687 } 688 catch (SnmpApplicationError e) { 689 690 ApplicationErrorInfoTypeImpl error_code = 691 new ApplicationErrorInfoTypeImpl(); 692 693 error_code.error = new UIDType( 694 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 695 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 696 697 if (e.reason.equals(ExceptionMessages.agent_response_error)) 698 error_code.details = ExceptionMessages.agent_response_error; 699 else 700 error_code.details = new String ("Could not retrieve ifMtu " + 701 "for LogicalInterface Object with name " + key + ":" + 702 " Object with Snmp Object Identifier " + ifSpeedOid + 703 " does not exist."); 704 throw new ApplicationError (error_code); 705 } 706 707 org.omg.CORBA.Any value = ifSpeedData.value; 708 709 if (value.type().kind().value() != TCKind._tk_longlong) { 710 711 ApplicationErrorInfoTypeImpl error_code = 712 new ApplicationErrorInfoTypeImpl(); 713 714 error_code.error = new UIDType( 715 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 716 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 717 718 error_code.details = new String ("Could not retrieve ifSpeed " + 719 "for LogicalInterface Object with name " + key + ":" + 720 " Object with Snmp Object Identifier " + ifSpeedOid + 721 " is not of type integer, as expected."); 722 723 throw new ApplicationError (error_code); 724 725 } 726 727 long ifSpeed = value.extract_longlong(); 728 729 return ifSpeed; 730 } 731 737 public byte[] 738 ifPhysAddressGet(org.omg.CosNaming.NameComponent [] name) 739 throws intt.itu.itut_x780.ApplicationError 740 { 741 String key = Utils.name2string(name); 745 746 if (this.elements.containsKey(key) == false) { 747 ApplicationErrorInfoTypeImpl error_code = 748 new ApplicationErrorInfoTypeImpl(); 749 750 error_code.error = new UIDType( 751 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 752 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 753 754 error_code.details = new String ("object with name " + 755 key + " does not exist."); 756 757 throw new ApplicationError(error_code); 758 } 759 760 LogicalInterfaceDataStructure data = 761 (LogicalInterfaceDataStructure) this.elements.get(key); 762 763 int ifIndex = data.ifIndex; 764 765 String ifPhysAddrOid = new String (IF_PHYSADDR_OID + "." + ifIndex); 766 767 DataType ifPhysAddrData = null; 768 769 771 try { 772 ifPhysAddrData = this.connector.get( 773 ifPhysAddrOid, 774 new String (data.mgmtIpAddress), 775 data.getSnmpPort(), 776 READ_COMMUNITY); 777 } 778 catch (SnmpApplicationError e) { 779 780 ApplicationErrorInfoTypeImpl error_code = 781 new ApplicationErrorInfoTypeImpl(); 782 783 error_code.error = new UIDType( 784 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 785 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 786 787 if (e.reason.equals(ExceptionMessages.agent_response_error)) 788 error_code.details = ExceptionMessages.agent_response_error; 789 else 790 error_code.details = new String ("Could not retrieve ifPhysAddr " + 791 "for LogicalInterface Object with name " + key + ":" + 792 " Object with Snmp Object Identifier " + ifPhysAddrOid + 793 " does not exist."); 794 throw new ApplicationError (error_code); 795 } 796 797 org.omg.CORBA.Any value = ifPhysAddrData.value; 798 799 if (value.type().kind().value() != org.omg.CORBA.OctetSeqHelper.type().kind().value()) { 801 ApplicationErrorInfoTypeImpl error_code = 802 new ApplicationErrorInfoTypeImpl(); 803 804 error_code.error = new UIDType( 805 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 806 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 807 808 error_code.details = new String ("Could not retrieve ifPhysAddr " + 809 "for LogicalInterface Object with name " + key + ":" + 810 " Object with Snmp Object Identifier " + ifPhysAddrOid + 811 " is not of expected type."); 812 813 throw new ApplicationError (error_code); 814 815 } 816 820 byte [] ifPhysAddr = org.omg.CORBA.OctetSeqHelper.extract(value); 821 return ifPhysAddr; 822 } 823 829 public int 830 ifAdminStatusGet(org.omg.CosNaming.NameComponent [] name) 831 throws intt.itu.itut_x780.ApplicationError 832 { 833 String key = Utils.name2string(name); 837 838 if (this.elements.containsKey(key) == false) { 839 ApplicationErrorInfoTypeImpl error_code = 840 new ApplicationErrorInfoTypeImpl(); 841 842 &nbs
|