Deleted Added
full compact
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>
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;
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 }
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();
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();
858 } else
859 report("bad token in index");
845 gettoken();
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);
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 ---