anchor.diff:  opcode_to_frame_type(9) -> ping;
   opcode_to_frame_type(10) -> pong.
   
  -frag_state(Type, 0, undefined) -> {nofin, Type};
  -frag_state(fragment, 0, FragState = {nofin, _}) -> FragState;
  -frag_state(fragment, 1, {nofin, Type}) -> {fin, Type};
  -frag_state(_, 1, FragState) -> FragState.
  -
  -%% @doc Parse and validate the close frame's close code.
  -%%
  -%% The close code is part of the payload and must therefore be unmasked.
  -
  --spec parse_close_code(binary(), mask_key()) -> {ok, close_code(), binary()} | error.
  -parse_close_code(<< MaskedCode:2/binary, Rest/bits >>, MaskKey) ->
  -	<< Code:16 >> = unmask(MaskedCode, MaskKey, 0),
  -	if
  -		Code < 1000; Code =:= 1004; Code =:= 1005; Code =:= 1006;
  -				(Code > 1011) and (Code < 3000); Code > 4999 ->
  -			error;
  -		true ->
  -			{ok, Code, Rest}
  -	end.
  +frag_state(Type, 0, Rsv, undefined) -> {nofin, Type, Rsv};
  +frag_state(fragment, 0, _, FragState = {nofin, _, _}) -> FragState;
  +frag_state(fragment, 1, _, {nofin, Type, Rsv}) -> {fin, Type, Rsv};
  +frag_state(_, 1, _, FragState) -> FragState.
   
   %% @doc Parse and validate the frame's payload.
   %%
  
positive.code: %% A frame MUST NOT use the zero opcode unless fragmentation was initiated.
  parse_header(<< _:4, 0:4, _/bits >>, _, undefined) -> error;
  %% Non-control opcode when expecting control message or next fragment.
  parse_header(<< _:4, 1:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 2:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 3:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 4:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 5:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 6:4, _/bits >>, _, {_, _}) -> error;
  parse_header(<< _:4, 7:4, _/bits >>, _, {_, _}) -> error;
  %% Close control frame length MUST be 0 or >= 2.
  parse_header(<< _:4, 8:4, _:1, 1:7, _/bits >>, _, _) -> error;
  %% Close control frame with incomplete close code. Need more data.
  
negative.code: 		_ ->
  			<< Data2:Len/binary, Rest/bits >> = Data,
  			{Data2, Rest, true}
  	end.
  
  validate_close_code(Code) ->
  	if
  		Code < 1000 -> error;
  		Code =:= 1004 -> error;
  		Code =:= 1005 -> error;
  		Code =:= 1006 -> error;
  		Code > 1011, Code < 3000 -> error;
  		Code > 4999 -> error;
  		true -> ok
  	end.
  
  unmask(Data, MaskKey, 0) ->
  