rem: code = AAA_SUCCESS;
add: code = htonl(AAA_SUCCESS);
context: AAAMessage *AAANewMessage(	AAACommandCode commandCode,	AAAApplicationId applicationId,	AAASessionId *sessionId,	AAAMessage *request){	AAAMessage   *msg;	AAA_AVP      *avp;	AAA_AVP      *avp_t;	unsigned int code;	msg = 0;	if (!sessionId) {		LOG(L_ERR,"ERROR:AAANewMessage: param session-ID received null!!\n");		goto error;	}	/* allocated a new AAAMessage structure a set it to 0 */	msg = (AAAMessage*)shm_malloc(sizeof(AAAMessage));	if (!msg) {		LOG(L_ERR,"ERROR:AAANewMessage: no more free memory!!\n");		goto error;	}	memset(msg,0,sizeof(AAAMessage));	/* command code */	msg->commandCode = commandCode;	/* application ID */	msg->applicationId = applicationId;	/* add session ID */	avp = AAACreateAVP( 263, 0, 0, sessionId->s, sessionId->len,		AVP_DONT_FREE_DATA);	if ( !avp || AAAAddAVPToMessage(msg,avp,0)!=AAA_ERR_SUCCESS) {		LOG(L_ERR,"ERROR:AAANewMessage: cannot create/add Session-Id avp\n");		if (avp) AAAFreeAVP( &avp );		goto error;	}	msg->sessionId = avp;	/* add origin host AVP */	avp = AAACreateAVP( 264, 0, 0, aaa_identity.s, aaa_identity.len,		AVP_DONT_FREE_DATA);	if (!avp||AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {		LOG(L_ERR,"ERROR:AAANewMessage: cannot create/add Origin-Host avp\n");		if (avp) AAAFreeAVP( &avp );		goto error;	}	msg->orig_host = avp;	/* add origin realm AVP */	avp = AAACreateAVP( 296, 0, 0, aaa_realm.s, aaa_realm.len,		AVP_DONT_FREE_DATA);	if (!avp||AAAAddAVPToMessage(msg,avp,msg->avpList.tail)!=AAA_ERR_SUCCESS) {		LOG(L_ERR,"ERROR:AAANewMessage: cannot create/add Origin-Realm avp\n");		if (avp) AAAFreeAVP( &avp );		goto error;	}	msg->orig_realm = avp;	if (!request) {		/* it's a new request -> set the flag */		msg->flags = 0x80;		/* keep track of the session -> SendMessage will need it! */		msg->sId = sessionId;	} else {		/* it'a an answer -> it will have the same session Id */		msg->sId = request->sId;		/* link the incoming peer to the answer */		msg->in_peer = request->in_peer;		/* set the P flag as in request */		msg->flags |= request->flags&0x40;		/**/		msg->endtoendId = request->endtoendId;		msg->hopbyhopId = request->hopbyhopId;		/* add a success result-code avp ;-))) */		avp = 0;		code = AAA_SUCCESS;		avp = AAACreateAVP( AVP_Result_Code, 0, 0, (char*)&code, sizeof(code),			AVP_DUPLICATE_DATA);		if (!avp || AAAAddAVPToMessage( msg, avp, msg->sessionId)		!=AAA_ERR_SUCCESS ) {			LOG(L_ERR,"ERROR:AAANewMessage: cannot create/add "				"Result-Code avp\n");			if (avp) AAAFreeAVP( &avp );			goto error;		}		msg->res_code = avp;		/* mirror all the proxy-info avp in the same order */		avp_t = request->avpList.head;		while ( (avp_t=AAAFindMatchingAVP		(request,avp_t,284,0,AAA_FORWARD_SEARCH))!=0 ) {			if ( (avp=AAACloneAVP(avp_t,0))==0 || AAAAddAVPToMessage( msg, avp,			msg->avpList.tail)!=AAA_ERR_SUCCESS )				goto error;		}	}	return msg;error:	LOG(L_ERR,"ERROR:AAANewMessage: failed to create a new AAA message!\n");	AAAFreeMessage(&msg);	return 0;}