Developing lightweight computation at the DSG edge

Commit 766de7fb authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

guificnml: create package



The guificnml package allows parsing CNML files from Guifi.net to use
them in Go applications.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 33179608
Pipeline #9 canceled with stages
# Monidote
## guificnml
The _**[guificnml][6d4eb44e]**_ package allows parsing [Community Network Markup Language (CNML)][d78b1e3b] files from the Guifi.net web page to use them in Go applications, such as those in the [Monidote project][c0b43b2a].
[c0b43b2a]: ../ "Monidote project (main)"
Sample CNML files are shipped in the [`../assets/cnml`][64da06da] folder.
[6d4eb44e]: guificnml.go "View the guificnml package source code"
[d78b1e3b]: http://en.wiki.guifi.net/wiki/CNML "The CNML page on Guifi.net's English Wiki"
[64da06da]: ../assets/cnml "CNML assets' folder including sample files"
\ No newline at end of file
package guificnml
import (
"net"
)
// The Cnml struct comprises the whole CNML
type Cnml struct {
Version float32 `xml:"version,attr"`
ServerID int `xml:"server_id,attr"`
ServerURL string `xml:"server_url,attr"`
Generated string `xml:"generated,attr"`
Nodes Node `xml:"node"`
Classes Class `xml:"class"`
Network Network `xml:"network"`
}
// The Class struct contains some details about the CNML itself
type Class struct {
// NodeDescription int `xml:"node_description,attr"`
Mapping string `xml:"mapping,attr"`
NetworkDescription string `xml:"network_description,attr"`
}
// The Network struct summarizes the network in the CNML
type Network struct {
Nodes int `xml:"nodes,attr"`
Devices int `xml:"devices,attr"`
Ap int `xml:"ap,attr"`
Client int `xml:"client,attr"`
Services int `xml:"services,attr"`
Links int `xml:"links,attr"`
Zone Zone `xml:"zone"`
}
// The Zone struct contains a Guifi zone (i.e. a geographical area)
type Zone struct {
ID int `xml:"id,attr"`
ParentID int `xml:"parent_id,attr"`
Title string `xml:"title,attr"`
TimeZone string `xml:"time_zone,attr"`
GraphServer int `xml:"graph_server,attr"`
Created string `xml:"created,attr"`
Updated string `xml:"updated,attr"`
ZoneNodes int `xml:"zone_nodes,attr"`
Box string `xml:"box,attr"`
AccessPoints int `xml:"access_points,attr"`
Clients int `xml:"client,attr"`
Devices int `xml:"devices,attr"`
Services int `xml:"services,attr"`
Links int `xml:"links,attr"`
Nodes []Node `xml:"node"`
Zones []Zone `xml:"zone"`
}
// The Node struct contains a Guifi node (i.e. a network physical location)
type Node struct {
ID int `xml:"id,attr"`
Title string `xml:"title,attr"`
Lat float32 `xml:"lat,attr"`
Lon float32 `xml:"lon,attr"`
AntennaElevation int `xml:"antenna_elevation,attr"`
Status string `xml:"status,attr"`
GraphServer int `xml:"graph_server,attr"`
Created string `xml:"created,attr"`
Updated string `xml:"updated,attr"`
DevicesCount int `xml:"devices,attr"`
ServicesCount int `xml:"services,attr"`
Devices []Device `xml:"device"`
}
// The Device struct contains a Guifi network device (e.g. a router, a switch)
type Device struct {
ID int `xml:"id,attr"`
MainIpv4 string `xml:"mainipv4,attr"`
Title string `xml:"title,attr"`
Type string `xml:"type,attr"`
Status string `xml:"status,attr"`
GraphServer int `xml:"graph_server,attr"`
Created string `xml:"created,attr"`
Updated string `xml:"updated,attr"`
SnmpIndex string `xml:"snmp_index,attr"`
Firmware string `xml:"firmware,attr"`
Name string `xml:"name,attr"`
Interfaces []Interface `xml:"interface"`
Radios Radio `xml:"radio"`
}
// The Interface struct defines an interface of a Guifi network device
type Interface struct {
ID int `xml:"id,attr"`
Type string `xml:"type,attr"`
Mac string `xml:"mac,attr"`
// Ipv4 net.IPAddr `xml:"ipv4,attr"`
Ipv4 string `xml:"ipv4,attr"`
Mask net.IPMask `xml:"mask,attr"`
}
// The Radio struct defines a wireless interface of a Guifi network device
type Radio struct {
ID int `xml:"id,attr"`
DeviceID int `xml:"device_id,attr"`
Ssid string `xml:"ssid,attr"`
Mode string `xml:"mode,attr"`
Protocol string `xml:"protocol,attr"`
Channel int `xml:"channel,attr"`
AntennaGain int `xml:"antenna_gain,attr"`
ClientsAccepted string `xml:"clients_accepted,attr"`
SnmpName string `xml:"snmp_name,attr"`
}
// The DeviceIpv4Adddresses holds the IPv4 addresses of a device
type DeviceIpv4Adddresses struct {
ID int
Addresses []string
}
// The DeviceAddressesServer lists the IPv4 addresses a GraphServer is assigned
type DeviceAddressesServer struct {
ID int
Addresses []string
GraphServer int
}
// The DeviceIpv4sGraphserver lists the IPv4 addresses a GraphServer is assigned
type DeviceIpv4sGraphserver struct {
ID int `json:"Id"`
Addresses []string `json:"Addresses"`
GraphServer int `json:"GraphServer"`
}
// The DeviceMonitorAssignation holds a device with its IPv4 addresses and the
// list of monitors to which it is assigned
type DeviceMonitorAssignation struct {
Device DeviceIpv4Adddresses
MonitorID []string
}
// The AssignChecksum holds...
type AssignChecksum struct {
MonitorID string
Checksum string
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment