Описал их так
Код:
# Удаление заголовка, при необходимости, 0 - не удалять, 2 - 2 удалить байта (тип+длина) из значения DHCP-опции.
# При удалении поля position для agentRemoteId, vlanId, interfaceId нужно уменьшить на тоже кол-во байт
#dhcp.option82.removeHeader=0
dhcp.option82.removeHeader=2
# Параметры для извлечения из пакета agentRemoteId
# вид значения в опции agentRemoteId: 0 (по умолчанию) - байты, 1 - строка
#dhcp.option82.agentRemoteId.type=0
# код субопции 82, содержащей идентификатор коммутатора клиента, позиция и длина последовательности идентификатора
dhcp.option82.agentRemoteId.code=2
dhcp.option82.agentRemoteId.position=0
dhcp.option82.agentRemoteId.length=6
# код субопции 82, содержащей VLAN, позиция и длина в субопции
#dhcp.option82.vlanId.code=1
#dhcp.option82.vlanId.position=0
#dhcp.option82.vlanId.length=2
# код субопции 82, содержащей интерфейс, позиция и длина в субопции
dhcp.option82.interfaceId.code=1
dhcp.option82.interfaceId.position=0
dhcp.option82.interfaceId.length=1
Стало приходить:
Код:
dhcp 09-16/17:12:28 INFO [dhcpLstnr-p-9-t-7] InetAbstractDhcpProcessor - REQUEST_AFTER_PREPROCESS:
Message type: BOOT_REQUEST
Dhcp message type: DHCP Discover{1}
htype: 1, hlen: 6, hops: 1
xid: 673484365, secs: 0, flags: 0
Client IP: 0.0.0.0
Your IP: 0.0.0.0
Server IP: 0.0.0.0
Relay IP: 10.88.0.1
Client MAC: {D8FEE3C8CDF2}
{61}={01D8FEE3C8CDF2}
Parameter request list{55}={1, 3, 6, 12, 15, 17, 28, 42, 66, 33, 121, -7, 43}
Agent information{82}=
sub{1}={01}
sub{2}={D8FEE38CA7E0}
dhcp 09-16/17:12:28 ERROR [dhcpLstnr-p-9-t-7] InetDhcpProcessor - 2
java.lang.ArrayIndexOutOfBoundsException: 2
at ru.bitel.bgbilling.modules.inet.api.server.InetUtils.parseInt(InetUtils.java:518)
at ru.bitel.bgbilling.modules.inet.runtime.device.AbstractInetDeviceRuntime.getOption82InterfaceId(AbstractInetDeviceRuntime.java:298)
at ru.bitel.bgbilling.modules.inet.runtime.device.InetDeviceRuntime.getOption82InterfaceId(InetDeviceRuntime.java:1)
at ru.bitel.bgbilling.modules.inet.dhcp.InetDhcpDevice.findServRuntime(InetDhcpDevice.java:319)
at ru.bitel.bgbilling.modules.inet.dhcp.InetDhcpProcessor.processOption82RequestImpl(InetDhcpProcessor.java:201)
at ru.bitel.bgbilling.modules.inet.dhcp.InetAbstractDhcpProcessor.processOption82Request(InetAbstractDhcpProcessor.java:501)
at ru.bitel.bgbilling.modules.inet.dhcp.InetAbstractDhcpProcessor.processRequest(InetAbstractDhcpProcessor.java:271)
at ru.bitel.bgbilling.kernel.network.dhcp.DhcpListenerWorker.runImpl(DhcpListenerWorker.java:57)
at ru.bitel.common.worker.WorkerTask.run(WorkerTask.java:86)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
at ru.bitel.common.worker.WorkerThread.run(WorkerThread.java:40)
PS:
У меня еще:
Код:
protected void setUsername( final RadiusPacket request )
{
String macAddr = request.getStringAttribute( 2352, 145, null );
byte[] remoteId = request.getByteAttribute( 2352, 96, null );
byte[] circuitId = request.getByteAttribute( 2352, 97, null );
if( macAddr != null && remoteId != null && circuitId != null )
{
String callingStation = macAddr.replaceAll( "\\-", "" );
String userName = "";
if (remoteId.length == 8) {
logger.info( "Format of Option 82 is D-link" );
userName = Utils.bytesToHexString( remoteId ).substring(4, 16) + ":" + Utils.bytesToHexString( circuitId ).substring(10, 12);
}
if (remoteId.length == 11) {
logger.info( "Format of Option 82 is Eltex" );
//userName = Utils.bytesToHexString( remoteId ).substring(10, 22) + Utils.bytesToHexString( circuitId ).substring(4, 8) + ":" + Utils.bytesToHexString( circuitId ).substring(20, 22);
userName = Utils.bytesToHexString( remoteId ).substring(10, 22) + ":" + Utils.bytesToHexString( circuitId ).substring(8, 12);
}
userName = userName.toLowerCase();
request.setStringAttribute( -1, 1, userName );
request.setStringAttribute( -1, 31, callingStation );
}
/* --- ORIGINAL CODE ----
String macAddr = request.getStringAttribute( radiusVendor, Mac_Addr, null );
if( macAddr != null )
{
String callingStation = macAddr.replaceAll( "\\-", "" );
request.setStringAttribute( -1, RadiusDictionary.Calling_Station_Id, callingStation );
}
byte[] remoteId = request.getByteAttribute( radiusVendor, Agent_Remote_Id, null );
byte[] circuitId = request.getByteAttribute( radiusVendor, Agent_Circuit_Id, null );
if( remoteId != null && circuitId != null )
{
String userName = Utils.bytesToString( remoteId, true, null ) + ":" + Utils.bytesToString( circuitId, true, null );
userName = userName.toLowerCase();
request.setStringAttribute( -1, 1, userName );
}
--- ORIGINAL CODE ---- */
}
Код:
public void preprocessDhcpRequest( DhcpPacket request, DhcpPacket response )
throws Exception
{
// необходимо для старого поиска по логину
if( servSearchModes[0][0] == InetDevice.SERV_SEARCH_MODE_LOGIN )
{
try
{
byte[] circuitId = request.getSubOption( (byte)1 ).value;
byte[] remoteId = request.getSubOption( (byte)2 ).value;
byte[] mac = new byte[6];
byte[] port = new byte[1];
System.arraycopy( circuitId, 5, port, 0, 1 );
System.arraycopy( remoteId, 2, mac, 0, 6 );
request.setSubOption( (byte)1, port );
request.setSubOption( (byte)2, mac );
}
catch( java.lang.NullPointerException e )
{
return;
}
}