Lines Matching refs:lease

266 			 * delete the lease record, and exit without modifying
555 * active_lease: the lease that is being used on the interface
563 * In addition, there are several relevant per-lease variables.
564 * T1_expiry, T2_expiry, lease_expiry: lease milestones
565 * In the active lease, these control the process of renewing the lease;
567 * can no longer legitimately use the lease.
575 /* If we don't remember an active lease, go straight to INIT. */
604 * Called when a lease has completely expired and we've
653 in this particular lease. */
661 toss the lease. */
688 /* Make up some lease expiry times
707 /* Make a DHCPREQUEST packet from the lease we picked. */
711 /* Toss the lease we picked - we'll get it back in a DHCPACK. */
725 struct client_lease *lease;
743 lease = packet_to_lease(packet);
744 if (!lease) {
749 ip->client->new = lease;
754 /* Figure out the lease time. */
761 because the lease expiry offset is unsigned. */
804 /* Write out the new lease. */
819 /* Replace the old active lease with the new one. */
838 * lease, but the renewal time on that lease has expired. We are
840 * original lease.
928 struct client_lease *lease, *lp;
946 /* If this lease doesn't supply the minimum required parameters,
956 /* If we've already seen this lease, don't record it again. */
957 for (lease = ip->client->offered_leases;
958 lease; lease = lease->next) {
959 if (lease->address.len == sizeof(packet->raw->yiaddr) &&
960 !memcmp(lease->address.iabuf,
961 &packet->raw->yiaddr, lease->address.len)) {
967 lease = packet_to_lease(packet);
968 if (!lease) {
973 /* If this lease was acquired through a BOOTREPLY, record that
976 lease->is_bootp = 1;
978 /* Record the medium under which this lease was offered. */
979 lease->medium = ip->client->medium;
982 script_init("ARPSEND", lease->medium);
983 script_write_params("check_", lease);
995 /* If this is the lease we asked for, put it at the head of the
997 if (lease->address.len == ip->client->requested_address.len &&
998 !memcmp(lease->address.iabuf,
1001 lease->next = ip->client->offered_leases;
1002 ip->client->offered_leases = lease;
1012 /* Put the lease at the end of the list. */
1013 lease->next = NULL;
1015 ip->client->offered_leases = lease;
1020 lp->next = lease;
1047 struct client_lease *lease;
1050 lease = malloc(sizeof(struct client_lease));
1052 if (!lease) {
1053 warning("dhcpoffer: no memory to record lease.");
1057 memset(lease, 0, sizeof(*lease));
1059 /* Copy the lease options. */
1062 lease->options[i].data =
1064 if (!lease->options[i].data) {
1066 free_client_lease(lease);
1069 memcpy(lease->options[i].data,
1072 lease->options[i].len =
1074 lease->options[i].data[lease->options[i].len] =
1077 if (!check_option(lease,i)) {
1078 /* ignore a bogus lease offer */
1079 warning("Invalid lease option - ignoring offer");
1080 free_client_lease(lease);
1086 lease->address.len = sizeof(packet->raw->yiaddr);
1087 memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
1089 lease->nextserver.len = sizeof(packet->raw->siaddr);
1090 memcpy(lease->nextserver.iabuf, &packet->raw->siaddr, lease->nextserver.len);
1101 lease->server_name = malloc(DHCP_SNAME_LEN + 1);
1102 if (!lease->server_name) {
1104 free_client_lease(lease);
1107 memcpy(lease->server_name, packet->raw->sname, DHCP_SNAME_LEN);
1108 lease->server_name[DHCP_SNAME_LEN]='\0';
1116 lease->filename = malloc(DHCP_FILE_LEN + 1);
1117 if (!lease->filename) {
1119 free_client_lease(lease);
1122 memcpy(lease->filename, packet->raw->file, DHCP_FILE_LEN);
1123 lease->filename[DHCP_FILE_LEN]='\0';
1125 return lease;
1150 note("DHCPNAK with no active lease.\n");
1277 /* We may not have an active lease, but we may have some
1285 note("Trying recorded lease %s",
1296 /* If the old lease is still good and doesn't
1328 /* Otherwise, put the active lease at the end of the
1329 lease list, and try another lease.. */
1338 /* If we already tried this lease, we've exhausted the
1406 /* If the lease has expired, relinquish the address and go back
1451 /* If the lease T2 time has elapsed, or if we're not yet bound,
1501 make_discover(struct interface_info *ip, struct client_lease *lease)
1530 if (lease) {
1531 ip->client->requested_address = lease->address;
1534 options[i]->value = lease->address.iabuf;
1535 options[i]->len = lease->address.len;
1536 options[i]->buf_size = lease->address.len;
1614 make_request(struct interface_info *ip, struct client_lease * lease)
1647 options[i]->value = lease->options[i].data;
1648 options[i]->len = lease->options[i].len;
1649 options[i]->buf_size = lease->options[i].len;
1654 ip->client->requested_address = lease->address;
1657 options[i]->value = lease->address.iabuf;
1658 options[i]->len = lease->address.len;
1659 options[i]->buf_size = lease->address.len;
1728 lease->address.iabuf, lease->address.len);
1747 make_decline(struct interface_info *ip, struct client_lease *lease)
1769 options[i]->value = lease->options[i].data;
1770 options[i]->len = lease->options[i].len;
1771 options[i]->buf_size = lease->options[i].len;
1777 options[i]->value = lease->address.iabuf;
1778 options[i]->len = lease->address.len;
1779 options[i]->buf_size = lease->address.len;
1821 free_client_lease(struct client_lease *lease)
1825 if (lease->server_name)
1826 free(lease->server_name);
1827 if (lease->filename)
1828 free(lease->filename);
1830 if (lease->options[i].len)
1831 free(lease->options[i].data);
1833 free(lease);
1852 error("can't limit lease descriptor: %m");
1856 error("can't limit lease descriptor fcntls: %m");
1874 write_client_lease(struct interface_info *ip, struct client_lease *lease,
1888 /* If the lease came from the config file, we don't need to stash
1889 a copy in the lease database. */
1890 if (lease->is_static)
1899 fprintf(leaseFile, "lease {\n");
1900 if (lease->is_bootp)
1903 fprintf(leaseFile, " fixed-address %s;\n", piaddr(lease->address));
1904 if (lease->nextserver.len == sizeof(inaddr_any) &&
1905 0 != memcmp(lease->nextserver.iabuf, &inaddr_any,
1908 piaddr(lease->nextserver));
1909 if (lease->filename)
1910 fprintf(leaseFile, " filename \"%s\";\n", lease->filename);
1911 if (lease->server_name)
1913 lease->server_name);
1914 if (lease->medium)
1915 fprintf(leaseFile, " medium \"%s\";\n", lease->medium->string);
1917 if (lease->options[i].len)
1920 pretty_print_option(i, lease->options[i].data,
1921 lease->options[i].len, 1, 1));
1923 t = gmtime(&lease->renewal);
1927 t = gmtime(&lease->rebind);
1931 t = gmtime(&lease->expiry);
2003 priv_script_write_params(char *prefix, struct client_lease *lease)
2011 piaddr(lease->address));
2018 dp = lease->options[DHO_SUBNET_MASK].data;
2019 len = lease->options[DHO_SUBNET_MASK].len;
2021 if (len && (len < sizeof(lease->address.iabuf))) {
2026 subnet = subnet_number(lease->address, netmask);
2030 if (!lease->options[DHO_BROADCAST_ADDRESS].len) {
2040 if (lease->filename)
2041 script_set_env(ip->client, prefix, "filename", lease->filename);
2042 if (lease->server_name)
2044 lease->server_name);
2049 if (lease->options[i].len) {
2053 dp = lease->options[i].data;
2054 len = lease->options[i].len;
2066 lease->options[i].len;
2081 lease->options[i].data,
2082 lease->options[i].len);
2094 lease->options[i].len;
2102 lease->options[i].data,
2103 lease->options[i].len);
2104 for (dp = dbuf + lease->options[i].len;
2122 } else if (lease->options[i].len) {
2123 len = lease->options[i].len;
2124 dp = lease->options[i].data;
2137 snprintf(tbuf, sizeof(tbuf), "%d", (int)lease->expiry);
2142 script_write_params(char *prefix, struct client_lease *lease)
2149 if (lease->filename != NULL)
2150 fn_len = strlen(lease->filename);
2151 if (lease->server_name != NULL)
2152 sn_len = strlen(lease->server_name);
2162 hdr.len += sizeof(int) + lease->options[i].len;
2171 errs += buf_add(buf, lease, sizeof(struct client_lease));
2173 errs += buf_add(buf, lease->filename, fn_len);
2175 errs += buf_add(buf, lease->server_name, sn_len);
2180 errs += buf_add(buf, &lease->options[i].len,
2181 sizeof(lease->options[i].len));
2182 errs += buf_add(buf, lease->options[i].data,
2183 lease->options[i].len);