Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2018 Open Networking Foundation |
| 3 | |
| 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation, either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | #include <iostream> |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 18 | #include <unistd.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 19 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 20 | #include "server.h" |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 21 | #include "core.h" |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 22 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 23 | int main(int argc, char** argv) { |
| 24 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 25 | Status status = Enable_(argc, argv); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 26 | if (!status.ok()) { |
| 27 | std::cout << "ERROR: Enable_ failed - " |
| 28 | << status.error_code() << ": " << status.error_message() |
| 29 | << std::endl; |
| 30 | return 1; |
| 31 | } |
| 32 | |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 33 | // Wait for successful activation before allowing VOLTHA to connect. |
| 34 | // This is necessary to allow the device topology to be dynamically |
| 35 | // queried from driver after initialization and activation is complete. |
| 36 | int maxTrials = 300; |
| 37 | while (!state.is_activated()) { |
| 38 | sleep(1); |
| 39 | if (--maxTrials == 0) { |
| 40 | std::cout << "ERROR: OLT/PON Activation failed" << std::endl; |
| 41 | return 1; |
| 42 | } |
| 43 | } |
| 44 | |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 45 | ProbeDeviceCapabilities_(); |
| 46 | sleep(2); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 47 | // Enable all PON interfaces. |
| 48 | for (int i = 0; i < NumPonIf_(); i++) { |
| 49 | status = EnablePonIf_(i); |
| 50 | if (!status.ok()) { |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 51 | // raise alarm to report error in enabling PON |
| 52 | pushOltOperInd(i, "pon", "down"); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 53 | } |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 54 | else |
| 55 | pushOltOperInd(i, "pon", "up"); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 56 | } |
| 57 | sleep(2); |
| 58 | // Enable all NNI interfaces. |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame^] | 59 | #if 0 |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 60 | for (int i = 0; i < NumNniIf_(); i++) { |
| 61 | status = EnableUplinkIf_(i); |
| 62 | if (!status.ok()) { |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 63 | // raise alarm to report error in enabling PON |
| 64 | pushOltOperInd(i, "nni", "down"); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 65 | } |
Jason Huang | 8879522 | 2019-06-13 19:28:44 +0800 | [diff] [blame] | 66 | else |
| 67 | pushOltOperInd(i, "nni", "up"); |
Jason Huang | b1fad57 | 2019-05-28 19:02:30 +0800 | [diff] [blame] | 68 | } |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame^] | 69 | #endif |
| 70 | //only for nni-65536 mapping to intf_id 0 |
| 71 | status = SetStateUplinkIf_(0, true); |
| 72 | if (!status.ok()) { |
| 73 | // raise alarm to report error in enabling NNI |
| 74 | pushOltOperInd(0, "nni", "down"); |
| 75 | } |
| 76 | else |
| 77 | pushOltOperInd(0, "nni", "up"); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 78 | RunServer(); |
| 79 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 80 | return 0; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 81 | } |