1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
#pike 7.8 
#pragma strict_types 
 
//! Alert packet. 
 
import .Constants; 
 
//! Based on the base @[packet]. 
inherit .packet : packet; 
 
int level; 
int description; 
 
string message; 
mixed trace; 
 
constant is_alert = 1; 
 
//! @decl void create(int level, int description,@ 
//!                   int version, string|void message, mixed|void trace) 
void create(int l, int d, int version, string|void m, mixed|void t) 
{ 
  if (!version && (d == ALERT_no_renegotiation)) { 
    // RFC 5746 4.5: 
    // SSLv3 does not define the "no_renegotiation" alert (and does not 
    // offer a way to indicate a refusal to renegotiate at a "warning" 
    // level). SSLv3 clients that refuse renegotiation SHOULD use a 
    // fatal handshake_failure alert. 
    d = ALERT_handshake_failure; 
    l = ALERT_fatal; 
  } 
 
  if (! ALERT_levels[l]) 
    error( "Invalid level\n" ); 
  if (! ALERT_descriptions[d]) 
    error( "Invalid description\n" ); 
 
  level = l; 
  description = d; 
  message = m; 
  trace = t; 
 
#ifdef SSL3_DEBUG 
  if(m) 
    werror(m); 
  if(t) 
    werror(describe_backtrace(t)); 
#endif 
 
  packet::create(); 
  packet::content_type = PACKET_alert; 
  packet::protocol_version = ({ PROTOCOL_major, version }); 
  packet::fragment = sprintf("%c%c", level, description); 
}