MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsSideChannelSNMPGet

Function cupsSideChannelSNMPGet

cups/sidechannel.c:294–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292 */
293
294cups_sc_status_t /* O - Query status */
295cupsSideChannelSNMPGet(
296 const char *oid, /* I - OID to query */
297 char *data, /* I - Buffer for OID value */
298 int *datalen, /* IO - Size of OID buffer on entry, size of value on return */
299 double timeout) /* I - Timeout in seconds */
300{
301 cups_sc_status_t status; /* Status of command */
302 cups_sc_command_t rcommand; /* Response command */
303 char *real_data; /* Real data buffer for response */
304 int real_datalen, /* Real length of data buffer */
305 real_oidlen; /* Length of returned OID string */
306
307
308 DEBUG_printf(("cupsSideChannelSNMPGet(oid=\"%s\", data=%p, datalen=%p(%d), "
309 "timeout=%.3f)", oid, data, datalen, datalen ? *datalen : -1,
310 timeout));
311
312 /*
313 * Range check input...
314 */
315
316 if (!oid || !*oid || !data || !datalen || *datalen < 2)
317 return (CUPS_SC_STATUS_BAD_MESSAGE);
318
319 *data = '\0';
320
321 /*
322 * Send the request to the backend and wait for a response...
323 */
324
325 if (cupsSideChannelWrite(CUPS_SC_CMD_SNMP_GET, CUPS_SC_STATUS_NONE, oid,
326 (int)strlen(oid) + 1, timeout))
327 return (CUPS_SC_STATUS_TIMEOUT);
328
329 if ((real_data = _cupsBufferGet(_CUPS_SC_MAX_BUFFER)) == NULL)
330 return (CUPS_SC_STATUS_TOO_BIG);
331
332 real_datalen = _CUPS_SC_MAX_BUFFER;
333 if (cupsSideChannelRead(&rcommand, &status, real_data, &real_datalen, timeout))
334 {
335 _cupsBufferRelease(real_data);
336 return (CUPS_SC_STATUS_TIMEOUT);
337 }
338
339 if (rcommand != CUPS_SC_CMD_SNMP_GET)
340 {
341 _cupsBufferRelease(real_data);
342 return (CUPS_SC_STATUS_BAD_MESSAGE);
343 }
344
345 if (status == CUPS_SC_STATUS_OK)
346 {
347 /*
348 * Parse the response of the form "oid\0value"...
349 */
350
351 real_oidlen = (int)strlen(real_data) + 1;

Callers 1

mainFunction · 0.85

Calls 4

cupsSideChannelWriteFunction · 0.85
_cupsBufferGetFunction · 0.85
cupsSideChannelReadFunction · 0.85
_cupsBufferReleaseFunction · 0.85

Tested by 1

mainFunction · 0.68