Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hardware id ipdiscover #350

Merged
merged 3 commits into from
Oct 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Apache/Ocsinventory/Server/Capacities/Ipdiscover.pm
Original file line number Diff line number Diff line change
Expand Up @@ -280,30 +280,30 @@ sub _ipdiscover_read_result{
my $row_verif = $request_verif->fetchrow_hashref;

if (defined $row_verif->{'TAG'}) {
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=? WHERE MAC=? AND TAG=?');
$update_req->execute($_->{I}, $mask, $subnet, $_->{N}, $_->{M}, $tag);
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=?, HARDWARE_ID=? WHERE MAC=? AND TAG=?');
$update_req->execute($_->{I}, $mask, $subnet, $_->{N}, $DeviceID, $_->{M}, $tag);
} else {
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=?, TAG=? WHERE MAC=?');
$update_req->execute($_->{I}, $mask, $subnet, $_->{N}, $tag, $_->{M});
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=?, HARDWARE_ID=?, TAG=? WHERE MAC=?');
$update_req->execute($_->{I}, $mask, $subnet, $_->{N}, $DeviceID, $tag, $_->{M});
}
unless($update_req->rows){
$insert_req = $dbh->prepare('INSERT INTO netmap(IP, MAC, MASK, NETID, NAME, TAG) VALUES(?,?,?,?,?,?)');
$insert_req->execute($_->{I}, $_->{M}, $mask, $subnet, $_->{N}, $tag);
$insert_req = $dbh->prepare('INSERT INTO netmap(IP, MAC, MASK, NETID, NAME, TAG, HARDWARE_ID) VALUES(?,?,?,?,?,?,?)');
$insert_req->execute($_->{I}, $_->{M}, $mask, $subnet, $_->{N}, $tag, $DeviceID);
}
}
} else {
# We insert the results (MAC/IP)
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=? WHERE MAC=?');
$insert_req = $dbh->prepare('INSERT INTO netmap(IP, MAC, MASK, NETID, NAME) VALUES(?,?,?,?,?)');
$update_req = $dbh->prepare('UPDATE netmap SET IP=?,MASK=?,NETID=?,DATE=NOW(), NAME=?, HARDWARE_ID=? WHERE MAC=?');
$insert_req = $dbh->prepare('INSERT INTO netmap(IP, MAC, MASK, NETID, NAME, HARDWARE_ID) VALUES(?,?,?,?,?,?)');

for(@$base){
unless($_->{I}=~/^(\d{1,3}(?:\.\d{1,3}){3})$/ and $_->{M}=~/.{2}(?::.{2}){5}/){
&_log(1003,'ipdiscover','bad_result') if $ENV{'OCS_OPT_LOGLEVEL'};
next;
}
$update_req->execute($_->{I}, $mask, $subnet, $_->{N}, $_->{M});
$update_req->execute($_->{I}, $mask, $subnet, $_->{N},$DeviceID, $_->{M});
unless($update_req->rows){
$insert_req->execute($_->{I}, $_->{M}, $mask, $subnet, $_->{N});
$insert_req->execute($_->{I}, $_->{M}, $mask, $subnet, $_->{N},$DeviceID);
}
}
}
Expand Down