9541d76eab2cf65cb122b2c9635c06be792ab048
[VSoRC/.git] / js / utils.js
1 /*
2  * Copyright (C) 2014 SDN Hub
3  *
4  * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.
5  * You may not use this file except in compliance with this License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.gnu.org/licenses/gpl-3.0.txt
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13  * implied.
14  */
15
16 var ethertypeToString = function(type) {
17     switch (type) {
18         case 0x800: return "IPv4";
19         case 0x806: return "LLDP";
20         case 0x88cc: return "LLDP";
21         case 0x86dd: return "IPv6";
22         default: return "Unknown";
23     }
24 }
25
26 var nwprotoToString = function(type) {
27     switch (type) {
28         case 0x1: return "IPv4";
29         case 0x6: return "TCP";
30         case 0x11: return "UDP";
31         case 0x84: return "SCTP";
32         default: return "Unknown";
33     }
34 }
35
36 var removeAllChildren = function(node) {
37     while (node.firstChild) {
38             node.removeChild(node.firstChild);
39     }
40 }
41