Commit dcac440d authored by garciay's avatar garciay
Browse files

Start DHCPv6Component implementation

Add comments
Reorganise group
parent 1ad9eb10
Loading
Loading
Loading
Loading
+64 −18
Original line number Diff line number Diff line
module AtsDSLite_Functions {
    
    // LibCommon
    import from LibCommon_DataStrings {
        const c_16ZeroBytes
    };
    import from LibCommon_Sync {
        function 
            f_connect4SelfOrClientSync, 
@@ -15,6 +18,9 @@ module AtsDSLite_Functions {
    import from LibIpv6_Interface_Templates all;
    import from LibIpv6_Interface_TypesAndValues all;
    import from LibIpv6_CommonRfcsDhcp_TypesAndValues all;
    import from LibIpv6_CommonRfcsDhcp_Functions {
        function f_sendDhcpv6Msg
    };
    
    // DSLite
    import from AtsDSLite_Interfaces {
@@ -26,6 +32,10 @@ module AtsDSLite_Functions {
    
    group initialiseFunctions {
        
        /**
         * @desc Setup communication port
         * @verdict Unchanged
         */
        function f_cf01Up_B4() runs on DSLiteComponent {
            
            // Connect port
@@ -58,6 +68,10 @@ module AtsDSLite_Functions {
    
    group uninitialiseFunctions {
        
        /**
         * @desc Shutdown communication port
         * @verdict Unchanged
         */
        function f_cf01Down_B4() runs on DSLiteComponent {
            // Unmap all ports
            unmap(all component: all port);
@@ -75,12 +89,22 @@ module AtsDSLite_Functions {
    
    group preambleFunctions {
        
        /**
         * @desc Preamble processing for DHCPv6Component
         * @verdict Unchanged
         * @see DHCPv6Component
         */
        function f_preamble_dhcpv6() runs on DHCPv6Component {
            // Connect synchronisation ports
            f_connect4SelfOrClientSync();
            
        } // End of function f_preamble_dhcpv6
        
        /**
         * @desc Preamble processing for DNSComponent
         * @verdict Unchanged
         * @see DNSComponent
         */
        function f_preamble_dns() runs on DHCPv6Component {
            // Connect synchronisation ports
            f_connect4SelfOrClientSync();
@@ -91,10 +115,20 @@ module AtsDSLite_Functions {
    
    group postambleFunctions {
        
        /**
         * @desc Postamble processing for DHCPv6Component
         * @verdict Unchanged
         * @see DHCPv6Component
         */
        function f_postamble_dhcpv6() runs on DHCPv6Component {
            // Nothing to do
        } // End of function f_postamble_dhcpv6
        
        /**
         * @desc Postamble processing for DNSComponent
         * @verdict Unchanged
         * @see DNSComponent
         */
        function f_postamble_dns() runs on DHCPv6Component {
            // Nothing to do
        } // End of function f_postamble_dns
@@ -111,18 +145,22 @@ module AtsDSLite_Functions {
            var Ipv4Packet v_ipv4Pkt;
            var DHCPv6Msg v_dhcpMsg;
//            var DNSMsg v_dnsMsg;
            [] ipPort.receive(mw_ipPkt) -> value v_ipv6Pkt {

            [] ipPort.receive(mw_ipPkt) -> value v_ipv6Pkt { // Await IPv6 packet
                if (ispresent(v_ipv6Pkt.ipv6Payload)) {
                    if (ischosen(v_ipv6Pkt.ipv6Payload.udpMsg)
                            and ispresent(v_ipv6Pkt.ipv6Payload.udpMsg.data)) {
                        // Shall DHCP be handled?
                        if (vc_dhcpv6Component!=null and v_ipv6Pkt.ipv6Payload.udpMsg.sourcePort == int2oct(c_dhcpv6ClientPort, 2)
                                and v_ipv6Pkt.ipv6Payload.udpMsg.destPort == int2oct(c_dhcpv6ServerPort, 2)) {
                        if (
                                (vc_dhcpv6Component != null) and 
                                (v_ipv6Pkt.ipv6Payload.udpMsg.sourcePort == int2oct(c_dhcpv6ClientPort, 2)) and
                                (v_ipv6Pkt.ipv6Payload.udpMsg.destPort == int2oct(c_dhcpv6ServerPort, 2))) 
                        {
                            // Process DHCPv6 packet
                            if (decvalue(oct2bit(valueof(v_ipv6Pkt.ipv6Payload.udpMsg.data)), v_dhcpMsg)!=0) {
                                dhcpv6Port.send(v_dhcpMsg);
                                repeat;
                            }
                            else {
                            } else {
                                log("*** " & __SCOPE__ & "ERROR: Could not successfully decode the DHCPv6 message ***");
                                f_selfOrClientSyncAndVerdict("error", e_error);
                            }
@@ -169,14 +207,29 @@ module AtsDSLite_Functions {
                ipPort.send(v_ipv6Pkt);
                repeat;
            }
            [] dhcpv6Port.receive(DHCPv6Msg:?) -> value v_dhcpMsg {
//                f_sendDhcpv6Msg(v_dhcpMsg, TODO src addr, TODO dst addr, c_dhcpv6ServerPort, c_dhcpv6ClientPort);
                repeat;
            }
// TODO To be removed
//            [] dhcpv6Port.receive(DHCPv6Msg:?) -> value v_dhcpMsg {
////                f_sendDhcpv6Msg(v_dhcpMsg, TODO src addr, TODO dst addr, c_dhcpv6ServerPort, c_dhcpv6ClientPort);
//                f_sendDhcpv6Msg(
//                                v_dhcpMsg,
//                                c_16ZeroBytes,
//                                c_all_DHCP_Servers,
//                                c_dhcpv6ServerPort,
//                                c_dhcpv6ClientPort
//                );                             
//                repeat;
//            }
//            [] dnsPort.receive(DnsMsg:?) -> value v_dnsMsg {
//                f_sendDnsMsg(v_dnsMsg, TODO src addr, TODO dst addr, c_dhcpv6ServerPort, c_dhcpv6ClientPort);
//                repeat;
//            }

// TODO Add support of ICMPv6
            [] ipPort.receive  { // Unsupported IPv6 messages
                tc_ac.stop;
                log("*** " & __SCOPE__ & "INFO: Received an unexpected IPv6 message, process it as an error ***");
                f_selfOrClientSyncAndVerdict("error", e_error);
            }
            [] ipv4Port.receive  { // Unsolicited messages
                tc_ac.stop;
                log("*** " & __SCOPE__ & "ERROR: Received an unexpected IPv4 message, process it as an error ***");
@@ -201,13 +254,6 @@ module AtsDSLite_Functions {
            }
        } // End of altstep a_default 
        
        altstep a_ipv6UnsupportedMessages() runs on DSLiteComponent {
            [] ipPort.receive  { // Unsupported IPv6 messages
                tc_ac.stop;
                log("*** " & __SCOPE__ & "INFO: Received an unexpected IPv6 message, process it as an error ***");
            }
        } // End of altstep a_ipv6UnsupportedMessages 
        
    } // End of group globalSteps
    
} // End of module AtsDSLite_Functions
+60 −29
Original line number Diff line number Diff line
@@ -24,7 +24,23 @@ module AtsDSLite_Interfaces {
            DHCPv6Msg 
    };
    
    group mtcPorts {
    group systemDesc {
        
        /**
         * @desc System interface description
         * @member ipv4Port IPv4 port to be mapped to the Test Adapter
         * @member ipPort IPv6 port to be mapped to the Test Adapter
         */
        type component TestAdapter {
            /** IPv4 port. Only UDP protocol is used */
            port Ipv4Port ipv4Port;
            /** IPv6 port. Only UDP protocol is used */
            port Ipv6Port ipPort;
        } // End of type TestAdapter
        
    } // End of component TestAdapter
    
    group mtcDesc {
    
        /**
         * @desc 
@@ -32,48 +48,56 @@ module AtsDSLite_Interfaces {
         * @member dnsPort
         */
        type component DSLiteComponent extends LibIpv6Node {            
            var AFTRComponent vc_aftrComponent := null;
            var HostComponent vc_hostComponent := null;
            var DHCPv6Component vc_dhcpv6Component := null;
            var DNSComponent vc_dnsComponent := null;
            
            /** DHCPv6 port for DHCPv6Msg message exchanges */
            port DHCPv6Port dhcpv6Port;
            /** DNSv4 port for DNSv4Msg message exchanges */
            port DNSv4Port dnsPort;

            /** AFTR port */
            port Ipv6Port aftrPort;
            
            /** Host IPv6 port to simulate IPv6 client */
            port Ipv6Port ipv6HostPort;
            /** Host IPv4 port to simulate IPv4 client */
            port Ipv4Port ipv4HostPort;
            /** AFTR component reference */
            var AFTRComponent vc_aftrComponent := null;
            /** Host component reference */
            var HostComponent vc_hostComponent := null;
            /** DHCPv6 component reference */
            var DHCPv6Component vc_dhcpv6Component := null;
            /** DNS component reference */
            var DNSComponent vc_dnsComponent := null;
        } // End of component DSLiteComponent
                    
    } // End of group mtcDesc
    
    group componentDesc {
        
        /**
         * @desc 
         * @member ipv4Port
         * @member ipPort
         */
        type component TestAdapter {
            /** IPv4 port. Only UDP protocol is used */
            port Ipv4Port ipv4Port;
            /** IPv6 port. Only UDP protocol is used */
            port Ipv6Port ipPort;
        } // End of type TestAdapter
    
    } // End of group mtcPorts
    
    group componentPorts {
    
        type port DHCPv6Port message {
            inout DHCPv6Msg
        } // End of type DHCPv6Port
        
        /**
         * @desc 
         */
        type port DNSv4Port message {
            inout all// TODO DNS_MSG
        } // End of type DNSPort
        
        /**
         * @desc 
         * @member ipv6Port
         * @member ipv4Port
         * @member tc_ac
         * @member tc_noac
         * @member tc_twait
         */
        type component HostComponent extends SelfSyncComp {
            /** IPv6 port */
            port Ipv6Port ipv6Port;   
            /** IPv4 message */
            port Ipv4Port ipv4Port;   
            /** Timer used for expected received message */
            timer tc_ac:= PX_TAC;
@@ -81,8 +105,15 @@ module AtsDSLite_Interfaces {
            timer tc_noac:= PX_TNOAC;
            /** Timer used for receive meceige */
            timer tc_twait:= PX_TWAIT;
       }
        } // End of component HostComponent
        
        /**
         * @desc 
         * @member aftrPort
         * @member tc_ac
         * @member tc_noac
         * @member tc_twait
         */
        type component AFTRComponent extends SelfSyncComp {
            port Ipv6Port aftrPort;   
            /** Timer used for expected received message */
@@ -91,7 +122,7 @@ module AtsDSLite_Interfaces {
            timer tc_noac:= PX_TNOAC;
            /** Timer used for receive meceige */
            timer tc_twait:= PX_TWAIT;
       }
        } // End of component AFTRComponent
         
        type component DHCPv6Component extends SelfSyncComp {
            /** DHCPv6 port */
@@ -114,6 +145,6 @@ module AtsDSLite_Interfaces {
            timer tc_twait:= PX_TWAIT;
        } // End of component DNSComponent

    } // End of group componentPorts
    } // End of group componentDesc
        
} // End of module AtsDSLite_Interfaces
 No newline at end of file
+59 −45
Original line number Diff line number Diff line
module AtsDSLite_Templates {
    
    // LibIPv6
    import from LibIpv6_CommonRfcs_TypesAndValues {
        type Ipv6Address 
    };
    import from LibIpv6_CommonRfcsDhcp_TypesAndValues {
        type 
            DHCPv6Msg, MsgType, 
            DHCPv6Option 
    };
    import from LibIpv6_Rfc6334Dhcp_TypesAndValues {
        type AFTRNameOption
    };
    import from LibIpv6_Interface_TypesAndValues {
        type UdpPacket;
        const c_udpHdr
    };
    import from LibIpv6_CommonRfcsDhcp_TypesAndValues {
        type DHCPv6Msg, MsgType; 
    };
    import from LibIpv6_Interface_Templates {
        template mw_ipHdr_nextHdr 
    };
    
    group dhcpv6Templates {
        
        
        
        /**
         *  @desc   UDP/DHCPv6 receive packet
         */
        template UdpPacket mw_udpDhcpv6Pkt := {
            ipv6Hdr := mw_ipHdr_nextHdr(c_udpHdr),
            extHdrList := *,
            ipv6Payload := { 
                udpMsg := {
                    sourcePort:= ?,
                    destPort:= ?,
                    msgLength:= ?,
                    checksum:=?,
                    data := ?
                }
            }
        } // End of template mw_udpDhcpv6Pkt
        
        
        group dhcpv6DummySendTemplates {
            
            
            
            
            
        } // End of group dhcpv6DummySendTemplates
        
        group dhcpv6DummyRecvTemplates {
            
            
            /**
             * @desc Genercic receive DHCP Client/Server message
             * @reference http://tools.ietf.org/html/rfc3315#section-6
@@ -57,7 +40,6 @@ module AtsDSLite_Templates {
                options     := ?
            } // End of template mw_dhcpv6_dummy
            
            
            /**
             * @desc Genercic receive DHCP Client/Sollicit message
             * @reference http://tools.ietf.org/html/rfc3315#section-6
@@ -66,6 +48,38 @@ module AtsDSLite_Templates {
                msgType     := e_SOLICIT
            } // End of template mdw_dhcpv6_Sollicit_dummy
            
            /**
             * @desc Receive DHCP Client/Sollicit message to check AFTR-name option
             * @param p_aftrName
             * @reference http://tools.ietf.org/html/rfc3315#section-6
             */  
            template (present) DHCPv6Msg mdw_dhcpv6_Sollicit_aftrName(
                                                                      in template (present) AFTRNameOption p_aftrName
            ) modifies mw_dhcpv6_dummy := {
                // TODO aftrName := p_aftrName
            } // End of template mdw_dhcpv6_Sollicit_aftrName
            
            template (present) AFTRNameOption mw_dhcpv6_aftrName_dummy := {
                optionCode          := e_OPTION_AFTR_NAME,
                optionLen           := ?,
                tunnelEndpointName  := ?
            } // End of template mw_dhcpv6_aftrName_dummy
            
            /**
             * @desc Genercic receive DHCP Client/Reply message
             * @reference http://tools.ietf.org/html/rfc3315#section-6
             */  
            template (present) DHCPv6Msg mdw_dhcpv6_reply_dummy modifies mw_dhcpv6_dummy := {
                msgType     := e_REPLY
            } // End of template mdw_dhcpv6_reply_dummy
            
            /**
             * @desc Receive DHCP Client/Reply message to retrieve IPv6 address provided by the DHCPv6 server
             * @reference http://tools.ietf.org/html/rfc3315#section-6
             */  
            template (present) DHCPv6Msg mdw_dhcpv6_reply_ipv6Address modifies mw_dhcpv6_dummy := {
                // TODO
            } // End of template mdw_dhcpv6_reply_dummy
            
        } // End of group dhcpv6DummyRecvTemplates
        
+21 −64
Original line number Diff line number Diff line
module AtsDSLite_TestCases {
    
    // LibCommon
    import from LibCommon_DataStrings {
        const c_16ZeroBytes
    };
    import from LibCommon_Sync {
        function 
            f_selfOrClientSyncAndVerdictPreamble, f_selfOrClientSyncAndVerdictTestBody, f_selfOrClientSyncAndVerdict,
@@ -17,9 +14,6 @@ module AtsDSLite_TestCases {
            DHCPv6Msg; 
        group dhcpConstants
    };
    import from LibIpv6_CommonRfcsDhcp_Functions {
        function f_sendDhcpv6Msg
    };
    
    // DSLitefrom 
    import from AtsDSLite_Functions all;
@@ -75,61 +69,15 @@ module AtsDSLite_TestCases {
                    // Test adapter configuration
                    
                    // Start all components
                    v_dhcpv6Component.start(f_TC_DSLITE_B4_GWA_BV_001_dhcpv6());
                    vc_dhcpv6Component.start(f_TC_DSLITE_B4_GWA_BV_001_dhcpv6());
                    
                    f_serverSyncNClientsAndStop(1, { c_prDone, c_tbDone, c_poDone });
                    
//                    // Preamble
//                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
//                    log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");
                                        
                    // Test Body
                    // Clause 'when': 
//                    action("the IUT goes online");
                    
                    // Clause 'then': 
//                    while (v_exitLoop == false) {
//                        tc_ac.start;
//                        alt {
//                            [] ipPort.receive( // Receive an UDP/DHCPv6 packet
//                                mw_udpDhcpv6Pkt
//                            ) { 
//                                tc_ac.stop;
//                                // Extract the DHCP message
//                                if (0 != decvalue(oct2bit(mw_udpDhcpv6Pkt.ipv6Payload.udpMsg.data), v_dHCPv6Msg)) {
//                                    // TODO 
//                                } else { // Send it to DHCPv6 component
//                                    dhcpv6Port.send(v_dHCPv6Msg);
//                                }
//                            }
//                            // FIXME Receive DNS/DHCPv6 packet
//                            [] ipv4Port.receive  { // TODO To ne continued
//                                tc_ac.stop;
//                                // TODO Implement processing
//                            }
//                            [] a_ipv6UnsupportedMessages() {
//                            }
//                            [] dhcpv6Port.receive(
//                                mw_dhcpv6_dummy
//                            ) -> value v_dHCPv6Msg {
//                                // Forward message to the IUT
//                                tc_ac.stop;
//                                f_sendDhcpv6Msg(
//                                                v_dHCPv6Msg,
//                                                c_16ZeroBytes,
//                                                c_all_DHCP_Servers,
//                                                c_dhcpv6ClientPort,
//                                                c_dhcpv6ServerPort
//                                );                             
//                            }
//                            [] tc_ac.timeout {
//                                log("*** " & __SCOPE__ & ": INCONC: Expected BTP packet not received ***");
//                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
//                                v_exitLoop := true;
//                            }   
//                        } // End of 'alt' statement
//                        
//                    } // End of 'while' statement
                    action("the IUT goes online");
                    
                    // Clause 'then': Nothing to do, refer to a_default
        
                    // Postamble
                    f_cf01Down_B4();
@@ -138,9 +86,14 @@ module AtsDSLite_TestCases {
                
                group f_TC_DSLITE_B4_GWA_BV_001 {
                    
                    /**
                     * @desc Implement DHCPv6 client/server protocol
                     * @verdict 'pass' on success, 'inconc' on 'timeout', fail otherwise
                     */
                    function f_TC_DSLITE_B4_GWA_BV_001_dhcpv6() runs on DHCPv6Component {
                        
                        // Local variables
                        var DHCPv6Msg v_dhcpMsg;
                         
                        // Preamble
                        // Clause 'Initial conditions'
@@ -149,15 +102,19 @@ module AtsDSLite_TestCases {
                        log("*** " & __SCOPE__ & ": INFO: Preamblue done. ***");
                        
                        // Test Body
                        // Clause 'when': the IUT receives a UL-Request
                        
                        // Clause 'then': the IUT sends a UL-Answer
                        // Clause 'when': the IUT sends a DHCPv6 Request to DHCPv6 Server
                        tc_ac.start;
                        alt {
                            [] dhcpv6Port.receive(
                                mdw_dhcpv6_Sollicit_dummy // FIXME To be refined
                            ) { 
                                // Send UDP/ADVERTISE
                            [] dhcpv6Port.receive(                  // Await Sollicit DHCPv6 Request to DHCPv6 Server
                                mdw_dhcpv6_Sollicit_aftrName(       //     containing the Option field
                                    mw_dhcpv6_aftrName_dummy        //         indicating the AFTR-name DHCPv6 Option (value 64)
                            )) { 
                                // Nothing to do
                            }
                            [] dhcpv6Port.receive(                  // Await Reply message
                                mdw_dhcpv6_reply_ipv6Address
                            ) -> value v_dhcpMsg { 
                                // TODO Store the IPv6 address for future uses
                                
                            }
                            [] tc_ac.timeout {