免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 819 | 回复: 0
打印 上一主题 下一主题

DHCP中使用表达式dhcp-eval (1)布尔表达式 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-30 16:02 |只看该作者 |倒序浏览

名称
       dhcp-eval - ISC DHCP conditional evaluation条件等式

描述
    ISC DHCP的客户端和服务器都支持依据接收到数据包的内容进行特定的操作。相关的文档如下。

条件行为
    条件行为是由if 语句和else 语句或elsif 语句组成的。一个条件语句可以出现在任何常规的语句中(也就是任何option 语句中),并且可以包含一个或者多个这样的语句。服务器中典型的条件语句象这个样子:
       if option dhcp-user-class = "accounting" {
         max-lease-time 17600;
         option domain-name "accounting.example.org";
         option domain-name-servers ns1.accounting.example.org,
                           ns2.accounting.example.org;
       } elsif option dhcp-user-class = "sales" {
         max-lease-time 17600;
         option domain-name "sales.example.org";
         option domain-name-servers ns1.sales.example.org,
                           ns2.sales.example.org;
       } elsif option dhcp-user-class = "engineering" {
         max-lease-time 17600;
         option domain-name "engineering.example.org";
         option domain-name-servers ns1.engineering.example.org,
                           ns2.engineering.example.org;
       } else {
         max-lease-time 600;
         option domain-name "misc.example.org";
         option domain-name-servers ns1.misc.example.org,
                           ns2.misc.example.org;
       }

而在客户端,则可能是:
       # example.org filters DNS at its firewall, so we have to use their DNS
       # servers when we connect to their network.   If we are not at
       # example.org, prefer our own DNS server.
       if not option domain-name = "example.org" {
         prepend domain-name-servers 127.0.0.1;
       }


    If语句和elsif条件语句都使用布尔值作为参数。它们对后面的参数做一个计算,如果为得到的值为真,执行紧接着的大括号中的内容,并且其它所有的elsif和else都被忽略;否则,执行elsif语句的检查,直到找到一个匹配,或者没有找到匹配,执行最后的else语句。布尔表达式把null看作是false 。

布尔表达式
    以下是DHCP支持的布尔表达式列表。

       data-expression-1 = data-expression-2
     等号“=”操作符。比较两边的表达式,返回真true或假false。如果左边或者右边的值是空“null”,返回值也是“null”。

       boolean-expression-1 and boolean-expression-2
     与“and”操作符。左右两边如果都是真,返回也是真;如果两边有一边是假,返回就是假。如果两边有一边是null,返回也是null。

       boolean-expression-1 or boolean-expression-2
    或者“or”操作符。左右两边有一个是真的时候返回真,如果有两个都是假时返回假,如果两边有任何一边是null,返回值也是null。

       not boolean-expression
    否“not”。后面的值如果是真,则返回假;如果是假,则反回真。如果后面的值是null,返回null。

       exists option-name
存在“exists”操作符。在接收到的DHCP包中如果有指定的选项则返回真,否则返回假。

       known
知道“known”操作符。如果客户端是已知的客户端,也就是说此客户端有host语句声明时返回真。

       static
    静态“static”。如果当前客户被分配的是静态地址,就返回真。




本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/39411/showart_331560.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP