config.c (205729) | config.c (216294) |
---|---|
1/* 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $Begemot: bsnmp/snmpd/config.c,v 1.25 2006/02/14 09:04:20 brandt_h Exp $ 30 * 31 * Parse configuration file. 32 */ 33#include <sys/types.h> | 1/* 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $Begemot: bsnmp/snmpd/config.c,v 1.25 2006/02/14 09:04:20 brandt_h Exp $ 30 * 31 * Parse configuration file. 32 */ 33#include <sys/types.h> |
34#include <sys/queue.h> |
|
34#include <sys/socket.h> 35#include <sys/un.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <string.h> 39#include <stdarg.h> 40#include <ctype.h> 41#include <errno.h> --- 763 unchanged lines hidden (view full) --- 805 * Parse the left hand side of a config line. 806 */ 807static const struct snmp_node * 808parse_oid(const char *varname, struct asn_oid *oid) 809{ 810 struct snmp_node *node; 811 u_int i; 812 u_char ip[4]; | 35#include <sys/socket.h> 36#include <sys/un.h> 37#include <stdio.h> 38#include <stdlib.h> 39#include <string.h> 40#include <stdarg.h> 41#include <ctype.h> 42#include <errno.h> --- 763 unchanged lines hidden (view full) --- 806 * Parse the left hand side of a config line. 807 */ 808static const struct snmp_node * 809parse_oid(const char *varname, struct asn_oid *oid) 810{ 811 struct snmp_node *node; 812 u_int i; 813 u_char ip[4]; |
814 struct asn_oid str_oid; |
|
813 814 for (node = tree; node < &tree[tree_size]; node++) 815 if (strcmp(varname, node->name) == 0) 816 break; 817 if (node == &tree[tree_size]) 818 node = NULL; 819 820 oid->len = 0; 821 while (token == '.') { 822 if (gettoken() == TOK_NUM) { 823 if (numval > ASN_MAXID) 824 report("subid too large %#"QUADXFMT, numval); 825 if (oid->len == ASN_MAXOIDLEN) 826 report("index too long"); | 815 816 for (node = tree; node < &tree[tree_size]; node++) 817 if (strcmp(varname, node->name) == 0) 818 break; 819 if (node == &tree[tree_size]) 820 node = NULL; 821 822 oid->len = 0; 823 while (token == '.') { 824 if (gettoken() == TOK_NUM) { 825 if (numval > ASN_MAXID) 826 report("subid too large %#"QUADXFMT, numval); 827 if (oid->len == ASN_MAXOIDLEN) 828 report("index too long"); |
827 oid->subs[oid->len++] = numval; | 829 if (gettoken() != ':') 830 oid->subs[oid->len++] = numval; 831 else { 832 str_oid.len = 0; 833 str_oid.subs[str_oid.len++] = numval; 834 while (gettoken() == TOK_NUM) { 835 str_oid.subs[str_oid.len++] = numval; 836 if (gettoken() != ':') 837 break; 838 } 839 oid->subs[oid->len++] = str_oid.len; 840 asn_append_oid(oid, &str_oid); 841 } |
828 829 } else if (token == TOK_STR) { 830 if (strvallen + oid->len + 1 > ASN_MAXOIDLEN) 831 report("oid too long"); 832 oid->subs[oid->len++] = strvallen; 833 for (i = 0; i < strvallen; i++) 834 oid->subs[oid->len++] = strval[i]; | 842 843 } else if (token == TOK_STR) { 844 if (strvallen + oid->len + 1 > ASN_MAXOIDLEN) 845 report("oid too long"); 846 oid->subs[oid->len++] = strvallen; 847 for (i = 0; i < strvallen; i++) 848 oid->subs[oid->len++] = strval[i]; |
849 gettoken(); |
|
835 836 } else if (token == TOK_HOST) { 837 gethost(strval, ip); 838 if (oid->len + 4 > ASN_MAXOIDLEN) 839 report("index too long"); 840 for (i = 0; i < 4; i++) 841 oid->subs[oid->len++] = ip[i]; | 850 851 } else if (token == TOK_HOST) { 852 gethost(strval, ip); 853 if (oid->len + 4 > ASN_MAXOIDLEN) 854 report("index too long"); 855 for (i = 0; i < 4; i++) 856 oid->subs[oid->len++] = ip[i]; |
842 | 857 gettoken(); |
843 } else 844 report("bad token in index"); | 858 } else 859 report("bad token in index"); |
845 gettoken(); | |
846 } 847 848 return (node); 849} 850 851/* 852 * Parse the value for an assignment. 853 */ --- 147 unchanged lines hidden (view full) --- 1001parse_assign(const char *varname) 1002{ 1003 struct snmp_value value; 1004 struct asn_oid vindex; 1005 const struct snmp_node *node; 1006 1007 node = parse_oid(varname, &vindex); 1008 if (token != '=') | 860 } 861 862 return (node); 863} 864 865/* 866 * Parse the value for an assignment. 867 */ --- 147 unchanged lines hidden (view full) --- 1015parse_assign(const char *varname) 1016{ 1017 struct snmp_value value; 1018 struct asn_oid vindex; 1019 const struct snmp_node *node; 1020 1021 node = parse_oid(varname, &vindex); 1022 if (token != '=') |
1009 report("'=' expected"); | 1023 report("'=' expected, got '%c'", token); |
1010 gettoken(); 1011 1012 if (ignore) { 1013 /* skip rest of line */ 1014 while (token != TOK_EOL && token != TOK_EOF) 1015 gettoken(); 1016 return; 1017 } --- 350 unchanged lines hidden --- | 1024 gettoken(); 1025 1026 if (ignore) { 1027 /* skip rest of line */ 1028 while (token != TOK_EOL && token != TOK_EOF) 1029 gettoken(); 1030 return; 1031 } --- 350 unchanged lines hidden --- |