Ejemplo n.º 1
0
 def buildLayer(session: 'PPPoESession') -> 'Packet':
     packet = Ether(src=session.src_mac, dst=session.dst_mac)
     if session.providerVlan is not None:
         packet.add_payload(Dot1Q(vlan=session.clientVlan))
     if session.clientVlan is not None:
         packet.add_payload(Dot1Q(vlan=session.clientVlan))
     return packet
Ejemplo n.º 2
0
    def test_from_frame(self):
        e = Ether(src='00:01:02:03:04:05', dst='AA:BB:CC:DD:EE:FF')
        e.add_payload("thisisapayload")
        frame = str(e)

        vx = VXLAN(frame=frame, vni=123)
        self.assertEqual(vx.vni, 123)
        self.assertEqual(str(vx), "\x08\x00\x00\x00\x00\x00\x7b\x00" + frame)
Ejemplo n.º 3
0
def sendEthMsg(dest_hw_addr, msg):
    eth = Ether(type=0x800, dst=dest_hw_addr, src=get_if_hwaddr(conf.iface))
    raw_payload = Raw(load=str(msg))
    eth.add_payload(raw_payload)
    if(debug):
        print("\nsend eth header\n")
        eth.show()
    # send packet using socked on conf.iface, which is default interface (h1x1-eth0, etc)
    sendp(eth, iface=conf.iface)
Ejemplo n.º 4
0
    def test_from_frame(self):
        e = Ether(src='00:01:02:03:04:05', dst='AA:BB:CC:DD:EE:FF')
        e.add_payload("thisisapayload")
        frame = str(e)

        vx = VXLAN(frame=frame, vni=123)
        self.assertEqual(vx.vni, 123)
        self.assertEqual(str(vx),
            "\x08\x00\x00\x00\x00\x00\x7b\x00" + frame)
Ejemplo n.º 5
0
    def test_from_packet(self):
        e = Ether(src='00:01:02:03:04:05', dst='AA:BB:CC:DD:EE:FF')
        e.add_payload("thisisapayload")
        frame = str(e)

        packet = "\x08\x00\x00\x00\x00\x00\x7c\x00" + frame
        vx = VXLAN(packet=packet)
        self.assertEqual(vx.vni, 124)
        self.assertEqual(str(vx.frame), frame)
        self.assertEqual(str(vx), packet)
        self.assertEqual(vx.src_mac, "00:01:02:03:04:05")
        self.assertEqual(vx.dst_mac, "AA:BB:CC:DD:EE:FF")
Ejemplo n.º 6
0
    def test_from_packet(self):
        e = Ether(src='00:01:02:03:04:05', dst='AA:BB:CC:DD:EE:FF')
        e.add_payload("thisisapayload")
        frame = str(e)

        packet = "\x08\x00\x00\x00\x00\x00\x7c\x00" + frame
        vx = VXLAN(packet=packet)
        self.assertEqual(vx.vni, 124)
        self.assertEqual(str(vx.frame), frame)
        self.assertEqual(str(vx), packet)
        self.assertEqual(vx.src_mac, "00:01:02:03:04:05")
        self.assertEqual(vx.dst_mac, "AA:BB:CC:DD:EE:FF")
Ejemplo n.º 7
0
 def remove_dot1_layer(self, packet):
     self.test.instance().assertEqual(type(packet), Ether)
     self.test.instance().assertEqual(packet.type, self.DOT1AD_TYPE)
     packet.type = self.DOT1Q_TYPE
     packet = Ether(str(packet))
     payload = packet.payload
     self.test.instance().assertEqual(type(payload), Dot1Q)
     self.test.instance().assertEqual(payload.vlan, self.outer_vlan)
     payload = payload.payload
     self.test.instance().assertEqual(type(payload), Dot1Q)
     self.test.instance().assertEqual(payload.vlan, self.inner_vlan)
     payload = payload.payload
     packet.remove_payload()
     packet.add_payload(payload)
     return packet