我正在使用radius中的rlm_python模块,并以hex或二进制格式从coovachilli获取DHCP位置option82 。
捕获它作为一个string显示为这个值 01 27 02 25 01+ 01 24 ,但看起来python显示的值被截断,因为option82包含以TLVs-type,length,values表示该字段以types0x01(circuit ID,per RFC 3046)开头,后跟一个字节长度。
任何想法如何能够抓住这一点,并正确地解压缩选项?
我已经使用struct.unpack解压string,但没有意义struct.unpack因为它不告诉option82字段中的压缩suboptions option82 。
无头Linux – >广播IP到Windows工作站?
如何使用connman为wifinetworking设置静态IP地址
实现DHCP客户端
如何在(Ubuntu)Linux机器上更改IP地址(很可能使用dhclient钩子)时运行脚本?
RaspBerry Pi isc-dhcp-server:eth0没有子网声明
Python 2.4.3 (#1,May 5 2011,16:39:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help","copyright","credits" or "license" for more @R_137_4045@ion. >>> from struct import * >>> unpack('=hhl'," 01 27 02 25 01+ 01 24" ) (5889,5378,335620865)
有任何想法吗?
更新:
Coovachilli被编译为--locationopt82 ,它发送位置作为一个属性,像这样…
rad_recv: Accounting-Request packet from host 10.66.53.49 port 53178,id=101,length=342 ChilliSpot-Version = "1.3.0" ChilliSpot-Acct-View-Point = ChilliSpot-Client-View-Point Event-Timestamp = "Apr 18 2013 11:59:16 BST" User-Name = "3C-D0-F8-4A-05-68" Acct-Input-Octets = 0 Acct-Output-Octets = 22851 Acct-Input-Gigawords = 0 Acct-Output-Gigawords = 0 Acct-Input-Packets = 0 Acct-Output-Packets = 370 Acct-Session-Time = 5401 ChilliSpot-Session-State = Authorized Acct-Status-Type = Interim-Update Acct-Session-Id = "516fbceb00000002" Framed-IP-Address = 10.75.33.46 NAS-Port-Type = Wireless-802.11 NAS-Port = 2 NAS-Port-Id = "00000002" Calling-Station-Id = "3C-D0-F8-4A-05-68" Called-Station-Id = "00-50-56-B7-66-00" NAS-IP-Address = 10.75.32.7 ChilliSpot-Location = " 01 30 02 26 01+ 01 24" ChilliSpot-Location-Change-Count = 15 NAS-Identifier = "VLAN299-REGENT" WISPr-Location-ID = "isocc=GR,cc=44,ac=01200,network=mywifi,my_Network_regent" WISPr-Location-Name = "REGENT"
freeradius有查找计费请求的rlm_python模块
def accounting(p): file = open("/tmp/test.log","a") username = None chillilocation = None output = StringIO.StringIO() for t in p: if t[0] == 'User-Name': username = t[1] elif t[0] == 'ChilliSpot-Location': chillilocation = t[1]a output.write(t[1]) content = output.getvalue() file.write("I am being called in radius accouting section as %s and location is %s n" % (username,content)) file.close() print "---Accounting---" radiusd.radlog(radiusd.L_INFO,'*** radlog call in accounting (0) ***') print print p return radiusd.RLM_MODULE_OK
我试图存储ChilliSpot位置的string和stringIO ,使用结构解压缩没有用,它看起来像它的TLV格式…
任何想法如何剥离出来?
如何使用dhclient将供应商特定的选项传递给DHCP服务器?
将dhcp客户端标识符存储在服务器中,以便在稍后的租用期间使用
如何找出eth0模式是静态还是dhcp?
使用genymotion和virtualBox启动虚拟设备的问题
在.NET中检测远程DHCP服务器
解包不解包到“有意义”的价值。 它将字符串解压缩为一个数字字段序列,以便每个字段的大小由格式字符串的每个字符(前面的数字是乘数)指定。
不应该解压使用八位字节大小的字段?
>>> unpack('= 8B',“ 001 027 002 025 001+ 001 024”)
(1,23,2,21,1,43,1,20)
#或者也许'+'是分隔符(43):
>>> unpack('= 6Bh',“ 001 027 002 025 001+ 001 024”)
(1,23,2,21,1,43,5121)
第一个字节可能是一个电路子选择代码(unpack()[0] == 1),其大小非常奇怪,为23,这意味着我们没有得到整个子选项的值。 但是我们也可能只有== 10或者8个字节的子选项的内容值。
我不太确定选项82应该包含一个可读的字符串,虽然“ChilliSpot-Location”的确如此。 RFC3046指示电路子选项预计包含诸如“路由器接口号”,端口号和其他数值之类的东西。 但是,rad_recv的属性真的来自82选项?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。