Bonjour à tous,
J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber.
Je souhaiterais convertir ces Ipnumbers en IpAdress.
J'ai la fonction de transformation en Perl :
Code:
my (@octets,$i,$ip_number,$ip_number_display,
$number_convert,$ip_address);
$ip_number_display = $ip_number = $ARGV[0];
chomp($ip_number);
for($i = 3; $i >= 0; $i--) {
$octets[$i] = ($ip_number & 0xFF);
$ip_number >>= 8;
}
$ip_address = join('.', @octets);
print "\nThe IP Number $ip_number_display converts to the
IP Address $ip_address.\n";
J'ai auss la théorie :
Code:
Let IP = the 32-bit unsigned integer representation of the IP address
ip1 = octet 1 of 4 (high-order)
ip2 = octet 2 of 4
ip3 = octet 3 of 4
ip4 = octet 4 of 4 (low-order)
>> = bitwise shift right operator; takes an operand of the number
bits to shift
AND = bitwise AND operator
Then,
ip1 = IP >> 24
ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16
ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8
ip4 = (IP AND 00000000 00000000 00000000 11111111)
IP = ip1 . ip2 . ip3 . ip4
Par contre je n'ai aucune notion de programmation sous access.
Si quelqun voulais bien m'aider cela serait sympa.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Léo
Svp aidez moi. Je suis même prêt à payer !
"Léo" a écrit dans le message de news:4235f33e$0$9755$
Bonjour à tous, J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber. Je souhaiterais convertir ces Ipnumbers en IpAdress. J'ai la fonction de transformation en Perl : Code:
my (@octets,$i,$ip_number,$ip_number_display, $number_convert,$ip_address); $ip_number_display = $ip_number = $ARGV[0]; chomp($ip_number); for($i = 3; $i >= 0; $i--) { $octets[$i] = ($ip_number & 0xFF); $ip_number >>= 8; } $ip_address = join('.', @octets); print "nThe IP Number $ip_number_display converts to the
IP Address $ip_address.n";
J'ai auss la théorie :
Code:
Let IP = the 32-bit unsigned integer representation of the IP address
ip1 = octet 1 of 4 (high-order) ip2 = octet 2 of 4 ip3 = octet 3 of 4 ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the number
bits to shift AND = bitwise AND operator
Then, ip1 = IP >> 24 ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16 ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8 ip4 = (IP AND 00000000 00000000 00000000 11111111)
IP = ip1 . ip2 . ip3 . ip4
Par contre je n'ai aucune notion de programmation sous access. Si quelqun voulais bien m'aider cela serait sympa.
@+
Léo
Svp aidez moi.
Je suis même prêt à payer !
"Léo" <no@no.com> a écrit dans le message de
news:4235f33e$0$9755$636a15ce@news.free.fr...
Bonjour à tous,
J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber.
Je souhaiterais convertir ces Ipnumbers en IpAdress.
J'ai la fonction de transformation en Perl :
Code:
my (@octets,$i,$ip_number,$ip_number_display,
$number_convert,$ip_address);
$ip_number_display = $ip_number = $ARGV[0];
chomp($ip_number);
for($i = 3; $i >= 0; $i--) {
$octets[$i] = ($ip_number & 0xFF);
$ip_number >>= 8;
}
$ip_address = join('.', @octets);
print "nThe IP Number $ip_number_display converts to
the
IP Address $ip_address.n";
J'ai auss la théorie :
Code:
Let IP = the 32-bit unsigned integer representation of the IP
address
ip1 = octet 1 of 4 (high-order)
ip2 = octet 2 of 4
ip3 = octet 3 of 4
ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the
number
bits to shift
AND = bitwise AND operator
Then,
ip1 = IP >> 24
ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16
ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8
ip4 = (IP AND 00000000 00000000 00000000 11111111)
IP = ip1 . ip2 . ip3 . ip4
Par contre je n'ai aucune notion de programmation sous access.
Si quelqun voulais bien m'aider cela serait sympa.
"Léo" a écrit dans le message de news:4235f33e$0$9755$
Bonjour à tous, J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber. Je souhaiterais convertir ces Ipnumbers en IpAdress. J'ai la fonction de transformation en Perl : Code:
my (@octets,$i,$ip_number,$ip_number_display, $number_convert,$ip_address); $ip_number_display = $ip_number = $ARGV[0]; chomp($ip_number); for($i = 3; $i >= 0; $i--) { $octets[$i] = ($ip_number & 0xFF); $ip_number >>= 8; } $ip_address = join('.', @octets); print "nThe IP Number $ip_number_display converts to the
IP Address $ip_address.n";
J'ai auss la théorie :
Code:
Let IP = the 32-bit unsigned integer representation of the IP address
ip1 = octet 1 of 4 (high-order) ip2 = octet 2 of 4 ip3 = octet 3 of 4 ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the number
bits to shift AND = bitwise AND operator
Then, ip1 = IP >> 24 ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16 ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8 ip4 = (IP AND 00000000 00000000 00000000 11111111)
IP = ip1 . ip2 . ip3 . ip4
Par contre je n'ai aucune notion de programmation sous access. Si quelqun voulais bien m'aider cela serait sympa.
@+
Léo
Gilles
Svp aidez moi. Je suis même prêt à payer !
Bonjour à tous, J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber. Je souhaiterais convertir ces Ipnumbers en IpAdress. J'ai la fonction de transformation en Perl : Code: my (@octets,$i,$ip_number,$ip_number_display, $number_convert,$ip_address); $ip_number_display = $ip_number = $ARGV[0]; chomp($ip_number); for($i = 3; $i >= 0; $i--) { $octets[$i] = ($ip_number & 0xFF); $ip_number >>= 8; } $ip_address = join('.', @octets); print "nThe IP Number $ip_number_display converts to the
IP Address $ip_address.n"; J'ai auss la théorie : Code: Let IP = the 32-bit unsigned integer representation of the IP address
ip1 = octet 1 of 4 (high-order) ip2 = octet 2 of 4 ip3 = octet 3 of 4 ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the number
bits to shift AND = bitwise AND operator Then, ip1 = IP >> 24 ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16 ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8 ip4 = (IP AND 00000000 00000000 00000000 11111111) IP = ip1 . ip2 . ip3 . ip4 Par contre je n'ai aucune notion de programmation sous access. Si quelqun voulais bien m'aider cela serait sympa. @+ Léo
Bonjour, Léo
Inutile de proposer de l'argent (personnellement, je suis incorruptible;-)). Apparemment, il s'agit d'extraire chaque octet d'un mot de quatre octets. Après essais avec AND et MOD (qui plantent tout deux pour cause de dépassement de capacité), je me suis rabattu sur la définition mathématique du MOD pour pondre ceci:
Public Function IPNumToIPAddress(ByVal IPNum As Variant) As String Dim IP1 As Byte Dim IP2 As Byte Dim IP3 As Byte Dim IP4 As Byte Dim IP_tmp As Variant On Error GoTo Sortie IP_tmp = IPNum IP4 = IP_tmp - (Fix(IPNum / 256) * 256) IP_tmp = Fix(IPNum / 256) IP3 = IP_tmp - (Fix(IP_tmp / 256) * 256) IP_tmp = Fix(IP_tmp / 256) IP2 = IP_tmp - (Fix(IP_tmp / 256) * 256) IP_tmp = Fix(IP_tmp / 256) IP1 = IP_tmp - (Fix(IP_tmp / 256) * 256) IPNumToIPAddress = IP1 & "." & IP2 & "." & IP3 & "." & IP4 Exit Function Sortie: IPNumToIPAddress = "" End Function
Si une erreur se produit, la fonction renvoie une chaîne de longueur nulle. Place cette fonction dans un module. Tu peux par exemple l'utiliser dans une requête mise à jour de ce style: UPDATE Table1 SET Table1.IPAdress = IPNumToIPAddress([IPNum])
Bonne continuation
Svp aidez moi.
Je suis même prêt à payer !
Bonjour à tous,
J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber.
Je souhaiterais convertir ces Ipnumbers en IpAdress.
J'ai la fonction de transformation en Perl :
Code:
my (@octets,$i,$ip_number,$ip_number_display,
$number_convert,$ip_address);
$ip_number_display = $ip_number = $ARGV[0];
chomp($ip_number);
for($i = 3; $i >= 0; $i--) {
$octets[$i] = ($ip_number & 0xFF);
$ip_number >>= 8;
}
$ip_address = join('.', @octets);
print "nThe IP Number $ip_number_display converts to
the
IP Address $ip_address.n";
J'ai auss la théorie :
Code:
Let IP = the 32-bit unsigned integer representation of the IP
address
ip1 = octet 1 of 4 (high-order)
ip2 = octet 2 of 4
ip3 = octet 3 of 4
ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the
number
bits to shift
AND = bitwise AND operator
Then,
ip1 = IP >> 24
ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16
ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8
ip4 = (IP AND 00000000 00000000 00000000 11111111)
IP = ip1 . ip2 . ip3 . ip4
Par contre je n'ai aucune notion de programmation sous access.
Si quelqun voulais bien m'aider cela serait sympa.
@+
Léo
Bonjour, Léo
Inutile de proposer de l'argent (personnellement, je suis incorruptible;-)).
Apparemment, il s'agit d'extraire chaque octet d'un mot de quatre octets.
Après essais avec AND et MOD (qui plantent tout deux pour cause de
dépassement de capacité), je me suis rabattu sur la définition mathématique
du MOD pour pondre ceci:
Public Function IPNumToIPAddress(ByVal IPNum As Variant) As String
Dim IP1 As Byte
Dim IP2 As Byte
Dim IP3 As Byte
Dim IP4 As Byte
Dim IP_tmp As Variant
On Error GoTo Sortie
IP_tmp = IPNum
IP4 = IP_tmp - (Fix(IPNum / 256) * 256)
IP_tmp = Fix(IPNum / 256)
IP3 = IP_tmp - (Fix(IP_tmp / 256) * 256)
IP_tmp = Fix(IP_tmp / 256)
IP2 = IP_tmp - (Fix(IP_tmp / 256) * 256)
IP_tmp = Fix(IP_tmp / 256)
IP1 = IP_tmp - (Fix(IP_tmp / 256) * 256)
IPNumToIPAddress = IP1 & "." & IP2 & "." & IP3 & "." & IP4
Exit Function
Sortie:
IPNumToIPAddress = ""
End Function
Si une erreur se produit, la fonction renvoie une chaîne de longueur nulle.
Place cette fonction dans un module. Tu peux par exemple l'utiliser dans une
requête mise à jour de ce style:
UPDATE Table1 SET Table1.IPAdress = IPNumToIPAddress([IPNum])
Bonjour à tous, J'ai une base de donnée où j'ai des Adresses Ip sous la forme Ipnumber. Je souhaiterais convertir ces Ipnumbers en IpAdress. J'ai la fonction de transformation en Perl : Code: my (@octets,$i,$ip_number,$ip_number_display, $number_convert,$ip_address); $ip_number_display = $ip_number = $ARGV[0]; chomp($ip_number); for($i = 3; $i >= 0; $i--) { $octets[$i] = ($ip_number & 0xFF); $ip_number >>= 8; } $ip_address = join('.', @octets); print "nThe IP Number $ip_number_display converts to the
IP Address $ip_address.n"; J'ai auss la théorie : Code: Let IP = the 32-bit unsigned integer representation of the IP address
ip1 = octet 1 of 4 (high-order) ip2 = octet 2 of 4 ip3 = octet 3 of 4 ip4 = octet 4 of 4 (low-order)
= bitwise shift right operator; takes an operand of the number
bits to shift AND = bitwise AND operator Then, ip1 = IP >> 24 ip2 = (IP AND 00000000 11111111 00000000 00000000) >> 16 ip3 = (IP AND 00000000 00000000 11111111 00000000) >> 8 ip4 = (IP AND 00000000 00000000 00000000 11111111) IP = ip1 . ip2 . ip3 . ip4 Par contre je n'ai aucune notion de programmation sous access. Si quelqun voulais bien m'aider cela serait sympa. @+ Léo
Bonjour, Léo
Inutile de proposer de l'argent (personnellement, je suis incorruptible;-)). Apparemment, il s'agit d'extraire chaque octet d'un mot de quatre octets. Après essais avec AND et MOD (qui plantent tout deux pour cause de dépassement de capacité), je me suis rabattu sur la définition mathématique du MOD pour pondre ceci:
Public Function IPNumToIPAddress(ByVal IPNum As Variant) As String Dim IP1 As Byte Dim IP2 As Byte Dim IP3 As Byte Dim IP4 As Byte Dim IP_tmp As Variant On Error GoTo Sortie IP_tmp = IPNum IP4 = IP_tmp - (Fix(IPNum / 256) * 256) IP_tmp = Fix(IPNum / 256) IP3 = IP_tmp - (Fix(IP_tmp / 256) * 256) IP_tmp = Fix(IP_tmp / 256) IP2 = IP_tmp - (Fix(IP_tmp / 256) * 256) IP_tmp = Fix(IP_tmp / 256) IP1 = IP_tmp - (Fix(IP_tmp / 256) * 256) IPNumToIPAddress = IP1 & "." & IP2 & "." & IP3 & "." & IP4 Exit Function Sortie: IPNumToIPAddress = "" End Function
Si une erreur se produit, la fonction renvoie une chaîne de longueur nulle. Place cette fonction dans un module. Tu peux par exemple l'utiliser dans une requête mise à jour de ce style: UPDATE Table1 SET Table1.IPAdress = IPNumToIPAddress([IPNum])