Jakub Grajciar | 7b867a8 | 2017-12-08 16:28:42 +0100 | [diff] [blame] | 1 | |
| 2 | from vpp_object import VppObject |
| 3 | |
| 4 | |
| 5 | class IgmpSG(): |
| 6 | def __init__(self, saddr, gaddr): |
| 7 | self.saddr = saddr |
| 8 | self.gaddr = gaddr |
| 9 | |
| 10 | |
| 11 | class VppIgmpConfig(VppObject): |
| 12 | def __init__(self, test, sw_if_index, sg=None): |
| 13 | self._test = test |
| 14 | self.sw_if_index = sw_if_index |
| 15 | if isinstance(sg, list): |
| 16 | self.sg_list = sg |
| 17 | else: |
| 18 | self.sg_list = [] |
| 19 | self.sg_list.append(sg) |
| 20 | |
| 21 | def add_sg(self, sg): |
| 22 | self.sg.append(sg) |
| 23 | |
| 24 | def add_vpp_config(self): |
| 25 | for e in self.sg_list: |
| 26 | self._test.vapi.igmp_listen( |
| 27 | 1, self.sw_if_index, e.saddr, e.gaddr) |
| 28 | |
| 29 | def remove_vpp_config(self): |
| 30 | self._test.vapi.igmp_clear_interface(self.sw_if_index) |
| 31 | |
| 32 | def __str__(self): |
| 33 | return self.object_id() |
| 34 | |
| 35 | def object_id(self): |
| 36 | return "%s:%d" % (self.sg_list, self.sw_if_index) |
| 37 | |
| 38 | def query_vpp_config(self): |
| 39 | return self._test.vapi.igmp_dump() |