Replaces one protocol instance with another. Should be done before the stack is connected @param existing_prot @param new_prot
(Protocol existing_prot, Protocol new_prot)
| 746 | * @param new_prot |
| 747 | */ |
| 748 | public void replaceProtocol(Protocol existing_prot, Protocol new_prot) throws Exception { |
| 749 | Protocol up_neighbor=existing_prot.getUpProtocol(), down_neighbor=existing_prot.getDownProtocol(); |
| 750 | |
| 751 | new_prot.setUpProtocol(existing_prot.getUpProtocol()); |
| 752 | new_prot.setDownProtocol(existing_prot.getDownProtocol()); |
| 753 | up_neighbor.setDownProtocol(new_prot); |
| 754 | if(down_neighbor != null) |
| 755 | down_neighbor.setUpProtocol(new_prot); |
| 756 | |
| 757 | existing_prot.setDownProtocol(null); |
| 758 | existing_prot.setUpProtocol(null); |
| 759 | existing_prot.stop(); |
| 760 | existing_prot.destroy(); |
| 761 | |
| 762 | if(new_prot.getUpProtocol() == this) |
| 763 | top_prot=new_prot; |
| 764 | callAfterCreationHook(new_prot, afterCreationHook()); |
| 765 | new_prot.init(); |
| 766 | } |
| 767 | |
| 768 | |
| 769 |