rem: DBG("parse_headers: Via2 found, flags=%d\n", flags);
add: DBG("parse_headers: this is the second via\n");
context: int parse_headers(struct sip_msg* msg, int flags){	struct hdr_field* hf;	char* tmp;	char* rest;	char* end;	end=msg->buf+msg->len;	tmp=msg->unparsed;	DBG("parse_headers: flags=%d\n", flags);	while( tmp<end && (flags & msg->parsed_flag) != flags){		hf=pkg_malloc(sizeof(struct hdr_field));		if (hf==0){			LOG(L_ERR, "ERROR:parse_headers: memory allocation error\n");			goto error;		}		memset(hf,0, sizeof(struct hdr_field));		hf->type=HDR_ERROR;		rest=get_hdr_field(tmp, msg->buf+msg->len, hf);		switch (hf->type){			case HDR_ERROR:				LOG(L_INFO,"ERROR: bad header  field\n");				goto  error;			case HDR_EOH:				msg->eoh=tmp; /* or rest?*/				msg->parsed_flag|=HDR_EOH;				pkg_free(hf);				goto skip;			case HDR_OTHER: /*do nothing*/				break;			case HDR_CALLID:				if (msg->callid==0) msg->callid=hf;				msg->parsed_flag|=HDR_CALLID;				break;			case HDR_TO:				if (msg->to==0) msg->to=hf;				msg->parsed_flag|=HDR_TO;				break;			case HDR_CSEQ:				if (msg->cseq==0) msg->cseq=hf;				msg->parsed_flag|=HDR_CSEQ;				break;			case HDR_FROM:				if (msg->from==0) msg->from=hf;				msg->parsed_flag|=HDR_FROM;				break;			case HDR_CONTACT:				if (msg->contact==0) msg->contact=hf;				msg->parsed_flag|=HDR_CONTACT;				break;			case HDR_MAXFORWARDS:				if(msg->maxforwards==0) msg->maxforwards=hf;				msg->parsed_flag|=HDR_MAXFORWARDS;				break;			case HDR_ROUTE:				if (msg->route==0) msg->route=hf;				msg->parsed_flag|=HDR_ROUTE;				break;		        case HDR_RECORDROUTE:				if (msg->record_route==0) msg->record_route = hf;				msg->parsed_flag|=HDR_RECORDROUTE;				break;		        case HDR_VIA:				msg->parsed_flag|=HDR_VIA;				DBG("parse_headers: Via1 found, flags=%d\n", flags);				if (msg->via1==0) {					msg->h_via1=hf;					msg->via1=hf->parsed;					if (msg->via1->next){						msg->via2=msg->via1->next;						msg->parsed_flag|=HDR_VIA2;					}				}else if (msg->via2==0){					msg->h_via2=hf;					msg->via2=hf->parsed;					msg->parsed_flag|=HDR_VIA2;				DBG("parse_headers: Via2 found, flags=%d\n", flags);				}				break;			default:				LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",							hf->type);				goto error;		}		/* add the header to the list*/		if (msg->last_header==0){			msg->headers=hf;			msg->last_header=hf;		}else{			msg->last_header->next=hf;			msg->last_header=hf;		}	#ifdef EXTRA_DEBUG		DBG("header field type %d, name=<%s>, body=<%s>\n",			hf->type, hf->name.s, hf->body.s);	#endif		tmp=rest;	}skip:	msg->unparsed=tmp;	return 0;error:	if (hf) pkg_free(hf);	return -1;}