SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-32
Managers Supporting UDP and IPC
  memcpy ((char*) &host_int->from,
   (void *) ebuffp->start_bp,
   sizeof(host_int->from));
  /* Adjust the "read count" to skip the socket address. */
  read_cnt -= sizeof(struct sockaddr_in);
 }
 *rpkt = SNMP_Decode_Packet_WER(myEBuff.start_bp, read_cnt, <--48
   (SNMPADDR_T*) 0, (SNMPADDR_T *) 0, &err2);
 if (*rpkt == NULL || err2 != 0) <--49
 {
  host_int->err_num = (short) err2; /* Save the error number */
  SNMP_Free(*rpkt);
  *rpkt = NULL;      /* Mark it as returned */
  if (PRINT_DEBUG_MSG)
  {
   fprintf(stdout, "SNMP_DECODE_PACKET returned error %i.\n", err2);
  }
  return DECODE_FAILED;
 }
 /* Do the request IDs match? */
 if ((*rpkt)->pdu.std_pdu.request_id != spkt->pdu.std_pdu.request_id) <--50
 {
  host_int->err_num = REQ_ID_MISMATCH;  /* Set the error number */
  if (PRINT_DEBUG_MSG)
  {
   fprintf(stdout, "Bad REQ ID %i received.\n",
   (*rpkt)->pdu.std_pdu.request_id);
  }
  return REQ_ID_MISMATCH;
 }
 if (PRINT_RECV_MSG)
 {
  fprintf(stdout, "\nRECEIVED PACKET:\n");
  print_pkt(*rpkt);
  fprintf(stdout, "\n");
 }
 EBufferReset(ebuffp);  /* Reset the buffer to a known state */
 return 0;
}
Example 2-2. Contents of snmpfsc (page 19 of 19)










