Hi Dave,
Thanks for your reply. I am working with template code which was generated from mib2c.iterate_access.conf. Because of performance issue, I get the external data(PHY register values) in each column's get_ routine like following: ex: char *get_xDSLSCStatusPerBinActualMaxTxPsd(void *data_context, size_t *ret_len) { int port_num; int shm_id; char *ptr; xDSLSCStatusEntry *entry_ptr = (xDSLSCStatusEntry *)data_context; port_num = IFIX_TRANSFORM_TO_PORT_ID(entry_ptr->ifIndex); shm_id = SEND_GET_REQ_TO_DSL_TSK(port_num, GSMIB_xDSLSCStatusTable, GSMIB_xDSLSCStatusPerBinActualMaxTxPsd, NULL, 0, 1, entry_ptr->xDSLSCStatusDirection, 0xff, 0xff); if(shm_id == 1) { printf("shm_id = 1\n"); return NULL; } else { ptr = (char *)shmat(shm_id, NULL, 0); if((int)ptr == -1) { printf("shmat fail\n"); return NULL; } memcpy(entry_ptr->xDSLSCStatusPerBinActualMaxTxPsd, ptr, 1024 * sizeof(char)); if(shmdt(ptr) == -1) perror(" detach error "); shmctl(shm_id, IPC_RMID, NULL); *ret_len = strlen(entry_ptr->xDSLSCStatusPerBinActualMaxTxPsd); return (char *)(entry_ptr->xDSLSCStatusPerBinActualMaxTxPsd); /** XXX: replace this with a pointer to a real value */ } } Function SEND_GET_REQ_TO_DSL_TSK() was used to get external data, it will return a share memory id when everything is correct. Otherwise it will return 1 when there's an error occured during getting external data. I find that if shm_id = 1, get_ routine will return NULL and there will be a segmentation fault. Is there anything wrong in my get_ routine? Or it's a net-snmp 5.1.1's bug? Thanks, 永鈦鑫 iTAS Corporation 新竹市水源街75號 NO. 75,Shuiyuan St., Hsinchu City, Taiwan, R.O.C. Tel:03-5716099 Ext.1208 E-mail:tewen.hs...@itas.com.tw ----- Original Message ----- From: "Dave Shield" <d.t.shi...@liverpool.ac.uk> To: "Tewen Hsieh" <tewen.hs...@itas.com.tw> Cc: <net-snmp-coders@lists.sourceforge.net> Sent: Monday, August 17, 2009 7:25 PM Subject: Re: Could anyone give me some suggestions? 2009/8/17 Tewen Hsieh <tewen.hs...@itas.com.tw>: > But there's segmentation fault when it returns NULL in get_ routine. > Is it a normal result? It's never normal for the agent to crash. > Additionally, how can I inducate that there's an error when fail getting > external data? > I mean in the template code which was generated from > mib2c.iterate_access.conf, where can I return the > error-status(SNMP_ERR_GENERR, etc.) for get requests? What does the code look like? We can't make suggestions if we don't know what code you are working with. Dave ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders