--===============0572539865==
Content-Type: multipart/alternative;
boundary="----=_Part_22120_20981239.1165398840059"

------=_Part_22120_20981239.1165398840059
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hello friends,
I have installed netsnmp version 5.2.3 on windows
I have written code for suagent which will send trap to
main agent i.e. agentX.
so this is my code for subagent which send trap to main agent

#include
#include
#include
#define SUB_AGENT 1
#include
#include
#define MAX_PENDING_CONN 5
#define BUFF_LEN 1024

static oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
int
send_Event_trap( )
{
netsnmp_variable_list *var_list = NULL;


int i;
int num_devices;


oid Event_oid[] =
{ 1, 3, 6, 1, 4, 1, 16901, 0, 1 };

char data_str[]="testing windows trap";
oid EventShortText_oid[] =
{ 1, 3, 6, 1, 4, 1, 16901, 4, 0 };
snmp_varlist_add_variable(&var_list,
snmptrap_oid, OID_LENGTH(snmptrap_oid),
ASN_OBJECT_ID,
( u_char* ) Event_oid,
sizeof(Event_oid) );
snmp_varlist_add_variable( &var_list,
EventShortText_oid,
OID_LENGTH(EventShortText_oid),
ASN_OCTET_STR,
data_str ,
strlen(data_str));

send_v2trap(var_list);
snmp_free_varbind(var_list);
return SNMP_ERR_NOERROR;
}

////////////////////////////////


int send_trap()
{
send_Event_trap ();
return 0;
}


int
main (int argc, char **argv)
{
int agentx_subagent=1; /* change this if you want to be a SNMP master
agent */
int background = 1; /* change this if you want to run in the background */
int num_fds;
fd_set fdset;
int count;
int listen_fd;
int sock_fd;
int keep_running = 0;
if (agentx_subagent) {
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE,
SUB_AGENT);
// My comment
// Setting host,port for communication
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_X_SOCKET, "udp:localhost:705");
}
init_agent("sub-agent");
if (!agentx_subagent) {
init_vacm_vars();
init_usmUser();
}
init_snmp("sub-agent");
if (!agentx_subagent)
init_master_agent();
keep_running = 1;
send_trap( );
return 0;
}

so when i run this code it throws following warning
No log handling enabled - turning on stderr logging
Warning: Failed to connect to the agentx master agent (udp:localhost:705):
Unknown host (udp:localhost:705)

In my snmpd.conf i also set entry like this
master agentx
agentXSocket udp:localhost:705

this is netstat shows when my snmpd start
C:\Documents and Settings\Administrator.ATN-80>netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP atn-80:1367 192.168.1.13:epmap TIME_WAIT
TCP atn-80:1368 192.168.1.13:1026 TIME_WAIT
TCP atn-80:1369 192.168.1.13:1026 TIME_WAIT
UDP atn-80:snmp *:*
UDP atn-80:microsoft-ds *:*
UDP atn-80:isakmp *:*
UDP atn-80:1025 *:*
UDP atn-80:1026 *:*
UDP atn-80:1045 *:*
UDP atn-80:4500 *:*
UDP atn-80:ntp *:*
UDP atn-80:705 *:*
UDP atn-80:1027 *:*
UDP atn-80:1053 *:*
UDP atn-80:1137 *:*
UDP atn-80:1379 *:*
UDP atn-80:1380 *:*
UDP atn-80:1381 *:*
UDP atn-80:1382 *:*
UDP atn-80:1383 *:*
UDP atn-80:1384 *:*
UDP atn-80:1385 *:*
UDP atn-80:1386 *:*
UDP atn-80:1900 *:*
UDP atn-80:ntp *:*
UDP atn-80:netbios-ns *:*
UDP atn-80:netbios-dgm *:*
UDP atn-80:1900 *:*
so according to status of netstat snmpd listen on 705 port
but still subagent not able to connect to main agent,
i tried for tcp protocol also by setting entry in snmpd.conf as well in
my code but still same error is coming .
what is the problem ?
Thanks in advance
Bhushan E. Sonawane






--
bhushan. E . Sonawane

------=_Part_22120_20981239.1165398840059
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

hello friends,
I have installed netsnmp version 5.2.3 on windows
I ha=
ve written code for suagent which will send trap to
main agent i.e. age=
ntX.
so this is my code for subagent which send trap to main agent


#include <net-snmp/net-snmp-config.h>
#include <net-snmp/ne=
t-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-include=
s.h>
#define SUB_AGENT 1
#include <time.h>
#include <
signal.h>
#define MAX_PENDING_CONN 5
#define BUFF_LEN 1024

=
static oid      snmptrap_oid[] =3D { 1, 3, 6, 1, 6=
, 3, 1, 1, 4, 1, 0 };
int
send_Event_trap( )
{
  &nbs=
p; netsnmp_variable_list *var_list =3D NULL;

           &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;       
    int i; r>    int num_devices;
     &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;           &nbs=
p;            &=
nbsp;=20

    oid        &=
nbsp;    Event_oid[] =3D
     &n=
bsp;  { 1, 3, 6, 1, 4, 1, 16901, 0, 1 };
    &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;      
    char &nbs=
p;            &=
nbsp; data_str[]=3D"testing windows trap";
    =
oid            =
EventShortText_oid[] =3D

        { 1, 3, 6, 1, 4, 1, 16901, 4=
, 0 };
    snmp_varlist_add_variable(&var_list,
&n=
bsp;           &nbsp=
;            &n=
bsp;    snmptrap_oid, OID_LENGTH(snmptrap_oid),
 &nb=
sp;            =
            &nb=
sp;   ASN_OBJECT_ID,
      &nbsp=
;            &n=
bsp;          ( u_char* ) Even=
t_oid,

           &nbsp=
;            &n=
bsp;  sizeof(Event_oid) );
    snmp_varlist_add_vari=
able( &var_list,
        &nb=
sp;            =
   EventShortText_oid,
      &nb=
sp;            =
     OID_LENGTH(EventShortText_oid),
  &nb=
sp;            =
         ASN_OCTET_STR,

           &nbsp=
;            data_st=
r , strlen(data_str));        &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;            &n=
bsp;           &nbsp=
;  
    send_v2trap(var_list);
  =
  snmp_free_varbind(var_list);

    return SNMP_ERR_NOERROR;
}

///////////////=
/////////////////


int send_trap()
{
    sen=
d_Event_trap ();
    return 0;
}


int
mai=
n (int argc, char **argv)
{
  int agentx_subagent=3D1; /* chang=
e this if you want to be a SNMP master agent */

  int background =3D 1; /* change this if you want to run in the b=
ackground */
  int num_fds;
  fd_set fdset;
  int c=
ount;
  int listen_fd;   
  int sock_fd;
>  int keep_running =3D 0;
  if (agentx_subagent) {

    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NE=
TSNMP_DS_AGENT_ROLE, SUB_AGENT);
    // My comment
&nb=
sp;   // Setting host,port for communication
  &nbs=
p; netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCK=
ET, "udp:localhost:705");

  }
  init_agent("sub-agent");
  if (!ag=
entx_subagent) {
      init_vacm_vars();
&nb=
sp;     init_usmUser();
  }
  init_snmp=
("sub-agent");
  if (!agentx_subagent)
  &nb=
sp; init_master_agent();

  keep_running =3D 1;
  send_trap( );
  return 0;<=
br>}

so when i run this code it throws following warning
No log =
handling enabled - turning on stderr logging
Warning: Failed to connect =
to the agentx master agent (udp:localhost:705): Unknown host (udp:localhost=
:705)


In my snmpd.conf i also set entry like this
master agentx
ag=
entXSocket udp:localhost:705

this is netstat shows when my snmpd sta=
rt
C:\Documents and Settings\Administrator.ATN-80>netstat -a

Active Connections
  Proto  Local Address   &nb=
sp;      Foreign Address    &n=
bsp;   State
  TCP    atn-80:1367 &nb=
sp;          192.168.1.13:epma=
p     TIME_WAIT
  TCP    atn-80:=
1368            ref=3D"http://192.168.1.13:1026">
192.168.1.13:1026
      TIME_WAIT
  TCP=
    atn-80:1369       &nb=
sp;    192.168.1.13:102=
6
      TIME_WAIT
  UDP  &nbs=
p; atn-80:snmp          &=
nbsp; *:*
  UDP    atn-80:microsoft-ds  &n=
bsp; *:*

  UDP    atn-80:isakmp    &nbsp=
;     *:*
  UDP    atn-80:1025&n=
bsp;           *:*
&nb=
sp; UDP    atn-80:1026      &n=
bsp;     *:*
  UDP    atn-80:104=
5            *:*
=
  UDP    atn-80:4500     &nbsp=
;      *:*
  UDP    atn-80:=
ntp            =
*:*

  UDP    =
atn-80:705          &nbsp=
;  *:*

  UDP    atn-80:1027  &=
nbsp;         *:*
  UDP&nbs=
p;   atn-80:1053        &=
nbsp;   *:*
  UDP    atn-80:1137 &nbs=
p;          *:*
  UDP&=
nbsp;   atn-80:1379       &nbs=
p;    *:*

  UDP    atn-80:1380     &=
nbsp;      *:*
  UDP    atn=
-80:1381            =
*:*
  UDP    atn-80:1382    &nbs=
p;       *:*
  UDP    =
atn-80:1383          &nbs=
p; *:*
  UDP    atn-80:1384    &=
nbsp;       *:*
  UDP  &nbs=
p; atn-80:1385          &=
nbsp; *:*

  UDP    atn-80:1386     &=
nbsp;      *:*
  UDP    atn=
-80:1900            =
*:*
  UDP    atn-80:ntp    &nbsp=
;        *:*
  UDP  &n=
bsp; atn-80:netbios-ns      *:*
  UDP&nbsp=
;   atn-80:netbios-dgm     *:*
  UDP&=
nbsp;   atn-80:1900       &nbs=
p;    *:*

  so according to status of netstat snmpd listen on 705 port
&n=
bsp; but still subagent not able to connect to main agent,
  i trie=
d for tcp protocol also by setting entry in snmpd.conf as well in
&nbsp=
; my code but still same error is coming .=20

  what is the problem ?
  Thanks in advance
  Bhus=
han E. Sonawane






--
 &nbsp=
;          bhushan. E . S=
onawane

------=_Part_22120_20981239.1165398840059--


--===============0572539865==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?p...rge&CID=DEVDEV
--===============0572539865==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders

--===============0572539865==--