rem: for (t=msg->add_rm;t;t=t->next){
add: for (t=lumps;t;t=t->next){
context: static inline void process_lumps(	struct sip_msg* msg,										char* new_buf, 									unsigned int* new_buf_offs, 									unsigned int* orig_offs,									struct socket_info* send_sock){	struct lump *t;	struct lump *r;	char* orig;	int size;	int offset;	int s_offset;	str* send_address_str;	str* send_port_str;#define SUBST_LUMP(subst_l) \	switch((subst_l)->u.subst){ \		case SUBST_RCV_IP: \			if (msg->rcv.bind_address){  \				if (msg->rcv.bind_address->address.af!=AF_INET){\					new_buf[offset]='['; offset++; \				}\				memcpy(new_buf+offset, msg->rcv.bind_address->address_str.s, \						msg->rcv.bind_address->address_str.len); \				offset+=msg->rcv.bind_address->address_str.len; \				if (msg->rcv.bind_address->address.af!=AF_INET){\					new_buf[offset]=']'; offset++; \				}\			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \			}; \			break; \		case SUBST_RCV_PORT: \			if (msg->rcv.bind_address){  \				memcpy(new_buf+offset, msg->rcv.bind_address->port_no_str.s, \						msg->rcv.bind_address->port_no_str.len); \				offset+=msg->rcv.bind_address->port_no_str.len; \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \			}; \			break; \		case SUBST_RCV_ALL: \			if (msg->rcv.bind_address){  \				/* address */ \				if (msg->rcv.bind_address->address.af!=AF_INET){\					new_buf[offset]='['; offset++; \				}\				memcpy(new_buf+offset, msg->rcv.bind_address->address_str.s, \						msg->rcv.bind_address->address_str.len); \				offset+=msg->rcv.bind_address->address_str.len; \				if (msg->rcv.bind_address->address.af!=AF_INET){\					new_buf[offset]=']'; offset++; \				}\				/* :port */ \				if (msg->rcv.bind_address->port_no!=SIP_PORT){ \					new_buf[offset]=':'; offset++; \					memcpy(new_buf+offset, \							msg->rcv.bind_address->port_no_str.s, \							msg->rcv.bind_address->port_no_str.len); \					offset+=msg->rcv.bind_address->port_no_str.len; \				}\				switch(msg->rcv.bind_address->proto){ \					case PROTO_NONE: \					case PROTO_UDP: \						break; /* nothing to do, udp is default*/ \					case PROTO_TCP: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "tcp", 3); \						offset+=3; \						break; \					case PROTO_TLS: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "tls", 3); \						offset+=3; \						break; \					case PROTO_SCTP: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "sctp", 4); \						offset+=4; \						break; \					default: \						LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \								msg->rcv.bind_address->proto); \				} \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \			}; \			break; \		case SUBST_SND_IP: \			if (send_sock){  \				if ((send_sock->address.af!=AF_INET) && \						(send_address_str==&(send_sock->address_str))){\					new_buf[offset]='['; offset++; \				}\				memcpy(new_buf+offset, send_address_str->s, \									send_address_str->len); \				offset+=send_address_str->len; \				if ((send_sock->address.af!=AF_INET) && \						(send_address_str==&(send_sock->address_str))){\					new_buf[offset]=']'; offset++; \				}\			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: called with" \							" null send_sock\n"); \			}; \			break; \		case SUBST_SND_PORT: \			if (send_sock){  \				memcpy(new_buf+offset, send_port_str->s, \									send_port_str->len); \				offset+=send_port_str->len; \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: called with" \						" null send_sock\n"); \			}; \			break; \		case SUBST_SND_ALL: \			if (send_sock){  \				/* address */ \				if ((send_sock->address.af!=AF_INET) && \						(send_address_str==&(send_sock->address_str))){\					new_buf[offset]='['; offset++; \				}\				memcpy(new_buf+offset, send_address_str->s, \						send_address_str->len); \				offset+=send_address_str->len; \				if ((send_sock->address.af!=AF_INET) && \						(send_address_str==&(send_sock->address_str))){\					new_buf[offset]=']'; offset++; \				}\				/* :port */ \				if ((send_sock->port_no!=SIP_PORT) || \					(send_port_str!=&(send_sock->port_no_str))){ \					new_buf[offset]=':'; offset++; \					memcpy(new_buf+offset, send_port_str->s, \							send_port_str->len); \					offset+=send_port_str->len; \				}\				switch(send_sock->proto){ \					case PROTO_NONE: \					case PROTO_UDP: \						break; /* nothing to do, udp is default*/ \					case PROTO_TCP: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "tcp", 3); \						offset+=3; \						break; \					case PROTO_TLS: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "tls", 3); \						offset+=3; \						break; \					case PROTO_SCTP: \						memcpy(new_buf+offset, TRANSPORT_PARAM, \								TRANSPORT_PARAM_LEN); \						offset+=TRANSPORT_PARAM_LEN; \						memcpy(new_buf+offset, "sctp", 4); \						offset+=4; \						break; \					default: \						LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \								send_sock->proto); \				} \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \			}; \			break; \		case SUBST_RCV_PROTO: \			if (msg->rcv.bind_address){ \				switch(msg->rcv.bind_address->proto){ \					case PROTO_NONE: \					case PROTO_UDP: \						memcpy(new_buf+offset, "udp", 3); \						offset+=3; \						break; \					case PROTO_TCP: \						memcpy(new_buf+offset, "tcp", 3); \						offset+=3; \						break; \					case PROTO_TLS: \						memcpy(new_buf+offset, "tls", 3); \						offset+=3; \						break; \					case PROTO_SCTP: \						memcpy(new_buf+offset, "sctp", 4); \						offset+=4; \						break; \					default: \						LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \								msg->rcv.bind_address->proto); \				} \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: called with null" \							" send_sock \n"); \			}; \			break; \		case  SUBST_SND_PROTO: \			if (send_sock){ \				switch(send_sock->proto){ \					case PROTO_NONE: \					case PROTO_UDP: \						memcpy(new_buf+offset, "udp", 3); \						offset+=3; \						break; \					case PROTO_TCP: \						memcpy(new_buf+offset, "tcp", 3); \						offset+=3; \						break; \					case PROTO_TLS: \						memcpy(new_buf+offset, "tls", 3); \						offset+=3; \						break; \					case PROTO_SCTP: \						memcpy(new_buf+offset, "sctp", 4); \						offset+=4; \						break; \					default: \						LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \								send_sock->proto); \				} \			}else{  \				/*FIXME*/ \				LOG(L_CRIT, "FIXME: process_lumps: called with null" \							" send_sock \n"); \			}; \			break; \		default: \					LOG(L_CRIT, "BUG: process_lumps: unknown subst type %d\n", \							(subst_l)->u.subst); \	} \ \		/* init send_address_str & send_port_str */	if (msg->set_global_address.len)		send_address_str=&(msg->set_global_address);	else		send_address_str=&(send_sock->address_str);	if (msg->set_global_port.len)		send_port_str=&(msg->set_global_address);	else		send_port_str=&(send_sock->port_no_str);			orig=msg->buf;	offset=*new_buf_offs;	s_offset=*orig_offs;		for (t=msg->add_rm;t;t=t->next){		switch(t->op){			case LUMP_ADD:			case LUMP_ADD_SUBST:			case LUMP_ADD_OPT:				/* skip if this is an OPT lump and the condition is 				 * not satisfied */				if ((t->op==LUMP_ADD_OPT) &&						(!lump_check_opt(t->u.cond, msg, send_sock))) 					continue;				/* just add it here! */				/* process before  */				for(r=t->before;r;r=r->before){					switch (r->op){						case LUMP_ADD:							/*just add it here*/							memcpy(new_buf+offset, r->u.value, r->len);							offset+=r->len;							break;						case LUMP_ADD_SUBST:							SUBST_LUMP(r);							break;						case LUMP_ADD_OPT:							/* skip if this is an OPT lump and the condition is 					 		* not satisfied */							if (!lump_check_opt(r->u.cond, msg, send_sock))								goto skip_before;							break;						default:							/* only ADD allowed for before/after */							LOG(L_CRIT, "BUG:process_lumps: "									"invalid op for data lump (%x)\n", r->op);					}				}skip_before:				/* copy "main" part */				switch(t->op){					case LUMP_ADD:						memcpy(new_buf+offset, t->u.value, t->len);						offset+=t->len;						break;					case LUMP_ADD_SUBST:						SUBST_LUMP(t);						break;					case LUMP_ADD_OPT:						/* do nothing, it's only a condition */						break;					default: 						/* should not ever get here */						LOG(L_CRIT, "BUG: process_lumps: unhandled data lump "								" op %d\n", t->op);				}				/* process after */				for(r=t->after;r;r=r->after){					switch (r->op){						case LUMP_ADD:							/*just add it here*/							memcpy(new_buf+offset, r->u.value, r->len);							offset+=r->len;							break;						case LUMP_ADD_SUBST:							SUBST_LUMP(r);							break;						case LUMP_ADD_OPT:							/* skip if this is an OPT lump and the condition is 					 		* not satisfied */							if (!lump_check_opt(r->u.cond, msg, send_sock))								goto skip_after;							break;						default:							/* only ADD allowed for before/after */							LOG(L_CRIT, "BUG:process_lumps: "									"invalid op for data lump (%x)\n", r->op);					}				}skip_after:				break;			case LUMP_NOP:			case LUMP_DEL:				/* copy till offset */				if (s_offset>t->u.offset){					DBG("Warning: (%d) overlapped lumps offsets,"						" ignoring(%x, %x)\n", t->op, s_offset,t->u.offset);					/* this should've been fixed above (when computing len) */					/* just ignore it*/					break;				}				size=t->u.offset-s_offset;				if (size){					memcpy(new_buf+offset, orig+s_offset,size);					offset+=size;					s_offset+=size;				}				/* process before  */				for(r=t->before;r;r=r->before){					switch (r->op){						case LUMP_ADD:							/*just add it here*/							memcpy(new_buf+offset, r->u.value, r->len);							offset+=r->len;							break;						case LUMP_ADD_SUBST:							SUBST_LUMP(r);							break;						case LUMP_ADD_OPT:							/* skip if this is an OPT lump and the condition is 					 		* not satisfied */							if (!lump_check_opt(r->u.cond, msg, send_sock))								goto skip_nop_before;							break;						default:							/* only ADD allowed for before/after */							LOG(L_CRIT, "BUG:process_lumps: "									"invalid op for data lump (%x)\n",r->op);					}				}skip_nop_before:				/* process main (del only) */				if (t->op==LUMP_DEL){					/* skip len bytes from orig msg */					s_offset+=t->len;				}				/* process after */				for(r=t->after;r;r=r->after){					switch (r->op){						case LUMP_ADD:							/*just add it here*/							memcpy(new_buf+offset, r->u.value, r->len);							offset+=r->len;							break;						case LUMP_ADD_SUBST:							SUBST_LUMP(r);							break;						case LUMP_ADD_OPT:							/* skip if this is an OPT lump and the condition is 					 		* not satisfied */							if (!lump_check_opt(r->u.cond, msg, send_sock)) 								goto skip_nop_after;							break;						default:							/* only ADD allowed for before/after */							LOG(L_CRIT, "BUG:process_lumps: "									"invalid op for data lump (%x)\n", r->op);					}				}skip_nop_after:				break;			default:					LOG(L_CRIT, "BUG: process_lumps: "							"unknown op (%x)\n", t->op);		}	}	*new_buf_offs=offset;	*orig_offs=s_offset;}