Lines Matching defs:lease

283 			 * delete the lease record, and exit without modifying
602 * active_lease: the lease that is being used on the interface
610 * In addition, there are several relevant per-lease variables.
611 * T1_expiry, T2_expiry, lease_expiry: lease milestones
612 * In the active lease, these control the process of renewing the lease;
614 * can no longer legitimately use the lease.
622 /* If we don't remember an active lease, go straight to INIT. */
651 * Called when a lease has completely expired and we've
700 in this particular lease. */
708 toss the lease. */
735 /* Make up some lease expiry times
754 /* Make a DHCPREQUEST packet from the lease we picked. */
758 /* Toss the lease we picked - we'll get it back in a DHCPACK. */
772 struct client_lease *lease;
790 lease = packet_to_lease(packet);
791 if (!lease) {
796 ip->client->new = lease;
801 /* Figure out the lease time. */
812 because the lease expiry offset is unsigned. Also make sure that
897 /* Write out the new lease. */
912 /* Replace the old active lease with the new one. */
931 * lease, but the renewal time on that lease has expired. We are
933 * original lease.
1030 struct client_lease *lease, *lp;
1051 /* If this lease doesn't supply the minimum required parameters,
1061 /* If we've already seen this lease, don't record it again. */
1062 for (lease = ip->client->offered_leases;
1063 lease; lease = lease->next) {
1064 if (lease->address.len == sizeof(packet->raw->yiaddr) &&
1065 !memcmp(lease->address.iabuf,
1066 &packet->raw->yiaddr, lease->address.len)) {
1072 lease = packet_to_lease(packet);
1073 if (!lease) {
1078 /* If this lease was acquired through a BOOTREPLY, record that
1081 lease->is_bootp = 1;
1083 /* Record the medium under which this lease was offered. */
1084 lease->medium = ip->client->medium;
1087 script_init("ARPSEND", lease->medium);
1088 script_write_params("check_", lease);
1101 /* If this is the lease we asked for, put it at the head of the
1103 if (lease->address.len == ip->client->requested_address.len &&
1104 !memcmp(lease->address.iabuf,
1107 lease->next = ip->client->offered_leases;
1108 ip->client->offered_leases = lease;
1122 /* Put the lease at the end of the list. */
1123 lease->next = NULL;
1125 ip->client->offered_leases = lease;
1130 lp->next = lease;
1164 struct client_lease *lease;
1167 lease = malloc(sizeof(struct client_lease));
1169 if (!lease) {
1170 warning("dhcpoffer: no memory to record lease.");
1174 memset(lease, 0, sizeof(*lease));
1176 /* Copy the lease options. */
1188 lease->options[i].data =
1190 if (!lease->options[i].data) {
1192 free_client_lease(lease);
1195 memcpy(lease->options[i].data,
1198 lease->options[i].len =
1200 lease->options[i].data[lease->options[i].len] =
1203 if (!check_option(lease,i)) {
1204 /* ignore a bogus lease offer */
1205 warning("Invalid lease option - ignoring offer");
1206 free_client_lease(lease);
1212 lease->address.len = sizeof(packet->raw->yiaddr);
1213 memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
1215 lease->nextserver.len = sizeof(packet->raw->siaddr);
1216 memcpy(lease->nextserver.iabuf, &packet->raw->siaddr, lease->nextserver.len);
1227 lease->server_name = malloc(DHCP_SNAME_LEN + 1);
1228 if (!lease->server_name) {
1230 free_client_lease(lease);
1233 memcpy(lease->server_name, packet->raw->sname, DHCP_SNAME_LEN);
1234 lease->server_name[DHCP_SNAME_LEN]='\0';
1242 lease->filename = malloc(DHCP_FILE_LEN + 1);
1243 if (!lease->filename) {
1245 free_client_lease(lease);
1248 memcpy(lease->filename, packet->raw->file, DHCP_FILE_LEN);
1249 lease->filename[DHCP_FILE_LEN]='\0';
1251 return lease;
1276 note("DHCPNAK with no active lease.\n");
1403 /* We may not have an active lease, but we may have some
1411 note("Trying recorded lease %s",
1422 /* If the old lease is still good and doesn't
1454 /* Otherwise, put the active lease at the end of the
1455 lease list, and try another lease.. */
1464 /* If we already tried this lease, we've exhausted the
1532 /* If the lease has expired, relinquish the address and go back
1577 /* If the lease T2 time has elapsed, or if we're not yet bound,
1628 make_discover(struct interface_info *ip, struct client_lease *lease)
1657 if (lease) {
1658 ip->client->requested_address = lease->address;
1661 options[i]->value = lease->address.iabuf;
1662 options[i]->len = lease->address.len;
1663 options[i]->buf_size = lease->address.len;
1741 make_request(struct interface_info *ip, struct client_lease * lease)
1774 options[i]->value = lease->options[i].data;
1775 options[i]->len = lease->options[i].len;
1776 options[i]->buf_size = lease->options[i].len;
1781 ip->client->requested_address = lease->address;
1784 options[i]->value = lease->address.iabuf;
1785 options[i]->len = lease->address.len;
1786 options[i]->buf_size = lease->address.len;
1855 lease->address.iabuf, lease->address.len);
1874 make_decline(struct interface_info *ip, struct client_lease *lease)
1896 options[i]->value = lease->options[i].data;
1897 options[i]->len = lease->options[i].len;
1898 options[i]->buf_size = lease->options[i].len;
1904 options[i]->value = lease->address.iabuf;
1905 options[i]->len = lease->address.len;
1906 options[i]->buf_size = lease->address.len;
1948 free_client_lease(struct client_lease *lease)
1952 if (lease->server_name)
1953 free(lease->server_name);
1954 if (lease->filename)
1955 free(lease->filename);
1957 if (lease->options[i].len)
1958 free(lease->options[i].data);
1960 free(lease);
1978 error("can't limit lease descriptor: %m");
1981 error("can't limit lease descriptor fcntls: %m");
1999 write_client_lease(struct interface_info *ip, struct client_lease *lease,
2013 /* If the lease came from the config file, we don't need to stash
2014 a copy in the lease database. */
2015 if (lease->is_static)
2024 fprintf(leaseFile, "lease {\n");
2025 if (lease->is_bootp)
2028 fprintf(leaseFile, " fixed-address %s;\n", piaddr(lease->address));
2029 if (lease->nextserver.len == sizeof(inaddr_any) &&
2030 0 != memcmp(lease->nextserver.iabuf, &inaddr_any,
2033 piaddr(lease->nextserver));
2034 if (lease->filename)
2035 fprintf(leaseFile, " filename \"%s\";\n", lease->filename);
2036 if (lease->server_name)
2038 lease->server_name);
2039 if (lease->medium)
2040 fprintf(leaseFile, " medium \"%s\";\n", lease->medium->string);
2042 if (lease->options[i].len)
2045 pretty_print_option(i, lease->options[i].data,
2046 lease->options[i].len, 1, 1));
2048 t = gmtime(&lease->renewal);
2052 t = gmtime(&lease->rebind);
2056 t = gmtime(&lease->expiry);
2128 priv_script_write_params(const char *prefix, struct client_lease *lease)
2137 piaddr(lease->address));
2144 dp = lease->options[DHO_SUBNET_MASK].data;
2145 len = lease->options[DHO_SUBNET_MASK].len;
2147 if (len && (len < sizeof(lease->address.iabuf))) {
2152 subnet = subnet_number(lease->address, netmask);
2156 if (!lease->options[DHO_BROADCAST_ADDRESS].len) {
2166 if (lease->filename)
2167 script_set_env(ip->client, prefix, "filename", lease->filename);
2168 if (lease->server_name)
2170 lease->server_name);
2175 if (lease->options[i].len) {
2179 dp = lease->options[i].data;
2180 len = lease->options[i].len;
2192 lease->options[i].len;
2207 lease->options[i].data,
2208 lease->options[i].len);
2220 lease->options[i].len;
2228 lease->options[i].data,
2229 lease->options[i].len);
2230 for (dp = dbuf + lease->options[i].len;
2248 } else if (lease->options[i].len) {
2249 len = lease->options[i].len;
2250 dp = lease->options[i].data;
2263 snprintf(tbuf, sizeof(tbuf), "%d", (int)lease->expiry);
2268 script_write_params(const char *prefix, struct client_lease *lease)
2275 if (lease->filename != NULL)
2276 fn_len = strlen(lease->filename);
2277 if (lease->server_name != NULL)
2278 sn_len = strlen(lease->server_name);
2283 hdr.len = sizeof(hdr) + sizeof(*lease) +
2288 hdr.len += sizeof(lease->options[i].len);
2289 hdr.len += lease->options[i].len;
2299 errs += buf_add(buf, lease, sizeof(*lease));
2301 errs += buf_add(buf, lease->filename, fn_len);
2303 errs += buf_add(buf, lease->server_name, sn_len);
2308 errs += buf_add(buf, &lease->options[i].len,
2309 sizeof(lease->options[i].len));
2310 errs += buf_add(buf, lease->options[i].data,
2311 lease->options[i].len);