Hi ,
I need to parse a file that contain linux interface information. My file text is like below
Interface ge1
Hardware is Ethernet
Current HW addr: 00a1.2599.0003
Physical:00a1.2599.0003
Description: BC3 - Slot 3 (Phys Slot 7)
index 5001 metric 1 mtu 1500 duplex-full arp ageing timeout 0
<BROADCAST,MULTICAST>
VRF Binding: Not bound
Bandwidth 1g
VRRP Master of : VRRP is not configured on this interface.
input packets 00, bytes 00, dropped 00, multicast packets 00
output packets 00, bytes 00, multicast packets 00 broadcast packets 00
Interface ge2
Hardware is Ethernet
Current HW addr: 00a1.2599.0004
Physical:00a1.2599.0004
Description: BC4 - Slot 4 (Phys Slot 8)
index 5002 metric 1 mtu 1500 duplex-full arp ageing timeout 0
<BROADCAST,MULTICAST>
VRF Binding: Not bound
Bandwidth 1g
VRRP Master of : VRRP is not configured on this interface.
input packets 00, bytes 00, dropped 00, multicast packets 00
output packets 00, bytes 00, multicast packets 00 broadcast packets 00
I need to pick two things in two different variables.
1)Interface Name ---- that is ge1 or ge2 corresponding to Interface keyword
2)<UP,BROADCAST,RUNNING,MULTICAST> ... every individual words like UP/BROADCAST in this line
So when my parsing will be finished i will have information like
ifname = ge1 broadcast = BROADCAST multicast = MULTICAST
ifname = ge2 broadcast = BROADCAST multicast = MULTICAST
ifname = ge3 broadcast = BROADCAST multicast = MULTICAST
.
Could you guys help me first to find best approach for doing this. I want to implement it in C++. But if anything u have in your mind please share it.
I am so new with programing.
Thanks