Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/networking/udhcp/static_leases.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/udhcp/static_leases.c
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* 2 3 * static_leases.c -- Couple of functions to assist with storing and … … 7 8 */ 8 9 10 #include "common.h" 11 #include "dhcpd.h" 9 12 10 #include <stdlib.h>11 #include <stdio.h>12 #include <string.h>13 14 #include "static_leases.h"15 #include "dhcpd.h"16 13 17 14 /* Takes the address of the pointer to the static_leases linked list, … … 20 17 int addStaticLease(struct static_lease **lease_struct, uint8_t *mac, uint32_t *ip) 21 18 { 22 23 19 struct static_lease *cur; 24 20 struct static_lease *new_static_lease; … … 31 27 32 28 /* If it's the first node to be added... */ 33 if(*lease_struct == NULL) 34 { 29 if (*lease_struct == NULL) { 35 30 *lease_struct = new_static_lease; 36 } 37 else 38 { 31 } else { 39 32 cur = *lease_struct; 40 while(cur->next != NULL) 41 { 33 while (cur->next) { 42 34 cur = cur->next; 43 35 } … … 47 39 48 40 return 1; 49 50 41 } 51 42 … … 59 50 return_ip = 0; 60 51 61 while(cur != NULL) 62 { 52 while (cur) { 63 53 /* If the client has the correct mac */ 64 if(memcmp(cur->mac, mac, 6) == 0) 65 { 54 if (memcmp(cur->mac, mac, 6) == 0) { 66 55 return_ip = *(cur->ip); 67 56 } … … 71 60 72 61 return return_ip; 73 74 62 } 75 63 … … 81 69 uint32_t return_val = 0; 82 70 83 while(cur != NULL) 84 { 71 while (cur) { 85 72 /* If the client has the correct ip */ 86 if (*cur->ip == ip)73 if (*cur->ip == ip) 87 74 return_val = 1; 88 75 … … 91 78 92 79 return return_val; 93 94 80 } 95 81 96 #if def CONFIG_FEATURE_UDHCP_DEBUG82 #if ENABLE_FEATURE_UDHCP_DEBUG 97 83 /* Print out static leases just to check what's going on */ 98 84 /* Takes the address of the pointer to the static_leases linked list */ … … 102 88 struct static_lease *cur = *arg; 103 89 104 while(cur != NULL) 105 { 90 while (cur) { 106 91 /* printf("PrintStaticLeases: Lease mac Address: %x\n", cur->mac); */ 107 92 printf("PrintStaticLeases: Lease mac Value: %x\n", *(cur->mac)); … … 111 96 cur = cur->next; 112 97 } 113 114 115 98 } 116 99 #endif 117 118 119
Note:
See TracChangeset
for help on using the changeset viewer.