#!/bin/bash

# Return 0 if the given IP is private
# Return 1 if the given IP is public
# Return 2 if the IP is not valid

iplist=`grep hmc_address /opt/ccfw/data/network/network_config.xml | cut -d'=' -f2 | cut -d' ' -f1 | cut -d'"' -f2`
ip_addr=$1
if [ "$ip_addr" != "" ]; then
   for i in $iplist
   do
     if [ "$ip_addr" == "$i" ]; then
        exit 0
     fi
   done
else
  exit 2
fi
exit 1

