GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/ospfctl/../ospfd/logmsg.c Lines: 0 42 0.0 %
Date: 2017-11-13 Branches: 0 36 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: logmsg.c,v 1.1 2016/09/02 14:04:25 benno Exp $ */
2
3
/*
4
 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <errno.h>
20
#include <stdarg.h>
21
#include <stdio.h>
22
#include <stdlib.h>
23
#include <string.h>
24
#include <syslog.h>
25
#include <unistd.h>
26
27
#include "ospfd.h"
28
#include "log.h"
29
30
/* names */
31
const char *
32
nbr_state_name(int state)
33
{
34
	switch (state) {
35
	case NBR_STA_DOWN:
36
		return ("DOWN");
37
	case NBR_STA_ATTEMPT:
38
		return ("ATTMP");
39
	case NBR_STA_INIT:
40
		return ("INIT");
41
	case NBR_STA_2_WAY:
42
		return ("2-WAY");
43
	case NBR_STA_XSTRT:
44
		return ("EXSTA");
45
	case NBR_STA_SNAP:
46
		return ("SNAP");
47
	case NBR_STA_XCHNG:
48
		return ("EXCHG");
49
	case NBR_STA_LOAD:
50
		return ("LOAD");
51
	case NBR_STA_FULL:
52
		return ("FULL");
53
	default:
54
		return ("UNKNW");
55
	}
56
}
57
58
const char *
59
if_state_name(int state)
60
{
61
	switch (state) {
62
	case IF_STA_DOWN:
63
		return ("DOWN");
64
	case IF_STA_LOOPBACK:
65
		return ("LOOP");
66
	case IF_STA_WAITING:
67
		return ("WAIT");
68
	case IF_STA_POINTTOPOINT:
69
		return ("P2P");
70
	case IF_STA_DROTHER:
71
		return ("OTHER");
72
	case IF_STA_BACKUP:
73
		return ("BCKUP");
74
	case IF_STA_DR:
75
		return ("DR");
76
	default:
77
		return ("UNKNW");
78
	}
79
}
80
81
const char *
82
if_type_name(enum iface_type type)
83
{
84
	switch (type) {
85
	case IF_TYPE_POINTOPOINT:
86
		return ("POINTOPOINT");
87
	case IF_TYPE_BROADCAST:
88
		return ("BROADCAST");
89
	case IF_TYPE_NBMA:
90
		return ("NBMA");
91
	case IF_TYPE_POINTOMULTIPOINT:
92
		return ("POINTOMULTIPOINT");
93
	case IF_TYPE_VIRTUALLINK:
94
		return ("VIRTUALLINK");
95
	}
96
	/* NOTREACHED */
97
	return ("UNKNOWN");
98
}
99
100
const char *
101
if_auth_name(enum auth_type type)
102
{
103
	switch (type) {
104
	case AUTH_NONE:
105
		return ("none");
106
	case AUTH_SIMPLE:
107
		return ("simple");
108
	case AUTH_CRYPT:
109
		return ("crypt");
110
	}
111
	/* NOTREACHED */
112
	return ("unknown");
113
}
114
115
const char *
116
dst_type_name(enum dst_type type)
117
{
118
	switch (type) {
119
	case DT_NET:
120
		return ("Network");
121
	case DT_RTR:
122
		return ("Router");
123
	}
124
	/* NOTREACHED */
125
	return ("unknown");
126
}
127
128
const char *
129
path_type_name(enum path_type type)
130
{
131
	switch (type) {
132
	case PT_INTRA_AREA:
133
		return ("Intra-Area");
134
	case PT_INTER_AREA:
135
		return ("Inter-Area");
136
	case PT_TYPE1_EXT:
137
		return ("Type 1 ext");
138
	case PT_TYPE2_EXT:
139
		return ("Type 2 ext");
140
	}
141
	/* NOTREACHED */
142
	return ("unknown");
143
}