# DHCP Server Configuration file for route mode CMTS
#
authoritative;
option domain-name "localdomain";
option domain-name-servers 8.8.8.8,8.8.4.4;
option time-servers 192.53.103.108;
ddns-update-style none;
min-lease-time 2592000;
default-lease-time 2592000;
max-lease-time 2592000;
log-facility local6;
option wpad code 252 = text;
deny client-updates;

option space PacketCable;
option PacketCable.pri-dhcp code 1 = ip-address;
option PacketCable.sec-dhcp code 2 = ip-address;
option PacketCable.kerberos-realm-name code 6 = text;
option packet-cable code 122 = encapsulate PacketCable;
option PacketCable.pri-dhcp 172.22.0.13;

option space vsi;
option vsi.version code 6 = string;
option vsi.model code 9 = string;
option vsi.model_other code 201 = string;
option vsi.version_other code 202 = string;
option vsi-pkt code 43 = encapsulate vsi;

# Define option 122
option space docsis-mta;
option docsis-mta.dhcp-server-1 code 1 = ip-address;
option docsis-mta.dhcp-server-2 code 2 = ip-address;
option docsis-mta.provision-server code 3 = { integer 8, string };
option docsis-mta.as-req-as-rep-1 code 4 = { integer 32, integer 32, integer 32 };
option docsis-mta.as-req-as-rep-2 code 5 = { integer 32, integer 32, integer 32 };
option docsis-mta.krb-realm-name code 6 = string;
option docsis-mta.tgs-util code 7 = integer 8;
option docsis-mta.timer code 8 = integer 8;
option docsis-mta.ticket-ctrl-mask code 9 = integer 16;
option docsis-mta-pkt code 122 = encapsulate docsis-mta;

# Globally set option 122 settings just in case
option docsis-mta.dhcp-server-1 172.22.0.13;
option docsis-mta.provision-server 0 "\003lab\007albinet\003net\000";
option docsis-mta.krb-realm-name "\005BASIC\0011\000";


#Define option 43
option space vendorOptions;
option vendorOptions.deviceType code 2 = string;
option vendorOptions.serialNumber code 4 = string;
option vendorOptions.hardwareVersion code 5 = string;
option vendorOptions.softwareVersion code 6 = string;
option vendorOptions.bootRomVersion code 7 = string;
option vendorOptions.oui code 8 = string;
option vendorOptions.modelNumber code 9 = string;
option vendorOptions.docsisVendor code 10 = string;
#option vendorOptions.docsisVendor.version_other code 202 = string;
option vendorOptions-pkt code 43 = encapsulate vendorOptions;

stash-agent-options true;


option space myagent;
option myagent.circuit-id code 1 = text;
option myagent.remote-id code 2 = text;
option myagent.agent-id code 3 = text;
option myagent.DOCSIS-device-class code 4 = unsigned integer 32;
option myagent.link-selection code 5 = ip-address;
option myagent.subscriber-id code 6 = text;
option myagent.encapsulation code 82 = encapsulate myagent;

log( info,concat("@@DEBUG myagent.circuit-id ",substring(option myagent.circuit-id,0,6)));
log( info,concat("@@DEBUG myagent.remote-id ",option myagent.remote-id));
log( info,concat("@@DEBUG myagent.agent-id ",substring(option myagent.agent-id,0,6)));
log( info,concat("@@DEBUG myagent.DOCSIS-device-class ",substring(option myagent.DOCSIS-device-class,0,6)));
log( info,concat("@@DEBUG myagent.link-selection ",substring(option myagent.link-selection,0,6)));
log( info,concat("@@DEBUG myagent.subscriber-id ",substring(option myagent.subscriber-id,0,6)));
log( info,concat("@@DEBUG myagent.encapsulation ",substring(option myagent.encapsulation,0,6)));
#log( info,concat("@@DEBUG Vendor ID ",substring(option vendor-class-identifier,0,6)));
#log( info,concat("@@DEBUG Vendor ID ",substring(option vendor-class-identifier,0,5)));
#log( info,concat("@@DEBUG Vendor ID ",substring(option vendor-class-identifier,0,4)));
log( info,concat("@@DEBUG Vendor ID ",option vendor-class-identifier));
log( info,concat("@@DEBUG BOOTP_IP ", binary-to-ascii(10, 8, ".", packet(24,4))));
log( info,concat("@@DEBUG Remote-ID: ",binary-to-ascii(16,8,":",option agent.remote-id)) );
log( info,"@@DEBUG ");


# CheckingClass
class "CMs"
  {
  match if substring(option vendor-class-identifier,0,6)="docsis";
  log(info,"");
  log(info,"");
  log(info,"");
  log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  log(info,"@@             We have a CM!!!              ");
  log(info, concat("@@ MAC Address ", binary-to-ascii(16,8,":",substring(hardware,1,6))));
  log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  log(info,"");
  log(info,"");
  log(info,"");

  log(info,"********************************************");
  log(info,"@@ Option 43 values:");
  log(info, concat("@@ Device Type: ", option vendorOptions.deviceType));
  log(info, concat("@@ Serial Number: ", option vendorOptions.serialNumber));
  log(info, concat("@@ Hardware Version: ", option vendorOptions.hardwareVersion));
  log(info, concat("@@ Software Version: ", option vendorOptions.softwareVersion));
  log(info, concat("@@ Boot Rom Version: ", option vendorOptions.bootRomVersion));
  log(info, concat("@@ OUI: ", option vendorOptions.oui));
  log(info, concat("@@ Model Number: ", option vendorOptions.modelNumber));
  log(info, concat("@@ Docsis Vendor: ", option vendorOptions.docsisVendor));
  log(info, concat("@@ MAC Address ", binary-to-ascii(16,8,":",substring(hardware,1,6))));
  log(info,"********************************************");
  log(info,"");
  log(info,"");
  log(info,"");
  }

class "MTAs"
  {
  match if substring(option vendor-class-identifier,0,4)="pktc";
  if(exists myagent.remote-id )
   {
    log(info," ");
    log(info," ");
    log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
    log(info,"@@             We have an MTA!!!     ");
    log(info, concat("@@ MAC Address ", binary-to-ascii(16,8,":",substring(hardware,1,6))));
    log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
    log(info," ");
    log(info," ");
   }
  }

class "CPEs"
  {
  match if not (substring(option vendor-class-identifier,0,6)="docsis" or substring(option vendor-class-identifier,0,4)="pktc");
  log(info," ");
  log(info," ");
  log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  log(info,concat("@@  We have an authorized CPE :)     MAC Address ", binary-to-ascii(16,8,":",substring(hardware,1,6))));
  log(info,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
  log(info," ");
  log(info," ");

  }

class "EPC3925m"
     {
#    match if option vendorOptions.modelNumber = "EPC3925" and option vendorOptions.softwareVersion != "e3925-ES-16-c1200r5593-160720c";
#    match if option vendorOptions.modelNumber = "EPC3925" and option vendorOptions.softwareVersion != "e3925-ES-16-c1200r5593-170428c";
#    log(info, concat("@@ I'm in the EPC3925 Model. The Version is different from your point. I'm going to update this Modem ", option vendorOptions.modelNumber));
#    filename "epc3925.3.8.cfg";
#    filename "EPC3925_pics.cfg";    
#    next-server 172.22.0.13;  
     }

class "TC720020m"
{
#    match if option vendorOptions.modelNumber = "TC7200.20";
#     log(info, concat("@@ I'm in TC7200.20 Class and i'll check the version: ", option vendorOptions.modelNumber));
#    filename "tc7200.20.cfg";
#     filename "up.tc7200.20.SIP.STDD.0130.E.cfg";
#     next-server 172.22.0.13;
 }


class "TC7230"
{
#    match if option vendorOptions.modelNumber = "TC7230";
#    log(info, concat("@@ I'm in TC7230 Class and i'll check the version: ", option vendorOptions.modelNumber));
#    filename "tc7230.docsis.cfg";
#    filename "tc7230.full.cfg";
#  filename "up.tc7230.SIP.STEB.013B.cfg";
#next-server 172.22.0.13;
 }

# class "TC4400"
#{
#    match if option vendorOptions.modelNumber = "TC4400-GEN";
#     log(info, concat("@@ I'm in TC4400 Class and i'll check the version: ", option vendorOptions.modelNumber));
#     filename "tc4400v4.cfg";
#     next-server 172.22.0.13;
# }

 class "TG862S"
{
    match if option vendorOptions.modelNumber = "TG862S";
     log(info, concat("@@ I'm in TG862 Class and i'll check the version: ", option vendorOptions.modelNumber));
     filename "tg1652.cfg";
     next-server 172.22.0.13;
 }


 class "TG1652S-85"
{
    match if option vendorOptions.modelNumber = "TG1652S-85";
     log(info, concat("@@ I'm in TG862 Class and i'll check the version: ", option vendorOptions.modelNumber));
     filename "tg1652v2.cfg";
     next-server 172.22.0.13;
 }


  class "TWG870"
{
 #   match if option vendorOptions.modelNumber = "TWG870";
 #    log(info, concat("@@ I'm in TWG870 Class and i'll check the version: ", option vendorOptions.modelNumber));
 #    filename "twg870.cfg";
 #    next-server 172.22.0.13;
}

  class "TWG870U"
{
  #  match if option vendorOptions.modelNumber = "TWG870U";
#     log(info, concat("@@ I'm in TWG870 Class and i'll check the version: ", option vendorOptions.modelNumber));
#     filename "twg870.cfg";
   #  next-server 172.22.0.13;
 }



shared-network CentOSDhcpServer
  {
  subnet 172.22.0.0 netmask 255.255.255.0 {}
  }

shared-network LabuBR7246
  {
  subnet 172.22.48.0 netmask 255.255.255.0
    {
    ping-check true;
    option time-offset 3600;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.48.255;
    option routers 172.22.48.1;
    option time-servers 172.22.0.13;
    option log-servers 172.22.0.13;
    next-server 172.22.0.13;
    filename "basic.config.cfg";
   pool
      {
      range 172.22.48.2 172.22.48.254;
      deny members of "MTAs";
      deny members of "CPEs";
      allow members of "CMs";
      }
    }
  subnet 172.22.49.0 netmask 255.255.255.0
    {
    ping-check true;
    option time-offset 3600;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.49.255;
    option routers 172.22.49.1;
    option time-servers 172.22.0.13;
    option log-servers 172.22.0.13;
    option domain-name-servers 172.22.0.13;
    next-server 172.22.0.13;
    pool
      {
      range 172.22.49.2 172.22.49.254;
      deny members of "CMs";
      deny members of "CPEs";
      allow members of "MTAs";
      }
    }
  subnet 172.22.50.0 netmask 255.255.255.0
    {
    ping-check true;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.50.255;
    option routers 172.22.50.1;
    option domain-name-servers 8.8.8.8,8.8.4.4;
    pool
      {
      range 172.22.50.2 172.22.50.254;
      deny members of "CMs";
      deny members of "MTAs";
      allow members of "CPEs";
      }
    }
   }

shared-network LabUbr10k
  {
  subnet 172.22.8.0 netmask 255.255.255.0
    {
    ping-check true;
    option time-offset 3600;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.8.255;
    option routers 172.22.8.1;
    option time-servers 172.22.0.13;
    option log-servers 172.22.0.13;
    next-server 172.22.0.13;
    filename "basic.config.cfg";
   pool
      {
      range 172.22.8.2 172.22.8.254;
      deny members of "MTAs";
      deny members of "CPEs";
      allow members of "EPC3925m";
      allow members of "TC720020m";
      allow members of "TC7230";
#  allow members of "TC4400";
#  allow members of "TG862S";
  allow members of "TWG870";
  allow members of "TWG870U";

  allow members of "CMs";

      }
    }
  subnet 172.22.9.0 netmask 255.255.255.0
    {
    ping-check true;
    option time-offset 3600;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.9.255;
    option routers 172.22.9.1;
    option time-servers 172.22.0.13;
    option log-servers 172.22.0.13;
    option domain-name-servers 172.22.0.13;
    next-server 172.22.0.13;
    pool
      {
      range 172.22.9.2 172.22.9.254;
      deny members of "CMs";
      deny members of "CPEs";
      allow members of "MTAs";
      }
    }
  subnet 172.22.10.0 netmask 255.255.255.0
    {
    ping-check true;
    option subnet-mask 255.255.255.0;
    option broadcast-address 172.22.10.255;
    option routers 172.22.10.1;
    option domain-name-servers 8.8.8.8,8.8.4.4;
    pool
      {
      range 172.22.10.2 172.22.10.254;
      deny members of "CMs";
      deny members of "MTAs";
      allow members of "CPEs";
      }
    }
}