Commit 0c07bba7 authored by berge's avatar berge
Browse files

Cleaned up GN6 setup

parent d4bc7ebb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -311,12 +311,12 @@ module LibItsGeoNetworking_Functions {
    group geoPositionFunctions {
        
        function f_addPosition(
            in PositionTable v_positionTable,
            inout PositionTable p_positionTable,
            in charstring p_positionKey,
            in LongPosVector p_positionValue
        ) {
            
            v_positionTable[lengthof(v_positionTable)] := {
            p_positionTable[lengthof(p_positionTable)] := {
                key := p_positionKey,
                position := p_positionValue
            };
+98 −47
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ module LibItsIpv6OverGeoNetworking_Functions {
            
            f_cf01Up();
            
            f_addAddresses(vc_addressTable, c_compIut);
            f_addAddresses(vc_addressTable, c_compNodeA);
            
        } // end f_cf01Up

        /**
@@ -70,24 +73,26 @@ module LibItsIpv6OverGeoNetworking_Functions {
        
        function f_sendGeoBroadcastWithRtAdv(
            in template (value) GvlTableEntry p_gvl,
            in template (value) LongPosVector p_position,
            in template (value) Ipv6Address p_sourceAddr,
            in template (value) Ipv6Address p_destinationAddr
            in charstring p_compName
        ) runs on ItsNt {
            
            var AddressTableEntry v_nodeAddresses := f_getAddresses(p_compName);
            var LongPosVector v_nodeLongPosVector := f_getPosition(p_compName);
            
            f_sendGeoNetMessage(
                m_geoNwReq(
                    m_geoNwPduWithPayload(
                        m_geoBroadcastHeader(
                            p_position,
                            p_position,
                            v_nodeLongPosVector,
                            v_nodeLongPosVector,
                            e_vehicleStation,
                            vc_localSeqNumber,
                            f_getGeoBroadcastArea(valueof(p_gvl.area))
                        ),
                        m_ipv6Payload(
                            m_ipv6Packet(
                                p_sourceAddr,
                                p_destinationAddr,
                                v_nodeAddresses.lla,
                                c_allNodesMca,
                                c_icmpHdr,
                                m_rtAdvWithOptions(
                                    m_rtAdvOpt_prefixOpt(
@@ -118,6 +123,10 @@ module LibItsIpv6OverGeoNetworking_Functions {
            return valueof(vc_gvlTable[p_areaIndex]);
        } // end f_getGVL
        
        function f_getTVL() runs on ItsNt return GvlTableEntry {
            return valueof(vc_gvlTable[0]); // FIXME !!!
        } // end f_getTVL
        
        /**
         * @desc    Retrieves the MAC address from the GN address.
         * @param   p_gnAddr The GN address
@@ -170,32 +179,89 @@ module LibItsIpv6OverGeoNetworking_Functions {
        } // end f_createUniqueInterfaceId

        /**
         * @desc  Compute link-local, global, solicited-node multicast IPv6 addresses<br>
         * @desc    Compute link-local, solicited-node multicast IPv6 addresses
         *          and MAC-Solicited-node Address, based on prefix and MAC address
         * @param   p_macAddr MAC Address
         * @param   p_addressTable Address Table
         * @param   p_componentName entity for which addresses are computed and added
         * @return  Address table entry that will contain all the results
         */
        function f_addAddresses(
            inout AddressTable p_addressTable,
            in charstring p_componentName
        ) runs on ItsNt {            
            const UInt8 c_uniIdLen := 64;
            var AddressTableEntry v_addressTableEntry;
            var MacAddress v_macAddr;
            var Oct8 v_interfaceIdReady := int2oct(0,8);
            var Oct3 v_rightPartMac := int2oct(0,3);
            var UInt8 i;

            v_addressTableEntry.key := p_componentName;
            v_macAddr := f_gnAddr2MacAddr(f_getPosition(p_componentName).gnAddr);

            v_addressTableEntry.macAddress := v_macAddr;

            // compute interface ID
            v_interfaceIdReady := f_createUniqueInterfaceId(v_macAddr);
            
            // LLA
            v_addressTableEntry.lla := 'FE80000000000000'O & v_interfaceIdReady;
            
            // get rightPart
            for (i:=3; i<lengthof(v_macAddr); i:=i+1) {
                v_rightPartMac[i-3] := v_macAddr[i];
            }
            
            // SOL_NODE_MCA
            v_addressTableEntry.solNodeMca := 'FF0200000000000000000001FF'O & v_rightPartMac;
            
            // MAC_MCA
            v_addressTableEntry.macSolNodeMca := '3333FF'O & v_rightPartMac;
            
            p_addressTable[lengthof(p_addressTable)] := v_addressTableEntry;

        } // end f_computeAddresses

        function f_getAddresses(
            in charstring p_positionKey
        ) runs on ItsNt 
        return AddressTableEntry {
            
            var AddressTableEntry v_return;
            var integer i := 0;
            
            for (i:=0; i<lengthof(vc_addressTable); i:=i+1) {
                if (vc_addressTable[i].key == p_positionKey) {
                    v_return := vc_addressTable[i];
                }
            }
            
            return v_return;
        } // end  f_getAddresses

        /**
         * @desc    Compute global address based on prefix and MAC address
         * @param   p_compName Component name
         * @param   p_prefix Prefix
         * @param   p_prefixLen Prefix Length
         * @param   p_addressDB Database contining the computed link-local address, global address, solicited-node multicast address and MAC solicited-node multicast address
         * @return  Execution status
         * @return  Global IPv6 address
         */
        function f_createAddresses(
            in MacAddress p_macAddr,
        function f_computeGlobalAddress(
            in charstring p_compName,
            in Oct16 p_prefix, 
            in UInt8 p_prefixLen,
            out AddressDB p_addressDB
        )
        return FncRetCode {
            var UInt8 i;
            const UInt8 c_uniIdLen := 64;
            var Bit128 v_prefixBits := oct2bit(p_prefix);
            var Bit64 v_prefixReadyBits := int2bit(0, 64);
            in UInt8 p_prefixLen
        ) runs on ItsNt
        return Ipv6Address {

            var Oct8 v_prefixReady := int2oct(0,8);            
            var Oct8 v_interfaceIdReady := int2oct(0,8);
            var Oct3 v_rightPartMac := int2oct(0,3);
            var Bit128 v_prefixBits := oct2bit(p_prefix);
            var Bit64 v_prefixReadyBits := int2bit(0, 64);
            var UInt8 i;
            
            if (p_prefixLen > 64) {
                log("**** f_createIpAddresses: Wrong prefixLen ****");
                return e_error;
                log("**** f_computeGlobalAddress: Wrong prefixLen ****");
                return '00000000000000000000000000000000'O;
            }
            else {
                //Fill v_prefixReady with existing Prefix
@@ -204,28 +270,13 @@ module LibItsIpv6OverGeoNetworking_Functions {
                }
                v_prefixReady := bit2oct(v_prefixReadyBits);
            }
            // compute interface ID
            v_interfaceIdReady := f_createUniqueInterfaceId (p_macAddr);
            
            //LLA
            p_addressDB.lla := 'FE80000000000000'O & v_interfaceIdReady;
            
            //GLA
            p_addressDB.gla := v_prefixReady & v_interfaceIdReady;
            
            //get rightPart
            for (i:=3; i<lengthof(p_macAddr); i:=i+1) {
                v_rightPartMac[i-3] := p_macAddr[i];
            }
            
            //SOL_NODE_MCA
            p_addressDB.solNodeMca := 'FF0200000000000000000001FF'O & v_rightPartMac;
            // compute interface ID
            v_interfaceIdReady := f_createUniqueInterfaceId(f_getAddresses(p_compName).macAddress);

            //MAC_MCA
            p_addressDB.macSolNodeMca := '3333FF'O & v_rightPartMac;
            return v_prefixReady & v_interfaceIdReady;
                        
            return e_success;
        }//end f_createIpAddresses
        } // end f_computeGlobalAddress

        /**
         * @desc    Derives the traffic class from the IPv6 TrafficClass field
+6 −10
Original line number Diff line number Diff line
@@ -24,20 +24,16 @@ module LibItsIpv6OverGeoNetworking_TypesAndValues {
        
        type record of GvlTableEntry GvlTable;
        
        type record MacTableEntry {
        type record AddressTableEntry {
            charstring key,
            MacAddress macAddress
        }
        
        type record of MacTableEntry MacTable;
        
        type record AddressDB {
            MacAddress macAddress,
            MacAddress  macSolNodeMca,
            Ipv6Address lla,
            Ipv6Address gla,
            Ipv6Address solNodeMca,
            MacAddress  macSolNodeMca
            Ipv6Address solNodeMca
        }
        
        type record of AddressTableEntry AddressTable;
  
    } // end ipv6OverGeoConfigurationTypes

    group ipv6OverGeoConfigurationValues {
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ module LibIts_Interface {
            
            //variables for Gn6
            var GvlTable vc_gvlTable := {};
            var MacTable vc_macTable := {};
            var AddressTable vc_addressTable := {};
            
        } // end ItsNt