def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        q = DHCP6_Advertise(trid=0x1234)/ \
                DHCP6OptServerId(duid=builder.duid(self.target(1).ll_addr()))/ \
                    DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))
        self.node(1).send(IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.target(1).link_local_ip()))/UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort)/q)

        r = self.node(1).iface(0).received(src=(self.target(1).link_local_ip()))
        assertEqual(0, len(r), "Did not expect to receive any packets.")
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        q = DHCP6_Advertise(trid=0x1234)/ \
                DHCP6OptServerId(duid=builder.duid(self.target(1).ll_addr()))/ \
                    DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))
        self.node(1).send(
            IPv6(src=str(self.node(1).link_local_ip()),
                 dst=str(self.target(1).link_local_ip())) /
            UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort) / q)

        r = self.node(1).iface(0).received(
            src=(self.target(1).link_local_ip()))
        assertEqual(0, len(r), "Did not expect to receive any packets.")
Example #3
0
    def build_dhcpv6_decline(self, q, server, client, T1=5400, T2=3600):
        p = DHCP6_Decline(trid=q.trid)/ \
                DHCP6OptServerId(duid=q[DHCP6OptServerId].duid)/ \
                    DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                        DHCP6OptIA_NA(iaid=q.iaid, T1=T1, T2=T2, ianaopts=DHCP6OptIAAddress(addr=q[DHCP6OptIAAddress].addr))

        return p
Example #4
0
    def build_dhcpv6_reply(self,
                           q,
                           server,
                           client,
                           ias=True,
                           T1=300,
                           T2=300,
                           trid=None,
                           dns_servers=[],
                           dns_domains=[],
                           pref=True,
                           server_id=True):
        p = DHCP6_Reply(trid=(trid == None and q.trid or trid))/ \
                DHCP6OptClientId(duid=q[DHCP6OptClientId].duid)

        if server_id:
            p = p / DHCP6OptServerId(
                duid=builder.duid(server.iface(0).ll_addr))

        if ias:
            for ia in builder.ias(q[DHCP6OptIA_NA], client, T1, T2):
                p = p / ia

        if len(dns_servers) > 0:
            p = p / DHCP6OptDNSServers(dnsservers=dns_servers)

        if len(dns_domains) > 0:
            p = p / DHCP6OptDNSDomains(dnsdomains=dns_domains)

        if pref:
            p = p / DHCP6OptPref()

        return p
Example #5
0
    def build_dhcpv6_decline(self, q, server, client, T1=5400, T2=3600):
        p = DHCP6_Decline(trid=q.trid)/ \
                DHCP6OptServerId(duid=q[DHCP6OptServerId].duid)/ \
                    DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                        DHCP6OptIA_NA(iaid=q.iaid, T1=T1, T2=T2, ianaopts=DHCP6OptIAAddress(addr=q[DHCP6OptIAAddress].addr))

        return p
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        o = DHCP6_InfoRequest(trid=0x1234)/ \
                DHCP6OptClientId(duid=builder.duid("fe:80:90:01:02:03"))/ \
                    DHCP6OptElapsedTime(elapsedtime=2000)/ \
                        DHCP6OptOptReq()
        m = DHCP6_RelayForward(linkaddr="9001::1", peeraddr="fe80:9001::1", hopcount=2)/ \
                DHCP6OptIfaceId(ifaceid="eth0")/ \
                    DHCP6OptRelayMsg()/o
        q = DHCP6_RelayForward(linkaddr="::", peeraddr=str(self.node(2).link_local_ip()), hopcount=1)/ \
                DHCP6OptIfaceId(ifaceid="eth0")/ \
                    DHCP6OptRelayMsg()/m
        self.router(1).send(IPv6(src=str(self.router(1).iface(1).link_local_ip()), dst=AllDHCPv6RelayAgentsAndServers)/UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort)/q, iface=1)

        self.logger.info("Checking for a DHCPv6 Relay Reply message.")
        r2 = self.node(1).received(src=self.target(1).link_local_ip(), dst=self.router(1).link_local_ip(iface=1), type=DHCP6_RelayReply)
        assertEqual(1, len(r2), "expected to receive a DHCPv6 Relay Reply")
        p = r2[0]

        assertEqual(q.hopcount, p.hopcount, "Reply's hop count does not match Information Request's hop count.")
        assertEqual(q.linkaddr, p.linkaddr, "Reply's link address does not match Information Request's link address.")
        assertEqual(q.peeraddr, p.peeraddr, "Reply's peer address does not match Information Request's peer address.")
        assertHasLayer(DHCP6OptRelayMsg, p)
        assertEqual(len(p[DHCP6OptRelayMsg][1]), p[DHCP6OptRelayMsg].optlen, "Reply's Relay Message Option has an incorrect option length.")
        assertHasLayer(DHCP6_RelayReply, p[DHCP6OptRelayMsg][1])
        assertEqual(q.hopcount, p[DHCP6OptRelayMsg][1].hopcount, "Reply's hop count does not match Information Request's hop count.")
        assertEqual(q.linkaddr, p[DHCP6OptRelayMsg][1].linkaddr, "Reply's link address does not match Information Request's link address.")
        assertEqual(q.peeraddr, p[DHCP6OptRelayMsg][1].peeraddr, "Reply's peer address does not match Information Request's peer address.")
        assertHasLayer(DHCP6OptRelayMsg, p[DHCP6OptRelayMsg][1])
        assertHasLayer(DHCPv6_Reply, p[DHCP6OptRelayMsg][1])
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        p = DHCP6_InfoRequest(trid=0x1324)/ \
                DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))/ \
                    DHCP6OptServerId(duid=builder.duid(self.target(1).link_local_ip()))/ \
                        DHCP6OptElapsedTime(elapsedtime=2000)/ \
                            DHCP6OptOptReq()

        q = self.build_dhcpv6_information_request(self.node(1))
        self.node(1).send(IPv6(src=str(self.node(1).link_local_ip()), dst=str(self.target(1).link_local_ip()))/UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort)/q)

        self.logger.info("Checking for a DHCPv6 Relay Reply message.")
        r2 = self.node(1).received(src=str(self.target(1).link_local_ip()), dst=str(self.node(1).link_local_ip()), type=DHCP6_RelayReply)
        assertEqual(0, len(r2), "did not expect to receive a DHCPv6 Relay Reply")
Example #8
0
 def build_dhcpv6_information_request(self,
                                      client,
                                      trid=0x1234,
                                      reqopts=[23, 24]):
     p = DHCP6_InfoRequest(trid=trid)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptElapsedTime(elapsedtime=2000)/ \
                     DHCP6OptOptReq(reqopts=reqopts)
     return p
Example #9
0
 def build_dhcpv6_solicit(self,
                          client,
                          iaid=0x4321,
                          trid=0x1234,
                          T1=300,
                          T2=300):
     p = DHCP6_Solicit(trid=trid)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptOptReq()/ \
                     DHCP6OptIA_NA(iaid=iaid, T1=T1, T2=T2)
     return p
Example #10
0
    def build_dhcpv6_confirm(self,
                             server,
                             client,
                             ip,
                             iaid=0x87654322,
                             trid=0x1235,
                             T1=300,
                             T2=300):
        p = DHCP6_Confirm(trid=trid)/ \
                DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                    DHCP6OptIA_NA(iaid=iaid, T1=T1, T2=T2, ianaopts=DHCP6OptIAAddress(addr=ip))

        return p
Example #11
0
    def run(self):
        #self.ui.ask("Restart DHCPv6 on the NUT. Enter 'y' and press enter when you have done this.")
        self.logger.info("Sending an Information Request message from TN1.")

        p = DHCP6_InfoRequest(trid=0x1324)/ \
                DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))/ \
                    DHCP6OptServerId(duid=builder.duid(self.target(1).link_local_ip()))/ \
                        DHCP6OptElapsedTime(elapsedtime=2000)/ \
                            DHCP6OptOptReq()

        q = self.build_dhcpv6_information_request(self.node(1))
        self.node(1).send(
            IPv6(src=str(self.node(1).link_local_ip()),
                 dst=str(self.target(1).link_local_ip())) /
            UDP(sport=DHCPv6SourcePort, dport=DHCPv6DestPort) / q)

        self.logger.info("Checking for a DHCPv6 Relay Reply message.")
        r2 = self.node(1).received(src=str(self.target(1).link_local_ip()),
                                   dst=str(self.node(1).link_local_ip()),
                                   type=DHCP6_RelayReply)
        assertEqual(0, len(r2),
                    "did not expect to receive a DHCPv6 Relay Reply")
Example #12
0
    def build_dhcpv6_advertisement(self, s, server, client, options=True, ias=True, T1=300, T2=300):
        a = DHCP6_Advertise(trid=s.trid)/ \
                DHCP6OptServerId(duid=builder.duid(server.iface(0).ll_addr))/ \
                    DHCP6OptClientId(duid=s[DHCP6OptClientId].duid)
        if options:
            for option in builder.options(s[DHCP6OptOptReq].reqopts):
                a = a/option
        if ias:
            for ia in builder.ias(s[DHCP6OptIA_NA], client, T1, T2):
                a = a/ia
        a = a/DHCP6OptPref()

        return a
Example #13
0
    def build_dhcpv6_advertisement(self,
                                   s,
                                   server,
                                   client,
                                   options=True,
                                   ias=True,
                                   T1=300,
                                   T2=300):
        a = DHCP6_Advertise(trid=s.trid)/ \
                DHCP6OptServerId(duid=builder.duid(server.iface(0).ll_addr))/ \
                    DHCP6OptClientId(duid=s[DHCP6OptClientId].duid)
        if options:
            for option in builder.options(s[DHCP6OptOptReq].reqopts):
                a = a / option
        if ias:
            for ia in builder.ias(s[DHCP6OptIA_NA], client, T1, T2):
                a = a / ia
        a = a / DHCP6OptPref()

        return a
Example #14
0
    def build_dhcpv6_reply(self, q, server, client, ias=True, T1=300, T2=300, trid=None, dns_servers=[], dns_domains=[], pref=True, server_id=True):
        p = DHCP6_Reply(trid=(trid == None and q.trid or trid))/ \
                DHCP6OptClientId(duid=q[DHCP6OptClientId].duid)

        if server_id:
            p = p/DHCP6OptServerId(duid=builder.duid(server.iface(0).ll_addr))

        if ias:
            for ia in builder.ias(q[DHCP6OptIA_NA], client, T1, T2):
                p = p/ia

        if len(dns_servers) > 0:
            p = p/DHCP6OptDNSServers(dnsservers=dns_servers)

        if len(dns_domains) > 0:
            p = p/DHCP6OptDNSDomains(dnsdomains=dns_domains)

        if pref:
            p = p/DHCP6OptPref()

        return p
Example #15
0
 def build_dhcpv6_release(self, p, server, client):
     p = DHCP6_Release(trid=p.trid+1)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptServerId(duid=p[DHCP6OptServerId].duid)/ \
                     DHCP6OptIA_NA(iaid=p[DHCP6OptIA_NA].iaid + 1, ianaopts=DHCP6OptIAAddress(addr=self.ip_from(p)))
     return p
Example #16
0
 def build_dhcpv6_information_request(self, client, trid=0x1234, reqopts=[23,24]):
     p = DHCP6_InfoRequest(trid=trid)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptElapsedTime(elapsedtime=2000)/ \
                     DHCP6OptOptReq(reqopts=reqopts)
     return p
Example #17
0
 def build_dhcpv6_solicit(self, client, iaid=0x4321, trid=0x1234, T1=300, T2=300):
     p = DHCP6_Solicit(trid=trid)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptOptReq()/ \
                     DHCP6OptIA_NA(iaid=iaid, T1=T1, T2=T2)
     return p
Example #18
0
 def build_dhcpv6_renew(self, p, server, client):
     p = DHCP6_Renew(trid=p.trid+1)/ \
             DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                 DHCP6OptServerId(duid=p[DHCP6OptServerId].duid)/ \
                     DHCP6OptIA_NA(iaid=p[DHCP6OptIA_NA].iaid + 1, ianaopts=DHCP6OptIAAddress(addr=self.ip_from(p)))
     return p
Example #19
0
 def build_dhcpv6_request(self, a, server, client):
     p = DHCP6_Request(trid=a.trid)/ \
             DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))/ \
                 DHCP6OptServerId(duid=a[DHCP6OptServerId].duid)/ \
                     DHCP6OptIA_NA(ianaopts=DHCP6OptIAAddress(addr=a[DHCP6OptIAAddress].addr))
     return p
Example #20
0
    def build_dhcpv6_confirm(self, server, client, ip, iaid=0x87654322, trid=0x1235, T1=300, T2=300):
        p = DHCP6_Confirm(trid=trid)/ \
                DHCP6OptClientId(duid=builder.duid(client.iface(0).ll_addr))/ \
                    DHCP6OptIA_NA(iaid=iaid, T1=T1, T2=T2, ianaopts=DHCP6OptIAAddress(addr=ip))

        return p
Example #21
0
 def build_dhcpv6_request(self, a, server, client):
     p = DHCP6_Request(trid=a.trid)/ \
             DHCP6OptClientId(duid=builder.duid(self.node(1).iface(0).ll_addr))/ \
                 DHCP6OptServerId(duid=a[DHCP6OptServerId].duid)/ \
                     DHCP6OptIA_NA(ianaopts=DHCP6OptIAAddress(addr=a[DHCP6OptIAAddress].addr))
     return p