4 Replies Latest reply on Jan 27, 2010 9:49 AM by tb_ng

    Converting IP address in Binary to Std format??

      Hi,

       

      I am using the EPOEvents table and I need to convert the IP address field in the std format (xxx.xxx.xxx.xxx)

       

      I have used this function to atleast convert this to binary from default int format. But I am not able to convert this further to

      std format

       

       

      dbo.epoConvertIntToIPV4Binary(E1.SourceIPV4)

       

      Please help..

       

      Thanks,

      Micks

        • 1. Re: Converting IP address in Binary to Std format??
          Sailendra Pamidi

          the RSD inbuilt function converts the IPV4 int value to string (as noted in reply to your other post)

           

          RSDFN_ConvertIntToIPString(AnalyzerIPv4)

          • 2. Re: Converting IP address in Binary to Std format??

            Hey Sailendra,

             

            Thanks for helping. But This function RSDFN_ConvertIntToIPString is not there in my  funtions->scalar-valued-functions->..

             

             

            I tried running the command but it says 'RSDFN_ConvertIntToIPString' is not a recognized built-in function name.

             

            Which Epo version are u using and can u send me this functions location and definition..

             

            thanks a lot,

            micks

            • 3. Re: Converting IP address in Binary to Std format??
              GWIRT

              If you are using ePO 4.0, you will need to install Rogue System Detection to get this function.

              • 4. Re: Converting IP address in Binary to Std format??
                tb_ng

                Thanks to the information from Greg's post, I was able to find a way to do this without installing Rogue System detection -- which I don't have approval to do in my environment (at least not yet).  I was able to extract the code from the RSD installation files that creates the function and use that to create a new stand-alone function.  I would recommend changing the name of the function (RSDFN_ConvertIntToIPString) so that any future installs/upgrades of RSD will not be impacted.  I just changed the RSDFN prefix on mine.

                 

                 

                CREATE FUNCTION  [dbo].[RSDFN_ConvertIntToIPString]
                (
                    @ipin int
                )
                RETURNS  CHAR(15)
                AS
                BEGIN
                declare @o1 bigint, @o2 bigint, @o3 bigint, @o4  bigint;
                declare @ip bigint;
                -- This is the magic epo conversion  size...
                    set @ip = (CAST(@ipin as bigint) + 2147483647) + 1;
                    SET @o1 = @ip / 16777216;
                    SET  @ip = @ip % 16777216;
                    SET @o2 = @ip / 65536;
                    SET @ip = @ip %  65536;
                    SET @o3 = @ip / 256;
                    SET @ip = @ip % 256;
                    SET @o4 =  @ip;
                    RETURN
                        CONVERT(VARCHAR(4),  @o1) + '.' +
                        CONVERT(VARCHAR(4), @o2) + '.' +
                         CONVERT(VARCHAR(4), @o3) + '.' +
                        CONVERT(VARCHAR(4),  @o4)
                END