⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 database.c

📁 VxWorks下DHCP的源代码!
💻 C
📖 第 1 页 / 共 5 页
字号:
                   rp2->cookie_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_LPR_SERVER)) {        rp1->lpr_server.addr = calloc (rp2->lpr_server.num, sizeof (struct in_addr));        if (rp1->lpr_server.addr != NULL) {            rp1->lpr_server.num = rp2->lpr_server.num;            bcopy ((char *) rp2->lpr_server.addr, (char *) rp1->lpr_server.addr,                   rp2->lpr_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_IMPRESS_SERVER)) {        rp1->impress_server.addr = calloc (rp2->impress_server.num, sizeof (struct in_addr));        if (rp1->impress_server.addr != NULL) {            rp1->impress_server.num = rp2->impress_server.num;            bcopy ((char *) rp2->impress_server.addr,                   (char *) rp1->impress_server.addr,                   rp2->impress_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_RLS_SERVER)) {        rp1->rls_server.addr = calloc (rp2->rls_server.num, sizeof (struct in_addr));        if (rp1->rls_server.addr != NULL) {            rp1->rls_server.num = rp2->rls_server.num;            bcopy ((char *) rp2->rls_server.addr, (char *) rp1->rls_server.addr,                   rp2->rls_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_HOSTNAME))        strcpy (rp1->hostname, rp2->hostname);    if (ISCLR (rp1->valid, S_BOOTSIZE))        rp1->bootsize = rp2->bootsize;    if (ISCLR (rp1->valid, S_MERIT_DUMP))        strcpy (rp1->merit_dump, rp2->merit_dump);    if (ISCLR (rp1->valid, S_DNS_DOMAIN))        strcpy (rp1->dns_domain, rp2->dns_domain);    if (ISCLR (rp1->valid, S_SWAP_SERVER))        rp1->swap_server = rp2->swap_server;    if (ISCLR (rp1->valid, S_ROOT_PATH))        strcpy (rp1->root_path, rp2->root_path);    if (ISCLR (rp1->valid, S_EXTENSIONS_PATH))        strcpy (rp1->extensions_path, rp2->extensions_path);    if (ISCLR (rp1->valid, S_IP_FORWARD))        rp1->ip_forward = rp2->ip_forward;    if (ISCLR (rp1->valid, S_NONLOCAL_SRCROUTE))        rp1->nonlocal_srcroute = rp2->nonlocal_srcroute;    if (ISCLR (rp1->valid, S_POLICY_FILTER)) {        rp1->policy_filter.addr1 = calloc (rp2->policy_filter.num, sizeof (struct in_addr));        if (rp1->policy_filter.addr1 != NULL) {            rp1->policy_filter.addr2 = calloc (rp2->policy_filter.num, sizeof (struct in_addr));            if (rp1->policy_filter.addr2 != NULL) {                rp1->policy_filter.num = rp2->policy_filter.num;                bcopy ((char *) rp2->policy_filter.addr1,                       (char *) rp1->policy_filter.addr1,                       rp2->policy_filter.num * sizeof (struct in_addr));                bcopy ((char *) rp2->policy_filter.addr1,                       (char *) rp1->policy_filter.addr1,                       rp2->policy_filter.num * sizeof (struct in_addr));            } else                free (rp1->policy_filter.addr1);        }    }    if (ISCLR (rp1->valid, S_MAX_DGRAM_SIZE))        rp1->max_dgram_size = rp2->max_dgram_size;    if (ISCLR (rp1->valid, S_DEFAULT_IP_TTL))        rp1->default_ip_ttl = rp2->default_ip_ttl;    if (ISCLR (rp1->valid, S_MTU_AGING_TIMEOUT))        rp1->mtu_aging_timeout = rp2->mtu_aging_timeout;    if (ISCLR (rp1->valid, S_MTU_PLATEAU_TABLE)) {        rp1->mtu_plateau_table.shorts = calloc (rp2->mtu_plateau_table.num, sizeof (u_short));        if (rp1->mtu_plateau_table.shorts != NULL) {            rp1->mtu_plateau_table.num = rp2->mtu_plateau_table.num;            bcopy ((char *) rp2->mtu_plateau_table.shorts,                   (char *) rp1->mtu_plateau_table.shorts,                   rp2->mtu_plateau_table.num * sizeof (u_short));        }    }    if (ISCLR (rp1->valid, S_IF_MTU))        rp1->intf_mtu = rp2->intf_mtu;    if (ISCLR (rp1->valid, S_ALL_SUBNET_LOCAL))        rp1->all_subnet_local = rp2->all_subnet_local;    if (ISCLR (rp1->valid, S_BRDCAST_ADDR))        rp1->brdcast_addr = rp2->brdcast_addr;    if (ISCLR (rp1->valid, S_MASK_DISCOVER))        rp1->mask_discover = rp2->mask_discover;    if (ISCLR (rp1->valid, S_MASK_SUPPLIER))        rp1->mask_supplier = rp2->mask_supplier;    if (ISCLR (rp1->valid, S_ROUTER_DISCOVER))        rp1->router_discover = rp2->router_discover;    if (ISCLR (rp1->valid, S_ROUTER_SOLICIT))        rp1->router_solicit = rp2->router_solicit;    if (ISCLR (rp1->valid, S_STATIC_ROUTE)) {        rp1->static_route.addr1 = calloc (rp2->static_route.num, sizeof (struct in_addr));        if (rp1->static_route.addr1 != NULL) {            rp1->static_route.addr2 = calloc (rp2->static_route.num, sizeof (struct in_addr));            if (rp1->static_route.addr2 != NULL) {                rp1->static_route.num = rp2->static_route.num;                bcopy ((char *) rp2->static_route.addr1,                       (char *) rp1->static_route.addr1,                       rp2->static_route.num * sizeof (struct in_addr));                bcopy ((char *) rp2->static_route.addr1,                       (char *) rp1->static_route.addr1,                       rp2->static_route.num * sizeof (struct in_addr));            } else                free (rp1->static_route.addr1);        }    }    if (ISCLR (rp1->valid, S_TRAILER))        rp1->trailer = rp2->trailer;    if (ISCLR (rp1->valid, S_ARP_CACHE_TIMEOUT))        rp1->arp_cache_timeout = rp2->arp_cache_timeout;    if (ISCLR (rp1->valid, S_ETHER_ENCAP))        rp1->ether_encap = rp2->ether_encap;    if (ISCLR (rp1->valid, S_DEFAULT_TCP_TTL))        rp1->default_tcp_ttl = rp2->default_tcp_ttl;    if (ISCLR (rp1->valid, S_KEEPALIVE_INTER))        rp1->keepalive_inter = rp2->keepalive_inter;    if (ISCLR (rp1->valid, S_KEEPALIVE_GARBA))        rp1->keepalive_garba = rp2->keepalive_garba;    if (ISCLR (rp1->valid, S_NIS_DOMAIN))        strcpy (rp1->nis_domain, rp2->nis_domain);    if (ISCLR (rp1->valid, S_NIS_SERVER)) {        rp1->nis_server.addr = calloc (rp2->nis_server.num, sizeof (struct in_addr));        if (rp1->nis_server.addr != NULL) {            rp1->nis_server.num = rp2->nis_server.num;            bcopy ((char *) rp2->nis_server.addr, (char *) rp1->nis_server.addr,                   rp2->nis_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_NTP_SERVER)) {        rp1->ntp_server.addr = calloc (rp2->ntp_server.num, sizeof (struct in_addr));        if (rp1->ntp_server.addr != NULL) {            rp1->ntp_server.num = rp2->ntp_server.num;            bcopy ((char *) rp2->ntp_server.addr, (char *) rp1->ntp_server.addr,                   rp2->ntp_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_NBN_SERVER)) {        rp1->nbn_server.addr = calloc (rp2->nbn_server.num, sizeof (struct in_addr));        if (rp1->nbn_server.addr != NULL) {            rp1->nbn_server.num = rp2->nbn_server.num;            bcopy ((char *) rp2->nbn_server.addr, (char *) rp1->nbn_server.addr,                   rp2->nbn_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_NBDD_SERVER)) {        rp1->nbdd_server.addr = calloc (rp2->nbdd_server.num, sizeof (struct in_addr));        if (rp1->nbdd_server.addr != NULL) {            rp1->nbdd_server.num = rp2->nbdd_server.num;            bcopy ((char *) rp2->nbdd_server.addr, (char *) rp1->nbdd_server.addr,                   rp2->nbdd_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_NB_NODETYPE))        rp1->nb_nodetype = rp2->nb_nodetype;    if (ISCLR (rp1->valid, S_NB_SCOPE))        strcpy (rp1->nb_scope, rp2->nb_scope);    if (ISCLR (rp1->valid, S_XFONT_SERVER)) {        rp1->xfont_server.addr = calloc (rp2->xfont_server.num, sizeof (struct in_addr));        if (rp1->xfont_server.addr != NULL) {            rp1->xfont_server.num = rp2->xfont_server.num;            bcopy ((char *) rp2->xfont_server.addr,                   (char *) rp1->xfont_server.addr,                   rp2->xfont_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_XDISPLAY_MANAGER)) {        rp1->xdisplay_manager.addr = calloc (rp2->xdisplay_manager.num, sizeof (struct in_addr));        if (rp1->xdisplay_manager.addr != NULL) {            rp1->xdisplay_manager.num = rp2->xdisplay_manager.num;            bcopy ((char *) rp2->xdisplay_manager.addr,                   (char *) rp1->xdisplay_manager.addr,                   rp2->xdisplay_manager.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_DHCP_T1))        rp1->dhcp_t1 = rp2->dhcp_t1;    if (ISCLR (rp1->valid, S_DHCP_T2))        rp1->dhcp_t2 = rp2->dhcp_t2;    if (ISCLR (rp1->valid, S_NISP_DOMAIN))        strcpy (rp1->nisp_domain, rp2->nisp_domain);    if (ISCLR (rp1->valid, S_NISP_SERVER)) {        rp1->nisp_server.addr = calloc (rp2->nisp_server.num, sizeof (struct in_addr));        if (rp1->nisp_server.addr != NULL) {            rp1->nisp_server.num = rp2->nisp_server.num;            bcopy ((char *) rp2->nisp_server.addr, (char *) rp1->nisp_server.addr,                   rp2->nisp_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_MOBILEIP_HA)) {        rp1->mobileip_ha.addr = calloc (rp2->mobileip_ha.num, sizeof (struct in_addr));        if (rp1->mobileip_ha.addr != NULL) {            rp1->mobileip_ha.num = rp2->mobileip_ha.num;            bcopy ((char *) rp2->mobileip_ha.addr, (char *) rp1->mobileip_ha.addr,                   rp2->mobileip_ha.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_SMTP_SERVER)) {        rp1->smtp_server.addr = calloc (rp2->smtp_server.num, sizeof (struct in_addr));        if (rp1->smtp_server.addr != NULL) {            rp1->smtp_server.num = rp2->smtp_server.num;            bcopy ((char *) rp2->smtp_server.addr, (char *) rp1->smtp_server.addr,                   rp2->smtp_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_POP3_SERVER)) {        rp1->pop3_server.addr = calloc (rp2->pop3_server.num, sizeof (struct in_addr));        if (rp1->pop3_server.addr != NULL) {            rp1->pop3_server.num = rp2->pop3_server.num;            bcopy ((char *) rp2->pop3_server.addr, (char *) rp1->pop3_server.addr,                   rp2->pop3_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_NNTP_SERVER)) {        rp1->nntp_server.addr = calloc (rp2->nntp_server.num, sizeof (struct in_addr));        if (rp1->nntp_server.addr != NULL) {            rp1->nntp_server.num = rp2->nntp_server.num;            bcopy ((char *) rp2->nntp_server.addr, (char *) rp1->nntp_server.addr,                   rp2->nntp_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_DFLT_WWW_SERVER)) {        rp1->dflt_www_server.addr = calloc (rp2->dflt_www_server.num, sizeof (struct in_addr));        if (rp1->dflt_www_server.addr != NULL) {            rp1->dflt_www_server.num = rp2->dflt_www_server.num;            bcopy ((char *) rp2->dflt_www_server.addr,                   (char *) rp1->dflt_www_server.addr,                   rp2->dflt_www_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_DFLT_FINGER_SERVER)) {        rp1->dflt_finger_server.addr = calloc (rp2->dflt_finger_server.num,                                               sizeof (struct in_addr));        if (rp1->dflt_finger_server.addr != NULL) {            rp1->dflt_finger_server.num = rp2->dflt_finger_server.num;            bcopy ((char *) rp2->dflt_finger_server.addr,                   (char *) rp1->dflt_finger_server.addr,                   rp2->dflt_finger_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_DFLT_IRC_SERVER)) {        rp1->dflt_irc_server.addr = calloc (rp2->dflt_irc_server.num, sizeof (struct in_addr));        if (rp1->dflt_irc_server.addr != NULL) {            rp1->dflt_irc_server.num = rp2->dflt_irc_server.num;            bcopy ((char *) rp2->dflt_irc_server.addr,                   (char *) rp1->dflt_irc_server.addr,                   rp2->dflt_irc_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_STREETTALK_SERVER)) {        rp1->streettalk_server.addr = calloc (rp2->streettalk_server.num, sizeof (struct in_addr));        if (rp1->streettalk_server.addr != NULL) {            rp1->streettalk_server.num = rp2->streettalk_server.num;            bcopy ((char *) rp2->streettalk_server.addr,                   (char *) rp1->streettalk_server.addr,                   rp2->streettalk_server.num * sizeof (struct in_addr));        }    }    if (ISCLR (rp1->valid, S_STDA_SERVER)) {        rp1->stda_server.addr = calloc (rp2->stda_server.num, sizeof (struct in_addr));        if (rp1->stda_server.addr != NULL) {            rp1->stda_server.num = rp2->stda_server.num;            bcopy ((char *) rp2->stda_server.addr, (char *) rp1->stda_server.addr,                   rp2->stda_server.num * sizeof (struct in_addr));        }    }    for (i = 0; i < VALIDSIZE; i++) {        /*          * Set active and valid flags for all values provided by quoted         * entry. The valid flag for an entry is always set if the          * corresponding active flag is set.         */        rp1->active[i] |= (~rp1->valid[i] & rp2->active[i]);        rp1->valid[i] |= rp2->valid[i];    }    return (0);}/********************************************************************************* proc_mtpt - extract the MTU plateau table values** This routine sets the mtu_plateau_table field of a lease descriptor to the * values specified by a "mtpt" entry in the address pool database. The* structure field is cleared when "mtpt@", specifying deletion, is encountered.** RETURNS: 0, always.** ERRNO: N/A** NOMANUAL*/int proc_mtpt (int code,        /* resource code for address pool field */               int optype,      /* operation type (addition or deletion) */               char **symbol,   /* current location in input string */               struct dhcp_resource *rp /* pointer to lease descriptor */    ){    int i = 0;    unsigned short tmpnum[MAX_MTUPLTSZ];    if (optype == OP_ADDITION) {        for (i = 0; i <= MAX_MTUPLTSZ; i++) {            while (**symbol && isspace ((int) **symbol)) {                (*symbol)++;            }            if (!**symbol) {    /* Quit if nothing more */                break;            }            if (isdigit ((int) **symbol))                tmpnum[i] = (u_short) get_integer (symbol);            else                break;        }        if (i == 0) {#ifdef DHCPS_DEBUG            logMsg ("Warning: invalid MTU plateau table value.\n", 0, 0, 0, 0, 0, 0);#endif            return (-1);        }        rp->mtu_plateau_table.num = i;        if (rp->mtu_plateau_table.shorts != NULL)            free (rp->mtu_plateau_table.shorts);        rp->mtu_plateau_table.shorts = (u_short *) calloc (i, sizeof (u_short));        if (rp->mtu_plateau_table.shorts == NULL) {#ifdef DHCPS_DEBUG            logMsg ("Warning: memory allocation error reading MTU plateau.\n", 0, 0, 0, 0, 0, 0);#endif            return (-1);        }        for (i = 0; i < rp->mtu_plateau_table.num; i++)            rp->mtu_plateau_table.shorts[i] = htons (tmpnum[i]);    } else {        rp->mtu_plateau_table.num = 0;        if (rp->mtu_plateau_table.shorts != NULL)            free (rp->mtu_plateau_table.shorts);        rp->mtu_plateau_table.shorts = NULL;    }    return (0);}/********************************************************************************* proc_ip - process single IP addresses** This routine sets the fields of the lease descriptor containing single IP * address values. It is called in response to any "siad", "ipad", "snmk", * "swsv", "brda", or "rtsl" entries in the address pool database. When an "@" * mark is appended to any of the above specifiers, the corresponding field is * cleared.** RETURNS: 0 if processing completed, or -1 on parse error.** ERRNO: N/A** NOMANUAL*/int proc_ip (int code,          /* resource code for address pool field */             int optype,        /* operation type (addition or deletion) */             char **symbol,     /* current location in input string */             struct dhcp_resource *rp   /* pointer to lease descriptor */    ){    struct in_addr *ipp = NULL;    STATUS result;    switch (code) {    case S_SIADDR:        ipp = &rp->siaddr;        break;    case S_IP_ADDR:        ipp = &rp->ip_addr;        break;    case S_SUBNET_MASK:        ipp = &rp->subnet_mask;        break;    case 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -