Index: squid/snmplib/snmp_api.c diff -c squid/snmplib/snmp_api.c:1.17.2.1 squid/snmplib/snmp_api.c:1.17.2.2 *** squid/snmplib/snmp_api.c:1.17.2.1 Tue Feb 12 18:43:43 2002 --- squid/snmplib/snmp_api.c Wed May 4 12:03:47 2005 *************** *** 149,153 **** --- 149,156 ---- strncpy((char *) bufp, (char *) Community, CommunityLen); bufp[CommunityLen] = '0円'; + session->community = bufp; + session->community_len = CommunityLen; + return (bufp); } Index: squid/src/snmp_core.c diff -c squid/src/snmp_core.c:1.51.2.4 squid/src/snmp_core.c:1.51.2.5 *** squid/src/snmp_core.c:1.51.2.4 Mon Mar 7 06:31:35 2005 --- squid/src/snmp_core.c Wed May 4 12:03:47 2005 *************** *** 496,502 **** snmpDecodePacket(snmp_request_t * rq) { struct snmp_pdu *PDU; - struct snmp_session Session; aclCheck_t checklist; u_char *Community; u_char *buf = rq->buf; --- 496,501 ---- *************** *** 506,513 **** debug(49, 5) ("snmpDecodePacket: Called.\n"); /* Now that we have the data, turn it into a PDU */ PDU = snmp_pdu_create(0); ! Session.Version = SNMP_VERSION_1; ! Community = snmp_parse(&Session, PDU, buf, len); memset(&checklist, '0円', sizeof(checklist)); checklist.src_addr = rq->from.sin_addr; checklist.snmp_community = (char *) Community; --- 505,512 ---- debug(49, 5) ("snmpDecodePacket: Called.\n"); /* Now that we have the data, turn it into a PDU */ PDU = snmp_pdu_create(0); ! rq->session.Version = SNMP_VERSION_1; ! Community = snmp_parse(&rq->session, PDU, buf, len); memset(&checklist, '0円', sizeof(checklist)); checklist.src_addr = rq->from.sin_addr; checklist.snmp_community = (char *) Community; *************** *** 534,550 **** static void snmpConstructReponse(snmp_request_t * rq) { - struct snmp_session Session; struct snmp_pdu *RespPDU; debug(49, 5) ("snmpConstructReponse: Called.\n"); RespPDU = snmpAgentResponse(rq->PDU); snmp_free_pdu(rq->PDU); if (RespPDU != NULL) { ! Session.Version = SNMP_VERSION_1; ! Session.community = rq->community; ! Session.community_len = strlen((char *) rq->community); ! snmp_build(&Session, RespPDU, rq->outbuf, &rq->outlen); sendto(rq->sock, rq->outbuf, rq->outlen, 0, (struct sockaddr *) &rq->from, sizeof(rq->from)); snmp_free_pdu(RespPDU); } --- 533,545 ---- static void snmpConstructReponse(snmp_request_t * rq) { struct snmp_pdu *RespPDU; debug(49, 5) ("snmpConstructReponse: Called.\n"); RespPDU = snmpAgentResponse(rq->PDU); snmp_free_pdu(rq->PDU); if (RespPDU != NULL) { ! snmp_build(&rq->session, RespPDU, rq->outbuf, &rq->outlen); sendto(rq->sock, rq->outbuf, rq->outlen, 0, (struct sockaddr *) &rq->from, sizeof(rq->from)); snmp_free_pdu(RespPDU); } *************** *** 558,602 **** snmpAgentResponse(struct snmp_pdu *PDU) { struct snmp_pdu *Answer = NULL; - oid_ParseFn *ParseFn = NULL; - - variable_list *VarPtr, *VarNew = NULL, **VarPtrP; - int index = 0; debug(49, 5) ("snmpAgentResponse: Called.\n"); if ((Answer = snmp_pdu_create(SNMP_PDU_RESPONSE))) { Answer->reqid = PDU->reqid; Answer->errindex = 0; ! if (PDU->command == SNMP_PDU_GET) { ! variable_list **RespVars; ! ! RespVars = &(Answer->variables); /* Loop through all variables */ ! for (VarPtrP = &(PDU->variables); ! *VarPtrP; ! VarPtrP = &((*VarPtrP)->next_variable)) { ! VarPtr = *VarPtrP; index++; /* Find the parsing function for this variable */ ! ParseFn = snmpTreeGet(VarPtr->name, VarPtr->name_length); ! if (ParseFn == NULL) { Answer->errstat = SNMP_ERR_NOSUCHNAME; debug(49, 5) ("snmpAgentResponse: No such oid.\n"); ! } else VarNew = (*ParseFn) (VarPtr, (snint *) & (Answer->errstat)); /* Was there an error? */ ! if ((Answer->errstat != SNMP_ERR_NOERROR) || ! (VarNew == NULL)) { Answer->errindex = index; ! debug(49, 5) ("snmpAgentParse: successful.\n"); ! /* Just copy the rest of the variables. Quickly. */ ! *RespVars = VarPtr; ! *VarPtrP = NULL; return (Answer); } /* No error. Insert this var at the end, and move on to the next. --- 553,611 ---- snmpAgentResponse(struct snmp_pdu *PDU) { struct snmp_pdu *Answer = NULL; debug(49, 5) ("snmpAgentResponse: Called.\n"); if ((Answer = snmp_pdu_create(SNMP_PDU_RESPONSE))) { Answer->reqid = PDU->reqid; Answer->errindex = 0; ! if (PDU->command == SNMP_PDU_GET || PDU->command == SNMP_PDU_GETNEXT) { ! int get_next = (PDU->command == SNMP_PDU_GETNEXT); ! variable_list *VarPtr_; ! variable_list **RespVars = &(Answer->variables); ! oid_ParseFn *ParseFn; ! int index = 0; /* Loop through all variables */ ! for (VarPtr_ = PDU->variables; VarPtr_; VarPtr_ = VarPtr_->next_variable) { ! variable_list *VarPtr = VarPtr_; ! variable_list *VarNew = NULL; ! oid *NextOidName = NULL; ! snint NextOidNameLen = 0; index++; /* Find the parsing function for this variable */ ! if (get_next) ! ParseFn = snmpTreeNext(VarPtr->name, VarPtr->name_length, &NextOidName, &NextOidNameLen); ! else ! ParseFn = snmpTreeGet(VarPtr->name, VarPtr->name_length); if (ParseFn == NULL) { Answer->errstat = SNMP_ERR_NOSUCHNAME; debug(49, 5) ("snmpAgentResponse: No such oid.\n"); ! } else { ! if (get_next) { ! VarPtr = snmp_var_new(NextOidName, NextOidNameLen); ! xfree(NextOidName); ! } VarNew = (*ParseFn) (VarPtr, (snint *) & (Answer->errstat)); + if (get_next) + snmp_var_free(VarPtr); + } /* Was there an error? */ ! if ((Answer->errstat != SNMP_ERR_NOERROR) || (VarNew == NULL)) { Answer->errindex = index; ! debug(49, 5) ("snmpAgentResponse: error.\n"); ! if (VarNew) ! snmp_var_free(VarNew); ! /* Free the already processed results, if any */ ! while ((VarPtr = Answer->variables) != NULL) { ! Answer->variables = VarPtr->next_variable; ! snmp_var_free(VarPtr); ! } ! /* Steal the original PDU list of variables for the error response */ ! Answer->variables = PDU->variables; ! PDU->variables = NULL; return (Answer); } /* No error. Insert this var at the end, and move on to the next. *************** *** 604,640 **** *RespVars = VarNew; RespVars = &(VarNew->next_variable); } - return (Answer); - } else if (PDU->command == SNMP_PDU_GETNEXT) { - oid *NextOidName = NULL; - snint NextOidNameLen = 0; - - ParseFn = snmpTreeNext(PDU->variables->name, PDU->variables->name_length, - &NextOidName, &NextOidNameLen); - - if (ParseFn == NULL) { - Answer->errstat = SNMP_ERR_NOSUCHNAME; - debug(49, 5) ("snmpAgentResponse: No such oid:\n"); - snmpDebugOid(5, PDU->variables->name, PDU->variables->name_length); - } else { - xfree(PDU->variables->name); - PDU->variables->name = NextOidName; - PDU->variables->name_length = NextOidNameLen; - VarNew = (*ParseFn) (PDU->variables, (snint *) & Answer->errstat); - } - - /* Was there an error? */ - if (Answer->errstat != SNMP_ERR_NOERROR) { - Answer->errindex = 1; - Answer->variables = PDU->variables; - PDU->variables = NULL; - } else { - Answer->variables = VarNew; - } - - } else { - snmp_free_pdu(Answer); - Answer = NULL; } } return (Answer); --- 613,618 ---- Index: squid/src/structs.h diff -c squid/src/structs.h:1.408.2.42 squid/src/structs.h:1.408.2.43 *** squid/src/structs.h:1.408.2.42 Fri Apr 22 14:18:43 2005 --- squid/src/structs.h Wed May 4 12:03:47 2005 *************** *** 249,254 **** --- 249,255 ---- struct snmp_pdu *PDU; aclCheck_t *acl_checklist; u_char *community; + struct snmp_session session; }; #endif

AltStyle によって変換されたページ (->オリジナル) /