/*-----------------------------------------------------------------------*/
/* process_trp - process a trap that came in				 */
/*-----------------------------------------------------------------------*/

#include <conf.h>			/* local nyser config */
#ifdef BSD
#include <stdio.h>			/* for fprintf */
#include <sys/types.h>			/* needed by socket.h and in.h */
#include <sys/socket.h>			/* for inet_ntoa */
#include <netinet/in.h>			/* ditto... */
#include <arpa/inet.h>			/* ditto... */
#endif /* BSD */

#include <snmp_hs.h>
#include "cmon.h"


void
process_trp(mesg)
     trptype *mesg;
{
  AGENT *a;
  int found;  

  if (mesg->gtrp == VENDOR)		/* Vendor specific trap */
    {
      found = FALSE;
      for (a = first_agent; a != (AGENT *)NULL; a = a->nxt)
	if( a->agnt.s_addr == mesg->agnt.s_addr)
	  {
	    a->status = mesg->strp;
	    found = TRUE;
	    break;
	  }

      fprintf(stderr, "process_trp: %s - %s %s, %s\n",
	      (found ? "trap matched" : "match FAILED"),
	      (found ? a->nm : ""),
	      inet_ntoa(mesg->agnt),
	      (mesg->strp ? "login" : "logout"));
    }
}
