⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 table_sa.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
init_object_id(&demuxer.object);hdr_blk.version    = 1;hdr_blk.opcode1    = SA_REG_OBJ_REQUEST;hdr_blk.opcode2    = 0;hdr_blk.sa_error   = 0;hdr_blk.encoding   = SA_ENCODING_ASN1;hdr_blk.snmp_version = 0;hdr_blk.requestid  = 0;hdr_blk.sysuptime  = 0;hdr_blk.index      = 0;hdr_blk.snmp_error = 0;eret = SA_Encode(&vblist, &hdr_blk, &demuxer, &ebuf);if (eret) {    printf("Error creating message %ld\n", eret);    exit(1);    }/* build socket */sock = socket(AF_UNIX, SOCK_DGRAM, 0);if (sock < 0) {    printf("Error opening datagram socket\n");    exit(1);    }unlink(subagent);sa_name.sun_family = AF_UNIX;STRCPY(sa_name.sun_path, subagent);/* bind the socket to a name */if (bind(sock, (struct sockaddr *)&sa_name, sizeof(struct sockaddr_un))) {    printf("Error binding socket name\n");    exit(1);    }master_name.sun_family = AF_UNIX;STRCPY(master_name.sun_path, MASTER);/* send message */while(sendto(sock, EBufferStart(&ebuf), EBufferUsed(&ebuf), 0,	   (struct sockaddr *)&master_name, sizeof(struct sockaddr_un)) < 0) {    printf("Registration request failed: %d, will try again\n", errno);    }/* done with the buffer so clean it up */EBufferClean(&ebuf);fromlen = sizeof(struct sockaddr_un);cc = recvfrom(sock, buf, BUFLEN, 0, (struct sockaddr *)&from, &fromlen);eret = SA_Handler((OCTET_T *)buf, (ALENGTH_T)cc, &rbuf, &hdr_blk,		  &rvblist);if ((eret != 0) || (hdr_blk.sa_error)) {    printf("Error with registration %d\n", hdr_blk.sa_error);    exit(1);    }else    groupid = hdr_blk.index;/* clean up the receive buffer */EBufferClean(&rbuf);Clean_vb_list(&rvblist);/* set up the instance message, send everybody */for (i = 0; i < (argc * 3) + 3; i++)    vbl[i].vb_flags  = VFLAG_SA_SENDIT;hdr_blk.version    = 1;hdr_blk.opcode1    = SA_REG_INST_REQUEST;hdr_blk.opcode2    = 0;hdr_blk.sa_error   = 0;hdr_blk.encoding   = SA_ENCODING_ASN1;hdr_blk.snmp_version = 0;hdr_blk.requestid  = 0;hdr_blk.sysuptime  = 0;hdr_blk.index      = groupid;hdr_blk.snmp_error = 0;eret = SA_Encode(&vblist, &hdr_blk, &demuxer, &ebuf);if (eret) {    printf("Error creating message %ld\n", eret);    exit(1);    }if (sendto(sock, EBufferStart(&ebuf), EBufferUsed(&ebuf), 0,	   (struct sockaddr *)&master_name, sizeof(struct sockaddr_un)) < 0) {    printf("Failed trying to send inst registration\n");    exit(1);    }/* clean up the buffer */EBufferClean(&ebuf);fromlen = sizeof(struct sockaddr_un);cc = recvfrom(sock, buf, BUFLEN, 0, (struct sockaddr *)&from, &fromlen);eret = SA_Handler((OCTET_T *)buf, (ALENGTH_T)cc, &rbuf, &hdr_blk,		  &rvblist);if ((eret != 0) || (hdr_blk.sa_error)) {    printf("Error with inst registration %d\n", hdr_blk.sa_error);    exit(1);    }/* Loop waiting for messages. */while(1) {    cookie = (EX_SAADDR_T *)SNMP_memory_alloc(sizeof(EX_SAADDR_T));    if (cookie == 0) {	printf("Unable to allocate control block\n");	exit(1);	}    cookie->sock = sock;    cookie->fromlen = sizeof(struct sockaddr_un);    cc = recvfrom(sock, buf, BUFLEN, 0, (struct sockaddr *)&(cookie->from),		  &(cookie->fromlen));    SA_Handler_Async((OCTET_T *)buf, (ALENGTH_T)cc, 0,		     io_compat, err_compat, reg_compat,		     (PTR_T)cookie);    }}void  table_free(PTR_T vbptr){return;}/****************************************************************************NAME:  sa_table_testPURPOSE:  Find the appropriate entry in the sub agent table and attach	  information from it to the vbp using the getproc_got_* functions.	  If we can't find an entry indicate that by calling getproc_nosuchins.PARAMETERS:	OIDC_T		Last component of the object id leading to			the leaf node in the MIB.  This is usually			the identifier for the particular attribute			in the table.	int		Number of components in the unused part of the			object identifier	OIDC_T *	Unused part of the object identifier	SNMP_PKT_T *	SNMP packet currently being processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  sa_table_test(OIDC_T		 last_match,		int		 tcount,		OIDC_T		*tlist,		SNMP_PKT_T	*pktp,		VB_T		*vbp){  int i;  INT_32_T value;  value = vbp->value_u.v_number;  if ((value < 1) || (value > 10)) {      testproc_error(pktp, vbp, WRONG_VALUE);      return;      }  if (tcount != 1) {      testproc_error(pktp, vbp, NO_CREATION);      return;      }  for(i = 0; i < ilen; i++)      if (indexlist[i].index == *tlist) {	  vbp->vb_free_priv = table_free;	  vbp->vb_priv = 0;	  testproc_good(pktp, vbp);	  return;	  }  testproc_error(pktp, vbp, NO_CREATION);  return;}/****************************************************************************NAME:  sa_table_nextPURPOSE:  Find the appropriate entry in the sub agent table and attach	  information from it to the vbp using the getproc_got_* functions.	  If we can't find an entry indicate that by calling getproc_nosuchins.PARAMETERS:	OIDC_T		Last component of the object id leading to			the leaf node in the MIB.  This is usually			the identifier for the particular attribute			in the table.	int		Number of components in the unused part of the			object identifier	OIDC_T *	Unused part of the object identifier	SNMP_PKT_T *	SNMP packet currently being processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  sa_table_next(OIDC_T		 last_match,		int		 tcount,		OIDC_T		*tlist,		SNMP_PKT_T	*pktp,		VB_T		*vbp){  nextproc_no_next(pktp, vbp);  return;}/****************************************************************************NAME:  sa_table_getPURPOSE:  Find the appropriate entry in the sub agent table and attach	  information from it to the vbp using the getproc_got_* functions.	  If we can't find an entry indicate that by calling getproc_nosuchins.PARAMETERS:	OIDC_T		Last component of the object id leading to			the leaf node in the MIB.  This is usually			the identifier for the particular attribute			in the table.	int		Number of components in the unused part of the			object identifier	OIDC_T *	Unused part of the object identifier	SNMP_PKT_T *	SNMP packet currently being processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  sa_table_get(OIDC_T		 last_match,	       int		 tcount,	       OIDC_T		*tlist,	       SNMP_PKT_T	*pktp,	       VB_T		*vbp){  int i;  if (tcount != 1) {      getproc_nosuchins(pktp, vbp);      return;      }  for(i = 0; i < ilen; i++)      if (indexlist[i].index == *tlist) {	  switch(last_match) {	      case LM_tableindex:		  getproc_got_int32(pktp, vbp, (INT_32_T)indexlist[i].index);		  break;	      case LM_tabletype:		  getproc_got_int32(pktp, vbp, (INT_32_T)indexlist[i].type);		  break;	      case LM_tabledescr:		  getproc_got_string(pktp, vbp, STRLEN(subagent), subagent,				     0, VT_STRING);		  break;	      }	  return;	  }  getproc_nosuchins(pktp, vbp);  return;}/****************************************************************************NAME:  sa_table_setPURPOSE:  Find the appropriate entry in the sub agent table and attach	  information from it to the vbp using the getproc_got_* functions.	  If we can't find an entry indicate that by calling getproc_nosuchins.PARAMETERS:	OIDC_T		Last component of the object id leading to			the leaf node in the MIB.  This is usually			the identifier for the particular attribute			in the table.	int		Number of components in the unused part of the			object identifier	OIDC_T *	Unused part of the object identifier	SNMP_PKT_T *	SNMP packet currently being processed.	VB_T *		Variable being processed.RETURNS: void****************************************************************************//*ARGSUSED*/void  sa_table_set(OIDC_T		 last_match,	       int		 tcount,	       OIDC_T		*tlist,	       SNMP_PKT_T	*pktp,	       VB_T		*vbp){  int i;  for(i = 0; i < ilen; i++)      if (indexlist[i].index == *tlist)	  indexlist[i].type = VB_GET_INT32(vbp);  setproc_good(pktp, vbp);  vbp->vb_free_priv = 0;  vbp->vb_priv = 0;  return;}/* Stub routines to keep from using the versions in sun/agent.c */bits32_t  envoy_now(void){return(0);}void  envoy_call_timer (bits32_t when,		    void (*what)(void)){return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -