<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::Misc::FixIPFormat

NAME

FS::Misc::FixIPFormat - Functions to repair bad IP address input

DESCRIPTION

Provides functions for freeside_upgrade to check IP address storage for user-entered leading 0's in IP addresses. When read from database, NetAddr::IP would treat the number as octal isntead of decimal. If a user entered 10.0.0.052, this may get invisibly translated to 10.0.0.42 when exported. Base8:52 = Base0:42

Tied to freeside_upgrade with journal name TABLE__fixipformat

see: RT# 80555

SYNOPSIS

Usage:

    # require, not use - this module is only run once
    require FS::Misc::FixIPFormat;

    my $error = FS::Misc::FixIPFormat::fix_bad_addresses_in_table(
      'svc_broadband', 'svcnum', 'ip_addr'
    );
    die "oh no!" if $error;

fix_bad_addresses_in_table TABLE, ID_COLUMN, IP_COLUMN

$error = fix_bad_addresses_in_table( 'svc_broadband', 'svcnum', 'ip_addr' );

find_bad_addresses_in_table TABLE, ID_COLUMN, IP_COLUMN

@id = find_bad_addresses_in_table( 'svc_broadband', 'svcnum', 'ip_addr' );

fix_ip_for_record ID, TABLE, ID_COLUMN, IP_COLUMN

Attempt to strip the leading 0 from a stored IP address record. If the corrected IP address would be a duplicate of another record in the same table, thow an exception.

$error = fix_ip_for_record( 1001, 'svc_broadband', 'svcnum', 'ip_addr', );

<% include ('/elements/footer.html' ) %>