rem: memcpy( ptr, table->ce_avp_ipv4.s, AVP_HDR_SIZE + 4);
add: memcpy( ptr, table->ce_avp_ipv4.s, AVP_HDR_SIZE ); ((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 16 );
context: int build_msg_buffers(struct p_table *table){	int  nr_auth_app;	int  nr_acc_app;	char *ptr;	int  i;	/* standard request */	table->std_req.len = AAA_MSG_HDR_SIZE +            /* header */		AVP_HDR_SIZE + to_32x_len(aaa_identity.len) +  /* origin-host  */		AVP_HDR_SIZE + to_32x_len(aaa_realm.len);      /* origin-realm */	table->std_req.s = shm_malloc( table->std_req.len );	if (!table->std_req.s)		goto error;	ptr = table->std_req.s;	memset( ptr, 0, table->std_req.len);	/* diameter header */	ptr[0] = 0x01;	ptr[4] = 0x80;	ptr += AAA_MSG_HDR_SIZE;	/* origin host AVP */	((unsigned int*)ptr)[0] = htonl(264);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + aaa_identity.len );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE;	memcpy( ptr, aaa_identity.s, aaa_identity.len);	ptr += to_32x_len(aaa_identity.len);	/* origin realm AVP */	((unsigned int*)ptr)[0] = htonl(296);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + aaa_realm.len );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE;	memcpy( ptr, aaa_realm.s, aaa_realm.len);	ptr += to_32x_len(aaa_realm.len);	/* standard answer */	table->std_ans.len = AAA_MSG_HDR_SIZE +            /* header */		AVP_HDR_SIZE + 4 +                             /* result-code  */		AVP_HDR_SIZE + to_32x_len(aaa_identity.len) +  /* origin-host  */		AVP_HDR_SIZE + to_32x_len(aaa_realm.len);      /* origin-realm */	table->std_ans.s = shm_malloc( table->std_ans.len );	if (!table->std_ans.s)		goto error;	ptr = table->std_ans.s;	memset( ptr, 0, table->std_ans.len);	/* diameter header */	ptr[0] = 0x01;	ptr[4] = 0x00;	ptr += AAA_MSG_HDR_SIZE;	/* result code AVP */	((unsigned int*)ptr)[0] = htonl(268);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE + 4;	/* origin host AVP */	((unsigned int*)ptr)[0] = htonl(264);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + aaa_identity.len );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE;	memcpy( ptr, aaa_identity.s, aaa_identity.len);	ptr += to_32x_len(aaa_identity.len);	/* origin realm AVP */	((unsigned int*)ptr)[0] = htonl(296);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + aaa_realm.len );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE;	memcpy( ptr, aaa_realm.s, aaa_realm.len);	ptr += to_32x_len(aaa_realm.len);	/* CE avps IPv4 */	nr_auth_app = nr_acc_app = 0;	for(i=0;i<AAA_APP_MAX_ID;i++) {		if ((1<<i)&supported_auth_app_id)			nr_auth_app++;		if ((1<<i)&supported_acc_app_id)			nr_acc_app++;	}	/* build the avps */	table->ce_avp_ipv4.len =		AVP_HDR_SIZE + 4 +                             /* host-ip-address  */		AVP_HDR_SIZE + 4 +                             /* vendor-id  */		AVP_HDR_SIZE + to_32x_len(product_name.len) +  /* product-name */		nr_auth_app*(AVP_HDR_SIZE + 4) +               /* auth-app-id */		nr_acc_app*(AVP_HDR_SIZE + 4);                 /* acc-app-id */	table->ce_avp_ipv4.s = shm_malloc( table->ce_avp_ipv4.len );	if (!table->ce_avp_ipv4.s)		goto error;	ptr = table->ce_avp_ipv4.s;	memset( ptr, 0, table->ce_avp_ipv4.len);	/* host-ip-address AVP */	((unsigned int*)ptr)[0] = htonl(257);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE + 4;	/* vendor-id AVP */	((unsigned int*)ptr)[0] = htonl(266);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE;	((unsigned int*)ptr)[0] = htonl( vendor_id );	ptr += 4;	/* product-name AVP */	((unsigned int*)ptr)[0] = htonl(269);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + product_name.len );	ptr += AVP_HDR_SIZE;	memcpy( ptr, product_name.s, product_name.len);	ptr += to_32x_len(product_name.len);	/* auth-app-id AVP */	for(i=0;i<AAA_APP_MAX_ID;i++)		if ((1<<i)&supported_auth_app_id) {			((unsigned int*)ptr)[0] = htonl(258);			((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );			ptr[4] = 1<<6;			ptr += AVP_HDR_SIZE;			((unsigned int*)ptr)[0] = htonl( AAA_APP_ID[i] );			ptr += 4;		}	/* acc-app-id AVP */	for(i=0;i<AAA_APP_MAX_ID;i++)		if ((1<<i)&supported_acc_app_id) {			((unsigned int*)ptr)[0] = htonl(259);			((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );			ptr[4] = 1<<6;			ptr += AVP_HDR_SIZE;			((unsigned int*)ptr)[0] = htonl( AAA_APP_ID[i] );			ptr += 4;		}	/* CE avps IPv6 */	table->ce_avp_ipv6.len = table->ce_avp_ipv4.len + 12;	table->ce_avp_ipv6.s = shm_malloc( table->ce_avp_ipv6.len );	if (!table->ce_avp_ipv6.s)		goto error;	ptr = table->ce_avp_ipv6.s;	memset( ptr, 0, table->ce_avp_ipv6.len);	/* copy */	memcpy( ptr, table->ce_avp_ipv4.s, AVP_HDR_SIZE + 4);	ptr += AVP_HDR_SIZE + 16;	memcpy( ptr, table->ce_avp_ipv4.s+AVP_HDR_SIZE+4,		table->ce_avp_ipv4.len-AVP_HDR_SIZE-4);	/* DPR avp */	table->dpr_avp.len = AVP_HDR_SIZE + 4; /* disconnect cause  */	table->dpr_avp.s = shm_malloc( table->dpr_avp.len );	if (!table->dpr_avp.s)		goto error;	ptr = table->dpr_avp.s;	memset( ptr, 0, table->dpr_avp.len);	/* disconnect cause AVP */	((unsigned int*)ptr)[0] = htonl(273);	((unsigned int*)ptr)[1] = htonl( AVP_HDR_SIZE + 4 );	ptr[4] = 1<<6;	ptr += AVP_HDR_SIZE + 4;	return 1;error:	LOG(L_ERR,"ERROR:build_msg_buffers: no more free memory\n");	return -1;}