src/ssl_sock.c
static int bind_parse_npn(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
#ifdef OPENSSL_NPN_NEGOTIATED
	char *p1, *p2;

	if (!*args[cur_arg + 1]) {
		memprintf(err, "'%s' : missing the comma-delimited NPN protocol suite", args[cur_arg]);
		return ERR_ALERT | ERR_FATAL;
	}

	free(conf->npn_str);

	/* the NPN string is built as a suite of (<len> <name>)* */
	conf->npn_len = strlen(args[cur_arg + 1]) + 1;
	conf->npn_str = calloc(1, conf->npn_len);
	memcpy(conf->npn_str + 1, args[cur_arg + 1], conf->npn_len);

	/* replace commas with the name length */
	p1 = conf->npn_str;
	p2 = p1 + 1;
	while (1) {
		p2 = memchr(p1 + 1, ',', conf->npn_str + conf->npn_len - (p1 + 1));
		if (!p2)
			p2 = p1 + 1 + strlen(p1 + 1);

		if (p2 - (p1 + 1) > 255) {
			*p2 = '\0';
			memprintf(err, "'%s' : NPN protocol name too long : '%s'", args[cur_arg], p1 + 1);
			return ERR_ALERT | ERR_FATAL;
		}

		*p1 = p2 - (p1 + 1);
		p1 = p2;

		if (!*p2)
			break;

		*(p2++) = '\0';
	}
	return 0;
#else
	if (err)
		memprintf(err, "'%s' : library does not support TLS NPN extension", args[cur_arg]);
	return ERR_ALERT | ERR_FATAL;
#endif
}
/* parse the "npn" bind keyword */
parse the "npn" bind keyword
parse the " npn " bind keyword
static int bind_parse_npn(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
#ifdef OPENSSL_NPN_NEGOTIATED
	char *p1, *p2;
	if (!*args[cur_arg + 1]) {
		memprintf(err, "'%s' : missing the comma-delimited NPN protocol suite", args[cur_arg]);
		return ERR_ALERT | ERR_FATAL;
	}
	free(conf->npn_str);
	conf->npn_len = strlen(args[cur_arg + 1]) + 1;
	conf->npn_str = calloc(1, conf->npn_len);
	memcpy(conf->npn_str + 1, args[cur_arg + 1], conf->npn_len);
	p1 = conf->npn_str;
	p2 = p1 + 1;
	while (1) {
		p2 = memchr(p1 + 1, ',', conf->npn_str + conf->npn_len - (p1 + 1));
		if (!p2)
			p2 = p1 + 1 + strlen(p1 + 1);
		if (p2 - (p1 + 1) > 255) {
			*p2 = '\0';
			memprintf(err, "'%s' : NPN protocol name too long : '%s'", args[cur_arg], p1 + 1);
			return ERR_ALERT | ERR_FATAL;
		}
		*p1 = p2 - (p1 + 1);
		p1 = p2;
		if (!*p2)
			break;
		*(p2++) = '\0';
	}
	return 0;
#else
	if (err)
		memprintf(err, "'%s' : library does not support TLS NPN extension", args[cur_arg]);
	return ERR_ALERT | ERR_FATAL;
#endif
}
static int bind_parse_npn ( char * * args , int cur_arg , struct proxy * px , struct bind_conf * conf , char * * err ) { #ifdef OPENSSL_NPN_NEGOTIATED char * p1 , * p2 ; if ( ! * args [ cur_arg + 1 ] ) { memprintf ( err , " " , args [ cur_arg ] ) ; return ERR_ALERT | ERR_FATAL ; } free ( conf -> npn_str ) ; conf -> npn_len = strlen ( args [ cur_arg + 1 ] ) + 1 ; conf -> npn_str = calloc ( 1 , conf -> npn_len ) ; memcpy ( conf -> npn_str + 1 , args [ cur_arg + 1 ] , conf -> npn_len ) ; p1 = conf -> npn_str ; p2 = p1 + 1 ; while ( 1 ) { p2 = memchr ( p1 + 1 , ' ' , conf -> npn_str + conf -> npn_len - ( p1 + 1 ) ) ; if ( ! p2 ) p2 = p1 + 1 + strlen ( p1 + 1 ) ; if ( p2 - ( p1 + 1 ) > 255 ) { * p2 = ' \0 ' ; memprintf ( err , " " , args [ cur_arg ] , p1 + 1 ) ; return ERR_ALERT | ERR_FATAL ; } * p1 = p2 - ( p1 + 1 ) ; p1 = p2 ; if ( ! * p2 ) break ; * ( p2 ++ ) = ' \0 ' ; } return 0 ; #else if ( err ) memprintf ( err , " " , args [ cur_arg ] ) ; return ERR_ALERT | ERR_FATAL ; #endif }
parse the "npn" bind keyword
parse the " npn " bind keyword
/* the NPN string is built as a suite of (<len> <name>)* */ /* replace commas with the name length */