Beispiel #1
0
    def test_01(self):
        """SOME/IP-SD packet : subscribe eventgroup."""
        err_msg = ""

        # build SOME/IP-SD packet
        sip,sd = helper.newSD()
        
        sd.flags = 0x00
        sd.entry_array = [SDEntry_Eventgroup(type=SDEntry.TYPE_EVTGRP_SUBSCRIBE,
                                            n_1_opt=1,
                                            srv_id=0x1111,inst_id=0x2222,major_ver=0x03,egrp_id=0x04,cnt=0x0,ttl=0x05)]
        sd.option_array = [
                SDOption_IP4_EndPoint(addr="192.168.0.1",l4_proto=0x11,port=0xd903)
                ]
        
        # SEND MESSAGE (build request and reply packages)
        p = Ether()/IP(src="10.0.0.11",dst="10.0.0.12")/UDP(sport=30490,dport=30490)/sip/sd
        r = Ether()/IP(src="10.0.0.12",dst="10.0.0.11")/UDP(sport=30490,dport=30490)/sip/sd
        r['SD'].entry_array[0].type=SDEntry.TYPE_EVTGRP_SUBSCRIBE_ACK

        # use a couple of threads to emulate sender/reciever ends of communication
        t_send = threading.Thread(name='sender',target=self._test_01_sender,args=(p,))
        t_rcv = threading.Thread(name='receiver',target=self._test_01_rcv,args=(r,))
        t_send.start()
        t_rcv.start()
        t_send.join()
        t_rcv.join()

        # log test results
        self.addTestCase("send SOME/IP-SD : find service",error=err_msg)
Beispiel #2
0
    def test_01(self):
        """SOME/IP-SD packet : subscribe eventgroup."""
        err_msg = ""

        # build SOME/IP-SD packet
        sip, sd = helper.newSD()

        sd.flags = 0x00
        sd.entry_array = [
            SDEntry_Eventgroup(type=SDEntry.TYPE_EVTGRP_SUBSCRIBE,
                               n_1_opt=1,
                               srv_id=0x1111,
                               inst_id=0x2222,
                               major_ver=0x03,
                               egrp_id=0x04,
                               cnt=0x0,
                               ttl=0x05)
        ]
        sd.option_array = [
            SDOption_IP4_EndPoint(addr="192.168.0.1",
                                  l4_proto=0x11,
                                  port=0xd903)
        ]

        # SEND MESSAGE (build request and reply packages)
        p = Ether() / IP(src="10.0.0.11", dst="10.0.0.12") / UDP(
            sport=30490, dport=30490) / sip / sd
        r = Ether() / IP(src="10.0.0.12", dst="10.0.0.11") / UDP(
            sport=30490, dport=30490) / sip / sd
        r['SD'].entry_array[0].type = SDEntry.TYPE_EVTGRP_SUBSCRIBE_ACK

        # use a couple of threads to emulate sender/reciever ends of communication
        t_send = threading.Thread(name='sender',
                                  target=self._test_01_sender,
                                  args=(p, ))
        t_rcv = threading.Thread(name='receiver',
                                 target=self._test_01_rcv,
                                 args=(r, ))
        t_send.start()
        t_rcv.start()
        t_send.join()
        t_rcv.join()

        # log test results
        self.addTestCase("send SOME/IP-SD : find service", error=err_msg)
Beispiel #3
0
    def test_02(self):
        """ SOME/IP-SD : documentation example."""
        err_msg = ""
        
        # build SOME/IP-SD packet
        sip,sd = helper.newSD()

        sd.flags = 0x80
        sd.entry_array = [
                SDEntry_Service(type=SDEntry.TYPE_SRV_FINDSERVICE,srv_id=0x4711,inst_id=0xffff,major_ver=0xff,ttl=3600,minor_ver=0xffffffff),
                SDEntry_Service(type=SDEntry.TYPE_SRV_OFFERSERVICE,n_1_opt=1,srv_id=0x1234,inst_id=0x0001,major_ver=0x01,ttl=3,minor_ver=0x00000032)
                ]
        sd.option_array = [
                SDOption_IP4_EndPoint(addr="192.168.0.1",l4_proto=0x11,port=0xd903)
                ]
        
        # SEND MESSAGE 
        p = Ether()/IP(src="10.0.0.11",dst="10.0.0.12")/UDP(sport=30490,dport=30490)/sip/sd
        helper.sendp(p,iface=ETH_IFACE_SRC)
        
        # log test results
        self.addTestCase("send SOME/IP-SD : documentation example",error=err_msg)
Beispiel #4
0
    def test_02(self):
        """ SOME/IP-SD : documentation example."""
        err_msg = ""

        # build SOME/IP-SD packet
        sip, sd = helper.newSD()

        sd.flags = 0x80
        sd.entry_array = [
            SDEntry_Service(type=SDEntry.TYPE_SRV_FINDSERVICE,
                            srv_id=0x4711,
                            inst_id=0xffff,
                            major_ver=0xff,
                            ttl=3600,
                            minor_ver=0xffffffff),
            SDEntry_Service(type=SDEntry.TYPE_SRV_OFFERSERVICE,
                            n_1_opt=1,
                            srv_id=0x1234,
                            inst_id=0x0001,
                            major_ver=0x01,
                            ttl=3,
                            minor_ver=0x00000032)
        ]
        sd.option_array = [
            SDOption_IP4_EndPoint(addr="192.168.0.1",
                                  l4_proto=0x11,
                                  port=0xd903)
        ]

        # SEND MESSAGE
        p = Ether() / IP(src="10.0.0.11", dst="10.0.0.12") / UDP(
            sport=30490, dport=30490) / sip / sd
        helper.sendp(p, iface=ETH_IFACE_SRC)

        # log test results
        self.addTestCase("send SOME/IP-SD : documentation example",
                         error=err_msg)