add: case ',': switch(state){ case FIN_HIDDEN: *tmp=0; param->type=state; param->name.len=tmp-param->name.s; state=F_VIA; goto endofvalue; case FIN_BRANCH: case FIN_MADDR: case FIN_TTL: case FIN_RECEIVED: LOG(L_ERR, "ERROR: parse_via_param: new via found" "(',') when '=' expected (state %d=)\n", state); goto error;  case F_CR: case F_LF: case F_CRLF: state=END_OF_HEADER; goto end_via; case GEN_PARAM: default: *tmp=0; param->type=GEN_PARAM; param->name.len=tmp-param->name.s; state=F_VIA; goto endofvalue; } break;
context: char* parse_via_param(	char* p, char* end, int* pstate, 								int* psaved_state, struct via_param* param){	char* tmp;	register int state;	int saved_state;	state=*pstate;	saved_state=*psaved_state;	param->type=PARAM_ERROR;	for (tmp=p;tmp<end;tmp++){		switch(*tmp){			case ' ':			case '\t':				switch(state){					case FIN_HIDDEN:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						state=L_PARAM;						goto endofparam;					case FIN_BRANCH:					case FIN_TTL:					case FIN_MADDR:					case FIN_RECEIVED:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						state=L_VALUE;						goto find_value;					case F_PARAM:						break;					case F_LF:					case F_CR:					case F_CRLF:						state=saved_state;						break;					case GEN_PARAM:					default:						*tmp=0;						param->type=GEN_PARAM;						param->name.len=tmp-param->name.s;						state=L_VALUE;						goto find_value;				}				break;			/* \n and \r*/			case '\n':				switch(state){					case FIN_HIDDEN:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						saved_state=L_PARAM;						state=F_LF;						goto endofparam;					case FIN_BRANCH:					case FIN_TTL:					case FIN_MADDR:					case FIN_RECEIVED:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						saved_state=L_VALUE;						state=F_LF;						goto find_value;					case F_PARAM:						saved_state=state;						state=F_LF;						break;					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					case F_CR:						state=F_CRLF;						break;					case GEN_PARAM:					default:						*tmp=0;						param->type=GEN_PARAM;						saved_state=L_VALUE;						param->name.len=tmp-param->name.s;						state=F_LF;						goto find_value;				}				break;			case '\r':				switch(state){					case FIN_HIDDEN:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						saved_state=L_PARAM;						state=F_CR;						goto endofparam;					case FIN_BRANCH:					case FIN_TTL:					case FIN_MADDR:					case FIN_RECEIVED:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						saved_state=L_VALUE;						state=F_CR;						goto find_value;					case F_PARAM:						saved_state=state;						state=F_CR;						break;					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					case GEN_PARAM:					default:						*tmp=0;						param->type=GEN_PARAM;						param->name.len=tmp-param->name.s;						saved_state=L_VALUE;						state=F_CR;						goto find_value;				}				break;			case '=':				switch(state){					case FIN_BRANCH:					case FIN_TTL:					case FIN_MADDR:					case FIN_RECEIVED:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						state=F_VALUE;						goto find_value;					case F_PARAM:					case FIN_HIDDEN:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"								" state %d\n", *tmp, state);						goto error;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					case GEN_PARAM:					default:						*tmp=0;						param->type=GEN_PARAM;						param->name.len=tmp-param->name.s;						state=F_VALUE;						goto find_value;				}				break;			case ';':				switch(state){					case FIN_HIDDEN:						*tmp=0;						param->type=state;						param->name.len=tmp-param->name.s;						state=F_PARAM;						goto endofparam;					case FIN_BRANCH:					case FIN_MADDR:					case FIN_TTL:					case FIN_RECEIVED:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"								" state %d\n", *tmp, state);						goto error;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					case GEN_PARAM:					default:						*tmp=0;						param->type=GEN_PARAM;						param->name.len=tmp-param->name.s;						state=F_PARAM;						goto endofparam;				}				break;				/* param names */			case 'h':			case 'H':				switch(state){					case F_PARAM:						state=HIDDEN1;						param->name.s=tmp;						break;					case BRANCH5:						state=FIN_BRANCH;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'i':			case 'I':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case HIDDEN1:						state=HIDDEN2;						break;					case RECEIVED4:						state=RECEIVED5;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'd':			case 'D':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case HIDDEN2:						state=HIDDEN3;						break;					case HIDDEN3:						state=HIDDEN4;						break;					case MADDR2:						state=MADDR3;						break;					case MADDR3:						state=MADDR4;						break;					case RECEIVED7:						state=FIN_RECEIVED;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'e':			case 'E':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case HIDDEN4:						state=HIDDEN5;						break;					case RECEIVED1:						state=RECEIVED2;						break;					case RECEIVED3:						state=RECEIVED4;						break;					case RECEIVED6:						state=RECEIVED7;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'n':			case 'N':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case HIDDEN5:						state=FIN_HIDDEN;						break;					case BRANCH3:						state=BRANCH4;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 't':			case 'T':				switch(state){					case F_PARAM:						state=TTL1;						param->name.s=tmp;						break;					case TTL1:						state=TTL2;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'l':			case 'L':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case TTL2:						state=FIN_TTL;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'm':			case 'M':				switch(state){					case F_PARAM:						state=MADDR1;						param->name.s=tmp;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'a':			case 'A':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case MADDR1:						state=MADDR2;						break;					case BRANCH2:						state=BRANCH3;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'r':			case 'R':				switch(state){					case MADDR4:						state=FIN_MADDR;						break;					case F_PARAM:						state=RECEIVED1;						param->name.s=tmp;						break;					case BRANCH1:						state=BRANCH2;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'c':			case 'C':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case RECEIVED2:						state=RECEIVED3;						break;					case BRANCH4:						state=BRANCH5;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'v':			case 'V':				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case RECEIVED5:						state=RECEIVED6;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			case 'b':			case 'B':				switch(state){					case F_PARAM:						state=BRANCH1;						param->name.s=tmp;						break;					case GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}				break;			default:				switch(state){					case F_PARAM:						state=GEN_PARAM;						param->name.s=tmp;						break;					case  GEN_PARAM:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						state=GEN_PARAM;				}		}	}/* for tmp*//* end of packet? => error, no cr/lf,',' found!!!*/saved_state=state;state=END_OF_HEADER;goto error;find_value:	tmp++;	for(;*tmp;tmp++){		switch(*tmp){			case ' ':			case '\t':				switch(state){					case L_VALUE:					case F_VALUE: /*eat space*/						break; 					case P_VALUE:						*tmp=0;						state=L_PARAM;						param->value.len=tmp-param->value.s;						goto endofvalue;					case P_STRING:						break;					case F_CR:					case F_LF:					case F_CRLF:						state=saved_state;						break;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			case '\n':				switch(state){					case L_VALUE:					case F_VALUE: /*eat space*/					case P_STRING:						saved_state=state;						state=F_LF;						break;					case P_VALUE:						*tmp=0;						saved_state=L_PARAM;						state=F_LF;						param->value.len=tmp-param->value.s;						goto endofvalue;					case F_LF:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					case F_CR:						state=F_CRLF;						break;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			case '\r':				switch(state){					case L_VALUE:					case F_VALUE: /*eat space*/					case P_STRING:						saved_state=state;						state=F_CR;						break;					case P_VALUE:						*tmp=0;						param->value.len=tmp-param->value.s;						saved_state=L_PARAM;						state=F_CR;						goto endofvalue;					case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			case '=':				switch(state){					case L_VALUE:						state=F_VALUE;						break;					case P_STRING:						break;					case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			case ';':				switch(state){					case P_VALUE:						*tmp=0;						param->value.len=tmp-param->value.s;						state=F_PARAM;						goto endofvalue;					case P_STRING:						break; /* what to do? */					case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			case ',':				switch(state){					case P_VALUE:						*tmp=0;						param->value.len=tmp-param->value.s;						state=F_VIA;						goto endofvalue;					case P_STRING:						case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break; /* what to do? */			case '"':				switch(state){					case F_VALUE:						state=P_STRING;						param->value.s=tmp+1;						break;					case P_STRING:						*tmp=0;						state=L_PARAM;						param->value.len=tmp-param->value.s;						goto endofvalue;					case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}				break;			default:				switch(state){					case F_VALUE:						state=P_VALUE;						param->value.s=tmp;						break;					case P_VALUE:					case P_STRING:						break;					case F_LF:					case F_CR:					case F_CRLF:						state=END_OF_HEADER;						goto end_via;					default:						LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"								" in state %d\n", *tmp, state);						goto error;				}		}	} /* for2 tmp*/	/* end of buff and no CR/LF =>error*/saved_state=state;state=END_OF_HEADER;goto error;endofparam:endofvalue:	param->size=tmp-p;	*pstate=state;	*psaved_state=saved_state;	DBG("Found param type %d, <%s> = <%s>; state=%d\n", param->type,			param->name.s, param->value.s, state);	return tmp;end_via:	/* if we are here we found an "unexpected" end of via	 *  (cr/lf). This is valid only if the param type is GEN_PARAM*/	if (param->type==GEN_PARAM) goto endofparam;	*pstate=state;	*psaved_state=saved_state;	DBG("Error on  param type %d, <%s>, state=%d, saved_state=%d\n",		param->type, param->name.s, state, saved_state);error:	LOG(L_ERR, "error: parse_via_param\n");	param->type=PARAM_ERROR;	*pstate=PARAM_ERROR;	*psaved_state=state;	return tmp;}