Deleted Added
full compact
readfile.c (3229) readfile.c (13572)
1/************************************************************************
2 Copyright 1988, 1991 by Carnegie Mellon University
3
4 All Rights Reserved
5
6Permission to use, copy, modify, and distribute this software and its
7documentation for any purpose and without fee is hereby granted, provided
8that the above copyright notice appear in all copies and that both that

--- 6 unchanged lines hidden (view full) ---

15SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
16IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
17DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20SOFTWARE.
21************************************************************************/
22
1/************************************************************************
2 Copyright 1988, 1991 by Carnegie Mellon University
3
4 All Rights Reserved
5
6Permission to use, copy, modify, and distribute this software and its
7documentation for any purpose and without fee is hereby granted, provided
8that the above copyright notice appear in all copies and that both that

--- 6 unchanged lines hidden (view full) ---

15SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
16IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
17DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20SOFTWARE.
21************************************************************************/
22
23#ifndef lint
24static char rcsid[] = "$Id: readfile.c,v 1.1.1.1 1994/09/10 14:44:55 csgr Exp $";
25#endif
26
27
28/*
29 * bootpd configuration file reading code.
30 *
31 * The routines in this file deal with reading, interpreting, and storing
32 * the information found in the bootpd configuration file (usually
33 * /etc/bootptab).
34 */
35

--- 405 unchanged lines hidden (view full) ---

441 /* Register by HW addr if known. */
442 if (hp->flags.htype && hp->flags.haddr) {
443 /* We will either insert it or free it. */
444 hp->linkcount++;
445 hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype));
446 if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) {
447 report(LOG_NOTICE, "duplicate %s address: %s",
448 netname(hp->htype),
23/*
24 * bootpd configuration file reading code.
25 *
26 * The routines in this file deal with reading, interpreting, and storing
27 * the information found in the bootpd configuration file (usually
28 * /etc/bootptab).
29 */
30

--- 405 unchanged lines hidden (view full) ---

436 /* Register by HW addr if known. */
437 if (hp->flags.htype && hp->flags.haddr) {
438 /* We will either insert it or free it. */
439 hp->linkcount++;
440 hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype));
441 if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) {
442 report(LOG_NOTICE, "duplicate %s address: %s",
443 netname(hp->htype),
449 haddrtoa(hp->haddr, hp->htype));
444 haddrtoa(hp->haddr, haddrlength(hp->htype)));
450 free_host((hash_datum *) hp);
451 continue;
452 }
453 }
454 /* Register by IP addr if known. */
455 if (hp->flags.iaddr) {
456 hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4);
457 if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) {

--- 305 unchanged lines hidden (view full) ---

763 if (optype == OP_ADDITION) { \
764 hp->MEMBER = get_shared_string(symbol); \
765 if (hp->MEMBER == NULL) \
766 return E_SYNTAX_ERROR; \
767 hp->flags.MEMBER = TRUE; \
768 } \
769} while (0)
770
445 free_host((hash_datum *) hp);
446 continue;
447 }
448 }
449 /* Register by IP addr if known. */
450 if (hp->flags.iaddr) {
451 hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4);
452 if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) {

--- 305 unchanged lines hidden (view full) ---

758 if (optype == OP_ADDITION) { \
759 hp->MEMBER = get_shared_string(symbol); \
760 if (hp->MEMBER == NULL) \
761 return E_SYNTAX_ERROR; \
762 hp->flags.MEMBER = TRUE; \
763 } \
764} while (0)
765
771/* Parse an integer value for MEMBER */
772#define PARSE_INT(MEMBER) do \
766/* Parse an unsigned integer value for MEMBER */
767#define PARSE_UINT(MEMBER) do \
773{ \
774 if (optype == OP_BOOLEAN) \
775 return E_SYNTAX_ERROR; \
776 hp->flags.MEMBER = FALSE; \
777 if (optype == OP_ADDITION) { \
778 value = get_u_long(symbol); \
779 hp->MEMBER = value; \
780 hp->flags.MEMBER = TRUE; \

--- 10 unchanged lines hidden (view full) ---

791 */
792PRIVATE int
793eval_symbol(symbol, hp)
794 char **symbol;
795 struct host *hp;
796{
797 char tmpstr[MAXSTRINGLEN];
798 byte *tmphaddr;
768{ \
769 if (optype == OP_BOOLEAN) \
770 return E_SYNTAX_ERROR; \
771 hp->flags.MEMBER = FALSE; \
772 if (optype == OP_ADDITION) { \
773 value = get_u_long(symbol); \
774 hp->MEMBER = value; \
775 hp->flags.MEMBER = TRUE; \

--- 10 unchanged lines hidden (view full) ---

786 */
787PRIVATE int
788eval_symbol(symbol, hp)
789 char **symbol;
790 struct host *hp;
791{
792 char tmpstr[MAXSTRINGLEN];
793 byte *tmphaddr;
799 struct shared_string *ss;
800 struct symbolmap *symbolptr;
801 u_int32 value;
802 int32 timeoff;
803 int i, numsymbols;
804 unsigned len;
805 int optype; /* Indicates boolean, addition, or deletion */
806
807 eat_whitespace(symbol);

--- 7 unchanged lines hidden (view full) ---

815 return E_END_OF_ENTRY;
816 }
817 if ((*symbol)[0] == ':') {
818 return SUCCESS;
819 }
820 if ((*symbol)[0] == 'T') { /* generic symbol */
821 (*symbol)++;
822 value = get_u_long(symbol);
794 struct symbolmap *symbolptr;
795 u_int32 value;
796 int32 timeoff;
797 int i, numsymbols;
798 unsigned len;
799 int optype; /* Indicates boolean, addition, or deletion */
800
801 eat_whitespace(symbol);

--- 7 unchanged lines hidden (view full) ---

809 return E_END_OF_ENTRY;
810 }
811 if ((*symbol)[0] == ':') {
812 return SUCCESS;
813 }
814 if ((*symbol)[0] == 'T') { /* generic symbol */
815 (*symbol)++;
816 value = get_u_long(symbol);
823 sprintf(current_tagname, "T%d", value);
817 sprintf(current_tagname, "T%d", (int)value);
824 eat_whitespace(symbol);
825 if ((*symbol)[0] != '=') {
826 return E_SYNTAX_ERROR;
827 }
828 (*symbol)++;
829 if (!(hp->generic)) {
830 hp->generic = (struct shared_bindata *)
831 smalloc(sizeof(struct shared_bindata));

--- 148 unchanged lines hidden (view full) ---

980 return E_SYNTAX_ERROR;
981 hp->flags.time_offset = FALSE;
982 if (optype == OP_ADDITION) {
983 len = sizeof(tmpstr);
984 (void) get_string(symbol, tmpstr, &len);
985 if (!strncmp(tmpstr, "auto", 4)) {
986 hp->time_offset = secondswest;
987 } else {
818 eat_whitespace(symbol);
819 if ((*symbol)[0] != '=') {
820 return E_SYNTAX_ERROR;
821 }
822 (*symbol)++;
823 if (!(hp->generic)) {
824 hp->generic = (struct shared_bindata *)
825 smalloc(sizeof(struct shared_bindata));

--- 148 unchanged lines hidden (view full) ---

974 return E_SYNTAX_ERROR;
975 hp->flags.time_offset = FALSE;
976 if (optype == OP_ADDITION) {
977 len = sizeof(tmpstr);
978 (void) get_string(symbol, tmpstr, &len);
979 if (!strncmp(tmpstr, "auto", 4)) {
980 hp->time_offset = secondswest;
981 } else {
988 if (sscanf(tmpstr, "%d", &timeoff) != 1)
982 if (sscanf(tmpstr, "%d", (int*)&timeoff) != 1)
989 return E_BAD_LONGWORD;
990 hp->time_offset = timeoff;
991 }
992 hp->flags.time_offset = TRUE;
993 }
994 break;
995
996 case SYM_TIME_SERVER:

--- 119 unchanged lines hidden (view full) ---

1116
1117#ifdef YORK_EX_OPTION
1118 case SYM_EXEC_FILE:
1119 PARSE_STR(exec_file);
1120 break;
1121#endif
1122
1123 case SYM_MSG_SIZE:
983 return E_BAD_LONGWORD;
984 hp->time_offset = timeoff;
985 }
986 hp->flags.time_offset = TRUE;
987 }
988 break;
989
990 case SYM_TIME_SERVER:

--- 119 unchanged lines hidden (view full) ---

1110
1111#ifdef YORK_EX_OPTION
1112 case SYM_EXEC_FILE:
1113 PARSE_STR(exec_file);
1114 break;
1115#endif
1116
1117 case SYM_MSG_SIZE:
1124 PARSE_INT(msg_size);
1118 PARSE_UINT(msg_size);
1125 if (hp->msg_size < BP_MINPKTSZ ||
1126 hp->msg_size > MAX_MSG_SIZE)
1127 return E_BAD_VALUE;
1128 break;
1129
1130 case SYM_MIN_WAIT:
1119 if (hp->msg_size < BP_MINPKTSZ ||
1120 hp->msg_size > MAX_MSG_SIZE)
1121 return E_BAD_VALUE;
1122 break;
1123
1124 case SYM_MIN_WAIT:
1131 PARSE_INT(min_wait);
1132 if (hp->min_wait < 0)
1133 return E_BAD_VALUE;
1125 PARSE_UINT(min_wait);
1134 break;
1135
1136 /* XXX - Add new tags here */
1137
1138 default:
1139 return E_UNKNOWN_SYMBOL;
1140
1141 } /* switch symbolcode */

--- 535 unchanged lines hidden (view full) ---

1677 u_int32 *result;
1678{
1679 char tmpstr[MAXSTRINGLEN];
1680 register u_int32 value;
1681 u_int32 parts[4], *pp;
1682 int n;
1683 char *s, *t;
1684
1126 break;
1127
1128 /* XXX - Add new tags here */
1129
1130 default:
1131 return E_UNKNOWN_SYMBOL;
1132
1133 } /* switch symbolcode */

--- 535 unchanged lines hidden (view full) ---

1669 u_int32 *result;
1670{
1671 char tmpstr[MAXSTRINGLEN];
1672 register u_int32 value;
1673 u_int32 parts[4], *pp;
1674 int n;
1675 char *s, *t;
1676
1685#if 1 /* XXX - experimental */
1686 /* Leading alpha char causes IP addr lookup. */
1687 if (isalpha(**src)) {
1688 /* Lookup IP address. */
1689 s = *src;
1690 t = tmpstr;
1691 while ((isalnum(*s) || (*s == '.') ||
1692 (*s == '-') || (*s == '_') ) &&
1693 (t < &tmpstr[MAXSTRINGLEN - 1]) )
1694 *t++ = *s++;
1695 *t = '\0';
1696 *src = s;
1697
1698 n = lookup_ipa(tmpstr, result);
1699 if (n < 0)
1700 report(LOG_ERR, "can not get IP addr for %s", tmpstr);
1701 return n;
1702 }
1677 /* Leading alpha char causes IP addr lookup. */
1678 if (isalpha(**src)) {
1679 /* Lookup IP address. */
1680 s = *src;
1681 t = tmpstr;
1682 while ((isalnum(*s) || (*s == '.') ||
1683 (*s == '-') || (*s == '_') ) &&
1684 (t < &tmpstr[MAXSTRINGLEN - 1]) )
1685 *t++ = *s++;
1686 *t = '\0';
1687 *src = s;
1688
1689 n = lookup_ipa(tmpstr, result);
1690 if (n < 0)
1691 report(LOG_ERR, "can not get IP addr for %s", tmpstr);
1692 return n;
1693 }
1703#endif
1704
1705 /*
1706 * Parse an address in Internet format:
1707 * a.b.c.d
1708 * a.b.c (with c treated as 16-bits)
1709 * a.b (with b treated as 24 bits)
1710 */
1711 pp = parts;

--- 77 unchanged lines hidden (view full) ---

1789 if (hal <= 0) {
1790 report(LOG_ERR, "Invalid addr type for HW addr parse");
1791 return NULL;
1792 }
1793 tmplen = sizeof(tmpstr);
1794 get_string(src, tmpstr, &tmplen);
1795 p = tmpstr;
1796
1694
1695 /*
1696 * Parse an address in Internet format:
1697 * a.b.c.d
1698 * a.b.c (with c treated as 16-bits)
1699 * a.b (with b treated as 24 bits)
1700 */
1701 pp = parts;

--- 77 unchanged lines hidden (view full) ---

1779 if (hal <= 0) {
1780 report(LOG_ERR, "Invalid addr type for HW addr parse");
1781 return NULL;
1782 }
1783 tmplen = sizeof(tmpstr);
1784 get_string(src, tmpstr, &tmplen);
1785 p = tmpstr;
1786
1797#if 1 /* XXX - experimental */
1798 /* If it's a valid host name, try to lookup the HW address. */
1799 if (goodname(p)) {
1800 /* Lookup Hardware Address for hostname. */
1801 if ((hap = lookup_hwa(p, htype)) != NULL)
1802 return hap; /* success */
1803 report(LOG_ERR, "Add 0x prefix if hex value starts with A-F");
1804 /* OK, assume it must be numeric. */
1805 }
1787 /* If it's a valid host name, try to lookup the HW address. */
1788 if (goodname(p)) {
1789 /* Lookup Hardware Address for hostname. */
1790 if ((hap = lookup_hwa(p, htype)) != NULL)
1791 return hap; /* success */
1792 report(LOG_ERR, "Add 0x prefix if hex value starts with A-F");
1793 /* OK, assume it must be numeric. */
1794 }
1806#endif
1807
1808 hap = haddr;
1809 while (hap < haddr + hal) {
1795
1796 hap = haddr;
1797 while (hap < haddr + hal) {
1810 if (*p == '.')
1798 if ((*p == '.') || (*p == ':'))
1811 p++;
1812 if (interp_byte(&p, hap++) < 0) {
1813 return NULL;
1814 }
1815 }
1816 return haddr;
1817}
1818

--- 279 unchanged lines hidden ---
1799 p++;
1800 if (interp_byte(&p, hap++) < 0) {
1801 return NULL;
1802 }
1803 }
1804 return haddr;
1805}
1806

--- 279 unchanged lines hidden ---