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

📄 linux-user.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 2 页
字号:
	  case TABLE_USER: 	    return SNMP_NV_V3_User_Add_Mod((struct SNMP_USER_S *)cur, 					   (struct SNMP_USER_S *)new, 					   mod);	  case TABLE_ACCESS:	    return SNMP_NV_V3_Access_Add_Mod((struct SNMP_ACCESS_S *)cur, 					     (struct SNMP_ACCESS_S *)new, 					     mod);	  case TABLE_GROUP:	    return SNMP_NV_V3_Group_Add_Mod((struct SNMP_GROUP_S *)cur, 					    (struct SNMP_GROUP_S *)new, 					    mod);	  case TABLE_NOTIFY:	    return SNMP_NV_V3_Notify_Add_Mod((struct SNMP_NOTIFY_S *)cur, 					     (struct SNMP_NOTIFY_S *)new, 					     mod);	  case TABLE_NFILT:	    return SNMP_NV_V3_NFilt_Add_Mod((struct SNMP_NOTIFY_FILTER_S *)cur, 					    (struct SNMP_NOTIFY_FILTER_S *)new, 					    mod);	  case TABLE_NPROF:	    return SNMP_NV_V3_NProf_Add_Mod((struct SNMP_NOTIFY_FILTER_PROFILE_S *)cur, 					    (struct SNMP_NOTIFY_FILTER_PROFILE_S *)new, 					    mod);	  case TABLE_TADDR:	    return SNMP_NV_V3_TAddr_Add_Mod((struct SNMP_TARGET_ADDR_S *)cur, 					    (struct SNMP_TARGET_ADDR_S *)new, 					    mod);	  case TABLE_TPARAM:	    return SNMP_NV_V3_TParam_Add_Mod((struct SNMP_TARGET_PARAMS_S *)cur, 					     (struct SNMP_TARGET_PARAMS_S *)new, 					     mod);	  case TABLE_PROXY:	    return SNMP_NV_V3_Proxy_Add_Mod((struct SNMP_PROXY_S *)cur,					    (struct SNMP_PROXY_S *)new, 					     mod);	  case TABLE_V3COMM:	    return SNMP_NV_Community_Add_Mod((struct SNMP_COMMUNITY_S *)cur,                                             (struct SNMP_COMMUNITY_S *)new,                                              mod);	}      }      break;          case STAGE_BACKOUT:       SNMP_NV_Clean();      return 0;    case STAGE_SET:       return 0;    case STAGE_UNDO:       SNMP_NV_Clean();      return 0;          case STAGE_FINISHED:      SNMP_NV_Doit();      return 0;  } /* switch(stage) */  return 0;}/* *  */#include <sys/socket.h>#include <netinet/in.h>void USER_send_proxy_pkt ( SNMPADDR_T   *pForAddr,                           SNMPADDR_T   *pLocAddr,                           PTR_T         pPkt,                           ALENGTH_T     need ){#if ICON_PROXY_AGENT  EBUFFER_T ebuff;  struct sockaddr_in remoteAddr;  struct sockaddr_in localAddr;  extern int snmp_socket; /* this should be the snmp socket for the agent */    /* make sure we have an valid socket.  We assume it's initialized   * to -1 and set to some other value when it's created */  if ( snmp_socket == -1 )    return;  EBufferInitialize (&ebuff);  /*   * Just a safety to make sure our sockaddr structures are properly   * aligned...   */  MEMCPY (&remoteAddr, pForAddr, sizeof (struct sockaddr_in));  MEMCPY (&localAddr, pLocAddr, sizeof (struct sockaddr_in));  if (SNMP_Process_Finish ((SNMP_PKT_T *) pPkt, &ebuff, need) == 0)   {    sendto(snmp_socket, EBufferStart(&ebuff), need, /* flags */ 0,           (struct sockaddr *)&remoteAddr, sizeof(remoteAddr));    /* TODO - catch any error and print an error message */    EBufferClean (&ebuff);  }#endif /* ICON_PROXY_AGENT */}#if (INSTALL_ENVOY_SNMP_V3_NOTIFY)/********************************************************************** * These two routines will be used to convert between an SNMPADDR_T and a * TAddress/TDomain pair.  In the case of these demos, the SNMPADDR_T is * an opaque structure equivalent to a (struct sockaddr_in).  For SNMP * over UDP, the TDomain will always be 1.3.6.1.6.1.1, and the TAddress * will be 6 bytes long: 4 bytes of address and 2 bytes of port, all in * network order. *  * These were copied from the default Envoy implemenation, so they can * be overridden if need be.  *  * Both functions return 0 on success, -1 on failure. **********************************************************************/#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <wrn/wm/snmp/engine/objectid.h>OIDC_T udpdomain[] = { 1, 3, 6, 1, 6, 1, 1 };int USER_taddress_to_snmpaddr(SNMPADDR_T *addr,			      OBJ_ID_T   *tdomain,			      EBUFFER_T  *taddress){  struct sockaddr_in sock;  bits16_t port;  bits32_t ipaddr;    if (oidcmp(tdomain->num_components, tdomain->component_list,	     sizeof(udpdomain)/sizeof(OIDC_T), udpdomain) == 1)   {    sock.sin_family = AF_INET;    MEMCPY(&ipaddr, EBufferStart(taddress), 4);    MEMCPY(&port, (EBufferStart(taddress) + 4), 2);    sock.sin_port = port;    sock.sin_addr.s_addr = ipaddr;    MEMCPY(addr, &sock, sizeof(sock));    return 0;  }  return -1;}int USER_snmpaddr_to_taddress(SNMPADDR_T *addr,			      OBJ_ID_T   *tdomain,			      EBUFFER_T  *taddress){  struct sockaddr *sock = (struct sockaddr *)addr;  struct sockaddr_in sock_in;  bits16_t port;  bits32_t ipaddr;  bits8_t tadd[6];  if (sock->sa_family == AF_INET)   {    (void) memcpy((char *)(&sock_in), (char *)addr, sizeof(struct sockaddr_in));    if (build_object_id(sizeof(udpdomain)/sizeof(OIDC_T), udpdomain, tdomain))      return -1;    ipaddr = sock_in.sin_addr.s_addr;    port = sock_in.sin_port;    MEMCPY(tadd, &ipaddr, 4);    MEMCPY(tadd + 4, &port, 2);    if (EBufferAllocateLoad(BFL_IS_ALLOC, taddress, tadd, 6))     {      Clean_Obj_ID(tdomain);      return -1;    }        return 0;  }    return -1;}#endif /* #if INSTALL_ENVOY_SNMP_V3_NOTIFY */#endif /* #if INSTALL_ENVOY_SNMP_VERSION_3 */#if INSTALL_ENVOY_AGENTX_MASTER#include <wrn/wm/snmp/engine/agentx.h>extern UINT_32_T sysuptime(void); /* user must define this *//* * ENVOY_GET_SYSUPTIME * * INPUT: *     context -- gives the context to look in for the sysUptime  *                object.  Ignored in this example. * RETURNS:  *     the value of sysUptime. */bits32_t USER_get_sysuptime(void){  return sysuptime();}/* * ENVOY_AX_TRANSPORT_TYPE * * INPUT: *     cookie -- the pointer to the address block passed into the *               master handler.   * RETURNS:  *     transport type of the address according to the AgentX spec */sbits32_t USER_ax_transport_type(ptr_t cookie){  return(ENVOY_AX_TRANSPORT_TYPE_TCP);}/* * ENVOY_AX_TRANSPORT_STRING * * INPUT: *     cookie -- the pointer to the address block passed into the *               master handler.  In this case, probably a socket. *     length -- receives the length of the data being placed into buffer. *     buffer -- the memory for the transport string to be placed into. *     dynamic -- if set to non-zero, Envoy should free this string using *                SNMP_memory_free() once it's finished with it. * RETURNS:  *     0 if error, anything else otherwise  */int USER_ax_transport_string(ptr_t cookie, ALENGTH_T *length,			     bits8_t **buffer, int *dynamic){  struct sockaddr_in remote_addr;  int                addr_size;    *buffer = SNMP_memory_alloc(17);  if (*buffer == 0)    return(0);    if (getpeername((int) cookie, 		  (struct sockaddr *) &remote_addr,                   &addr_size))  {    SNMP_memory_free(*buffer);    return 0;  }    strcpy(*buffer, inet_ntoa(remote_addr.sin_addr));    *length = strlen(*buffer);  *dynamic = 1;  return(1);}/*  * no documentation was found on this, it does not appear to be * used in the envoy sources at all.   */bits8_t USER_ax_transports_supported(){  return 0;}/* * ENVOY_AX_FIND_MIB * * This routine will be given the context information from a sub agent * request message.  If the context is valid this routine should return * the root of the mib tree associated with that context. * If the context is invalid it should return 0. * * INPUT: *   context - the context information from the request packet * * RETURNS: *   On success a pointer to the root of the mib tree, otherwise a zero */MIBNODE_T *USER_ax_find_mib( EBUFFER_T *context ){#if ICON_AGENTX_AGENT  /* this is only valid for a real agent */  if (EBufferUsed(context) == 0)    return(&mib_root_node);#endif  return(0);}/* * ENVOY_AX_MA_AC_ADD * * INPUT: *   ax_pkt - a pointer to a an AgentX packet structure that contains *            the list of varbinds that a sub agent has requested the *            master agent register in its agent capabilities table. *   mibroot - the root of the tree that was identified by  *             envoy_ax_find_mib() * RETURNS: *   the return code will be the error status for the response message *   as per the AgentX specificaition, 0 means no error. */bits16_t USER_ax_ma_ac_add( struct ENVOY_AX_PKT_S *ax_pkt, 			    MIBNODE_T *mibroot ){  return(GEN_ERR);}/* * ENVOY_AX_MA_AC_REMOVE * * INPUT: *   ax_pkt - a pointer to a an AgentX packet structure that contains *            the list of varbinds that a sub agent has requested the *            master agent unregister from its agent capabilities table. *   mibroot - the root of the tree that was identified by  *             envoy_ax_find_mib() * RETURNS: *   the return code will be the error status for the response message *   as per the AgentX specificaition, 0 means no error. */bits16_t USER_ax_ma_ac_remove( struct ENVOY_AX_PKT_S *ax_pkt,			       MIBNODE_T *mibroot ){  return(GEN_ERR);}/* * ENVOY_AX_MA_AC_CLEAN  * * A call to this routine is a request from the master agent to remvoe * any agent capabilities that have been registered by the sub agent with * the input id.  The master agent will call this routine when it is trying * to close a session and would like to clean up any resources associated * with it. *  * INPUT: *   session_id - the id of the session being closed\ * RETURNS: *   nothing */void USER_ax_ma_ac_clean( bits32_t session_id ){}/* * These next two functions are required on the Master Agent which * will have to provide the real implementation.  So we #if 0 them * out. */#if 0/******************************************************************************* * * envoyAxConnEntry - Return the time, domain and address for a given connection * * This function is provided to support the AgentX MIB. *  * matchFlag is AX_MATCH_GET(1) or AX_MATCH_NEXT(2) from axapi.h * * Returns:  1 for success, 0 for failure. */bits32_t USER_ax_conn_entry(bits32_t axConnID, int matchFlag, struct AX_CONNENT_S *pConnEntry){  return 0;}/******************************************************************************* * * envoyAxGetConnID - Return the connection ID for a given session ID * * This function is provided to support the AgentX MIB. * * Returns:  Connection ID if successful; 0 for failure. */bits32_t USER_ax_get_connid(struct AX_CONN_S *pCE){  return 0;}#endif#endif

⌨️ 快捷键说明

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