export.c (133211) | export.c (155429) |
---|---|
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 --- 107 unchanged lines hidden (view full) --- 116 value->v.octetstring.len = (u_long)len; 117 if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) 118 return (SNMP_ERR_RES_UNAVAIL); 119 memcpy(value->v.octetstring.octets, ptr, (size_t)len); 120 return (SNMP_ERR_NOERROR); 121} 122 123/* | 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 --- 107 unchanged lines hidden (view full) --- 116 value->v.octetstring.len = (u_long)len; 117 if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) 118 return (SNMP_ERR_RES_UNAVAIL); 119 memcpy(value->v.octetstring.octets, ptr, (size_t)len); 120 return (SNMP_ERR_NOERROR); 121} 122 123/* |
124 * Get a string value for a response packet but cut it if it is too long. 125 */ 126int 127string_get_max(struct snmp_value *value, const u_char *ptr, ssize_t len, 128 size_t maxlen) 129{ 130 131 if (ptr == NULL) { 132 value->v.octetstring.len = 0; 133 value->v.octetstring.octets = NULL; 134 return (SNMP_ERR_NOERROR); 135 } 136 if (len == -1) 137 len = strlen(ptr); 138 if ((size_t)len > maxlen) 139 len = maxlen; 140 value->v.octetstring.len = (u_long)len; 141 if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL) 142 return (SNMP_ERR_RES_UNAVAIL); 143 memcpy(value->v.octetstring.octets, ptr, (size_t)len); 144 return (SNMP_ERR_NOERROR); 145} 146 147/* |
|
124 * Support for IPADDRESS 125 * 126 * Save the old IP address in scratch->int1 and set the new one. 127 */ 128int 129ip_save(struct snmp_value *value, struct snmp_context *ctx, u_char *valp) 130{ 131 ctx->scratch->int1 = (valp[0] << 24) | (valp[1] << 16) | (valp[2] << 8) --- 243 unchanged lines hidden --- | 148 * Support for IPADDRESS 149 * 150 * Save the old IP address in scratch->int1 and set the new one. 151 */ 152int 153ip_save(struct snmp_value *value, struct snmp_context *ctx, u_char *valp) 154{ 155 ctx->scratch->int1 = (valp[0] << 24) | (valp[1] << 16) | (valp[2] << 8) --- 243 unchanged lines hidden --- |