media.c revision 1.6 1 1.1 dyoung #include <sys/cdefs.h>
2 1.1 dyoung #ifndef lint
3 1.6 joerg __RCSID("$NetBSD: media.c,v 1.6 2011/08/29 14:35:00 joerg Exp $");
4 1.1 dyoung #endif /* not lint */
5 1.1 dyoung
6 1.1 dyoung #include <assert.h>
7 1.1 dyoung #include <err.h>
8 1.1 dyoung #include <errno.h>
9 1.1 dyoung #include <stdio.h>
10 1.1 dyoung #include <stdlib.h>
11 1.1 dyoung #include <string.h>
12 1.1 dyoung #include <util.h>
13 1.1 dyoung
14 1.1 dyoung #include <sys/ioctl.h>
15 1.1 dyoung
16 1.1 dyoung #include <net/if.h>
17 1.1 dyoung #include <net/if_dl.h>
18 1.1 dyoung #include <net/if_media.h>
19 1.1 dyoung
20 1.1 dyoung #include <prop/proplib.h>
21 1.1 dyoung
22 1.1 dyoung #include "env.h"
23 1.1 dyoung #include "extern.h"
24 1.1 dyoung #include "media.h"
25 1.1 dyoung #include "parse.h"
26 1.1 dyoung #include "util.h"
27 1.5 pooka #include "prog_ops.h"
28 1.1 dyoung
29 1.1 dyoung static void init_current_media(prop_dictionary_t, prop_dictionary_t);
30 1.1 dyoung static void media_constructor(void) __attribute__((constructor));
31 1.1 dyoung static int setmedia(prop_dictionary_t, prop_dictionary_t);
32 1.1 dyoung static int setmediainst(prop_dictionary_t, prop_dictionary_t);
33 1.1 dyoung static int setmediamode(prop_dictionary_t, prop_dictionary_t);
34 1.1 dyoung static int setmediaopt(prop_dictionary_t, prop_dictionary_t);
35 1.1 dyoung static int unsetmediaopt(prop_dictionary_t, prop_dictionary_t);
36 1.1 dyoung
37 1.1 dyoung /*
38 1.1 dyoung * Media stuff. Whenever a media command is first performed, the
39 1.1 dyoung * currently select media is grabbed for this interface. If `media'
40 1.1 dyoung * is given, the current media word is modifed. `mediaopt' commands
41 1.1 dyoung * only modify the set and clear words. They then operate on the
42 1.1 dyoung * current media word later.
43 1.1 dyoung */
44 1.1 dyoung static int media_current;
45 1.1 dyoung static int mediaopt_set;
46 1.1 dyoung static int mediaopt_clear;
47 1.1 dyoung
48 1.2 dyoung static struct usage_func usage;
49 1.2 dyoung
50 1.1 dyoung static const int ifm_status_valid_list[] = IFM_STATUS_VALID_LIST;
51 1.1 dyoung
52 1.1 dyoung static const struct ifmedia_status_description ifm_status_descriptions[] =
53 1.1 dyoung IFM_STATUS_DESCRIPTIONS;
54 1.1 dyoung
55 1.4 dyoung static struct pstr mediamode = PSTR_INITIALIZER1(&mediamode, "mediamode",
56 1.4 dyoung setmediamode, "mediamode", false, &command_root.pb_parser);
57 1.1 dyoung
58 1.1 dyoung static struct pinteger mediainst = PINTEGER_INITIALIZER1(&mediainst,
59 1.1 dyoung "mediainst", 0, IFM_INST_MAX, 10, setmediainst, "mediainst",
60 1.1 dyoung &command_root.pb_parser);
61 1.1 dyoung
62 1.4 dyoung static struct pstr unmediaopt = PSTR_INITIALIZER1(&unmediaopt, "-mediaopt",
63 1.4 dyoung unsetmediaopt, "unmediaopt", false, &command_root.pb_parser);
64 1.1 dyoung
65 1.4 dyoung static struct pstr mediaopt = PSTR_INITIALIZER1(&mediaopt, "mediaopt",
66 1.4 dyoung setmediaopt, "mediaopt", false, &command_root.pb_parser);
67 1.1 dyoung
68 1.4 dyoung static struct pstr media = PSTR_INITIALIZER1(&media, "media", setmedia, "media",
69 1.4 dyoung false, &command_root.pb_parser);
70 1.1 dyoung
71 1.1 dyoung static const struct kwinst mediakw[] = {
72 1.1 dyoung {.k_word = "instance", .k_key = "anymedia", .k_type = KW_T_BOOL,
73 1.1 dyoung .k_bool = true, .k_act = "media", .k_deact = "mediainst",
74 1.1 dyoung .k_nextparser = &mediainst.pi_parser}
75 1.1 dyoung , {.k_word = "inst", .k_key = "anymedia", .k_type = KW_T_BOOL,
76 1.1 dyoung .k_bool = true, .k_act = "media", .k_deact = "mediainst",
77 1.1 dyoung .k_nextparser = &mediainst.pi_parser}
78 1.1 dyoung , {.k_word = "media", .k_key = "anymedia", .k_type = KW_T_BOOL,
79 1.1 dyoung .k_bool = true, .k_deact = "media", .k_altdeact = "anymedia",
80 1.1 dyoung .k_nextparser = &media.ps_parser}
81 1.1 dyoung , {.k_word = "mediaopt", .k_key = "anymedia", .k_type = KW_T_BOOL,
82 1.1 dyoung .k_bool = true, .k_deact = "mediaopt", .k_altdeact = "instance",
83 1.1 dyoung .k_nextparser = &mediaopt.ps_parser}
84 1.1 dyoung , {.k_word = "-mediaopt", .k_key = "anymedia", .k_type = KW_T_BOOL,
85 1.1 dyoung .k_bool = true, .k_deact = "unmediaopt", .k_altdeact = "media",
86 1.1 dyoung .k_nextparser = &unmediaopt.ps_parser}
87 1.1 dyoung , {.k_word = "mode", .k_key = "anymedia", .k_type = KW_T_BOOL,
88 1.1 dyoung .k_bool = true, .k_deact = "mode",
89 1.1 dyoung .k_nextparser = &mediamode.ps_parser}
90 1.1 dyoung };
91 1.1 dyoung
92 1.1 dyoung struct pkw kwmedia = PKW_INITIALIZER(&kwmedia, "media keywords", NULL, NULL,
93 1.1 dyoung mediakw, __arraycount(mediakw), NULL);
94 1.1 dyoung
95 1.6 joerg __dead static void
96 1.1 dyoung media_error(int type, const char *val, const char *opt)
97 1.1 dyoung {
98 1.1 dyoung errx(EXIT_FAILURE, "unknown %s media %s: %s",
99 1.1 dyoung get_media_type_string(type), opt, val);
100 1.1 dyoung }
101 1.1 dyoung
102 1.1 dyoung void
103 1.1 dyoung init_current_media(prop_dictionary_t env, prop_dictionary_t oenv)
104 1.1 dyoung {
105 1.1 dyoung const char *ifname;
106 1.1 dyoung struct ifmediareq ifmr;
107 1.1 dyoung
108 1.1 dyoung if ((ifname = getifname(env)) == NULL)
109 1.1 dyoung err(EXIT_FAILURE, "getifname");
110 1.1 dyoung
111 1.1 dyoung /*
112 1.1 dyoung * If we have not yet done so, grab the currently-selected
113 1.1 dyoung * media.
114 1.1 dyoung */
115 1.1 dyoung
116 1.1 dyoung if (prop_dictionary_get(env, "initmedia") == NULL) {
117 1.1 dyoung memset(&ifmr, 0, sizeof(ifmr));
118 1.1 dyoung
119 1.1 dyoung if (direct_ioctl(env, SIOCGIFMEDIA, &ifmr) == -1) {
120 1.1 dyoung /*
121 1.1 dyoung * If we get E2BIG, the kernel is telling us
122 1.1 dyoung * that there are more, so we can ignore it.
123 1.1 dyoung */
124 1.1 dyoung if (errno != E2BIG)
125 1.1 dyoung err(EXIT_FAILURE, "SIOCGIFMEDIA");
126 1.1 dyoung }
127 1.1 dyoung
128 1.1 dyoung if (!prop_dictionary_set_bool(oenv, "initmedia", true)) {
129 1.1 dyoung err(EXIT_FAILURE, "%s: prop_dictionary_set_bool",
130 1.1 dyoung __func__);
131 1.1 dyoung }
132 1.1 dyoung media_current = ifmr.ifm_current;
133 1.1 dyoung }
134 1.1 dyoung
135 1.1 dyoung /* Sanity. */
136 1.1 dyoung if (IFM_TYPE(media_current) == 0)
137 1.1 dyoung errx(EXIT_FAILURE, "%s: no link type?", ifname);
138 1.1 dyoung }
139 1.1 dyoung
140 1.1 dyoung void
141 1.1 dyoung process_media_commands(prop_dictionary_t env)
142 1.1 dyoung {
143 1.1 dyoung struct ifreq ifr;
144 1.1 dyoung
145 1.1 dyoung if (prop_dictionary_get(env, "media") == NULL &&
146 1.1 dyoung prop_dictionary_get(env, "mediaopt") == NULL &&
147 1.1 dyoung prop_dictionary_get(env, "unmediaopt") == NULL &&
148 1.1 dyoung prop_dictionary_get(env, "mediamode") == NULL) {
149 1.1 dyoung /* Nothing to do. */
150 1.1 dyoung return;
151 1.1 dyoung }
152 1.1 dyoung
153 1.1 dyoung /*
154 1.1 dyoung * Media already set up, and commands sanity-checked. Set/clear
155 1.1 dyoung * any options, and we're ready to go.
156 1.1 dyoung */
157 1.1 dyoung media_current |= mediaopt_set;
158 1.1 dyoung media_current &= ~mediaopt_clear;
159 1.1 dyoung
160 1.1 dyoung memset(&ifr, 0, sizeof(ifr));
161 1.1 dyoung ifr.ifr_media = media_current;
162 1.1 dyoung
163 1.1 dyoung if (direct_ioctl(env, SIOCSIFMEDIA, &ifr) == -1)
164 1.1 dyoung err(EXIT_FAILURE, "SIOCSIFMEDIA");
165 1.1 dyoung }
166 1.1 dyoung
167 1.1 dyoung static int
168 1.3 dyoung setmedia(prop_dictionary_t env, prop_dictionary_t oenv)
169 1.1 dyoung {
170 1.1 dyoung int type, subtype, inst;
171 1.1 dyoung prop_data_t data;
172 1.1 dyoung char *val;
173 1.1 dyoung
174 1.3 dyoung init_current_media(env, oenv);
175 1.1 dyoung
176 1.1 dyoung data = (prop_data_t)prop_dictionary_get(env, "media");
177 1.1 dyoung assert(data != NULL);
178 1.1 dyoung
179 1.1 dyoung /* Only one media command may be given. */
180 1.1 dyoung /* Must not come after mode commands */
181 1.1 dyoung /* Must not come after mediaopt commands */
182 1.1 dyoung
183 1.1 dyoung /*
184 1.1 dyoung * No need to check if `instance' has been issued; setmediainst()
185 1.1 dyoung * craps out if `media' has not been specified.
186 1.1 dyoung */
187 1.1 dyoung
188 1.1 dyoung type = IFM_TYPE(media_current);
189 1.1 dyoung inst = IFM_INST(media_current);
190 1.1 dyoung
191 1.1 dyoung val = strndup(prop_data_data_nocopy(data), prop_data_size(data));
192 1.1 dyoung if (val == NULL)
193 1.1 dyoung return -1;
194 1.1 dyoung
195 1.1 dyoung /* Look up the subtype. */
196 1.1 dyoung subtype = get_media_subtype(type, val);
197 1.1 dyoung if (subtype == -1)
198 1.1 dyoung media_error(type, val, "subtype");
199 1.1 dyoung
200 1.1 dyoung /* Build the new current media word. */
201 1.1 dyoung media_current = IFM_MAKEWORD(type, subtype, 0, inst);
202 1.1 dyoung
203 1.1 dyoung /* Media will be set after other processing is complete. */
204 1.1 dyoung return 0;
205 1.1 dyoung }
206 1.1 dyoung
207 1.1 dyoung static int
208 1.3 dyoung setmediaopt(prop_dictionary_t env, prop_dictionary_t oenv)
209 1.1 dyoung {
210 1.1 dyoung char *invalid;
211 1.1 dyoung prop_data_t data;
212 1.1 dyoung char *val;
213 1.1 dyoung
214 1.3 dyoung init_current_media(env, oenv);
215 1.1 dyoung
216 1.1 dyoung data = (prop_data_t)prop_dictionary_get(env, "mediaopt");
217 1.1 dyoung assert(data != NULL);
218 1.1 dyoung
219 1.1 dyoung /* Can only issue `mediaopt' once. */
220 1.1 dyoung /* Can't issue `mediaopt' if `instance' has already been issued. */
221 1.1 dyoung
222 1.1 dyoung val = strndup(prop_data_data_nocopy(data), prop_data_size(data));
223 1.1 dyoung if (val == NULL)
224 1.1 dyoung return -1;
225 1.1 dyoung
226 1.1 dyoung mediaopt_set = get_media_options(media_current, val, &invalid);
227 1.1 dyoung free(val);
228 1.1 dyoung if (mediaopt_set == -1)
229 1.1 dyoung media_error(media_current, invalid, "option");
230 1.1 dyoung
231 1.1 dyoung /* Media will be set after other processing is complete. */
232 1.1 dyoung return 0;
233 1.1 dyoung }
234 1.1 dyoung
235 1.1 dyoung static int
236 1.3 dyoung unsetmediaopt(prop_dictionary_t env, prop_dictionary_t oenv)
237 1.1 dyoung {
238 1.1 dyoung char *invalid, *val;
239 1.1 dyoung prop_data_t data;
240 1.1 dyoung
241 1.3 dyoung init_current_media(env, oenv);
242 1.1 dyoung
243 1.1 dyoung data = (prop_data_t)prop_dictionary_get(env, "unmediaopt");
244 1.1 dyoung if (data == NULL) {
245 1.1 dyoung errno = ENOENT;
246 1.1 dyoung return -1;
247 1.1 dyoung }
248 1.1 dyoung
249 1.1 dyoung val = strndup(prop_data_data_nocopy(data), prop_data_size(data));
250 1.1 dyoung if (val == NULL)
251 1.1 dyoung return -1;
252 1.1 dyoung
253 1.1 dyoung /*
254 1.1 dyoung * No need to check for A_MEDIAINST, since the test for A_MEDIA
255 1.1 dyoung * implicitly checks for A_MEDIAINST.
256 1.1 dyoung */
257 1.1 dyoung
258 1.1 dyoung mediaopt_clear = get_media_options(media_current, val, &invalid);
259 1.1 dyoung free(val);
260 1.1 dyoung if (mediaopt_clear == -1)
261 1.1 dyoung media_error(media_current, invalid, "option");
262 1.1 dyoung
263 1.1 dyoung /* Media will be set after other processing is complete. */
264 1.1 dyoung return 0;
265 1.1 dyoung }
266 1.1 dyoung
267 1.1 dyoung static int
268 1.3 dyoung setmediainst(prop_dictionary_t env, prop_dictionary_t oenv)
269 1.1 dyoung {
270 1.1 dyoung int type, subtype, options;
271 1.1 dyoung int64_t inst;
272 1.1 dyoung bool rc;
273 1.1 dyoung
274 1.3 dyoung init_current_media(env, oenv);
275 1.1 dyoung
276 1.1 dyoung rc = prop_dictionary_get_int64(env, "mediainst", &inst);
277 1.1 dyoung assert(rc);
278 1.1 dyoung
279 1.1 dyoung /* Can only issue `instance' once. */
280 1.1 dyoung /* Must have already specified `media' */
281 1.1 dyoung
282 1.1 dyoung type = IFM_TYPE(media_current);
283 1.1 dyoung subtype = IFM_SUBTYPE(media_current);
284 1.1 dyoung options = IFM_OPTIONS(media_current);
285 1.1 dyoung
286 1.1 dyoung media_current = IFM_MAKEWORD(type, subtype, options, inst);
287 1.1 dyoung
288 1.1 dyoung /* Media will be set after other processing is complete. */
289 1.1 dyoung return 0;
290 1.1 dyoung }
291 1.1 dyoung
292 1.1 dyoung static int
293 1.3 dyoung setmediamode(prop_dictionary_t env, prop_dictionary_t oenv)
294 1.1 dyoung {
295 1.1 dyoung int type, subtype, options, inst, mode;
296 1.1 dyoung prop_data_t data;
297 1.1 dyoung char *val;
298 1.1 dyoung
299 1.3 dyoung init_current_media(env, oenv);
300 1.1 dyoung
301 1.1 dyoung data = (prop_data_t)prop_dictionary_get(env, "mediamode");
302 1.1 dyoung assert(data != NULL);
303 1.1 dyoung
304 1.1 dyoung type = IFM_TYPE(media_current);
305 1.1 dyoung subtype = IFM_SUBTYPE(media_current);
306 1.1 dyoung options = IFM_OPTIONS(media_current);
307 1.1 dyoung inst = IFM_INST(media_current);
308 1.1 dyoung
309 1.1 dyoung val = strndup(prop_data_data_nocopy(data), prop_data_size(data));
310 1.1 dyoung if (val == NULL)
311 1.1 dyoung return -1;
312 1.1 dyoung
313 1.1 dyoung mode = get_media_mode(type, val);
314 1.1 dyoung if (mode == -1)
315 1.1 dyoung media_error(type, val, "mode");
316 1.1 dyoung
317 1.1 dyoung free(val);
318 1.1 dyoung
319 1.1 dyoung media_current = IFM_MAKEWORD(type, subtype, options, inst) | mode;
320 1.1 dyoung
321 1.1 dyoung /* Media will be set after other processing is complete. */
322 1.1 dyoung return 0;
323 1.1 dyoung }
324 1.1 dyoung
325 1.1 dyoung void
326 1.1 dyoung print_media_word(int ifmw, const char *opt_sep)
327 1.1 dyoung {
328 1.1 dyoung const char *str;
329 1.1 dyoung
330 1.1 dyoung printf("%s", get_media_subtype_string(ifmw));
331 1.1 dyoung
332 1.1 dyoung /* Find mode. */
333 1.1 dyoung if (IFM_MODE(ifmw) != 0) {
334 1.1 dyoung str = get_media_mode_string(ifmw);
335 1.1 dyoung if (str != NULL)
336 1.1 dyoung printf(" mode %s", str);
337 1.1 dyoung }
338 1.1 dyoung
339 1.1 dyoung /* Find options. */
340 1.1 dyoung for (; (str = get_media_option_string(&ifmw)) != NULL; opt_sep = ",")
341 1.1 dyoung printf("%s%s", opt_sep, str);
342 1.1 dyoung
343 1.1 dyoung if (IFM_INST(ifmw) != 0)
344 1.1 dyoung printf(" instance %d", IFM_INST(ifmw));
345 1.1 dyoung }
346 1.1 dyoung
347 1.1 dyoung void
348 1.1 dyoung media_status(prop_dictionary_t env, prop_dictionary_t oenv)
349 1.1 dyoung {
350 1.1 dyoung struct ifmediareq ifmr;
351 1.1 dyoung int af, i, s;
352 1.1 dyoung int *media_list;
353 1.1 dyoung const char *ifname;
354 1.1 dyoung
355 1.1 dyoung if ((ifname = getifname(env)) == NULL)
356 1.1 dyoung err(EXIT_FAILURE, "getifname");
357 1.1 dyoung if ((af = getaf(env)) == -1)
358 1.1 dyoung af = AF_UNSPEC;
359 1.1 dyoung
360 1.1 dyoung /* get out early if the family is unsupported by the kernel */
361 1.1 dyoung if ((s = getsock(af)) == -1)
362 1.1 dyoung err(EXIT_FAILURE, "%s: getsock", __func__);
363 1.1 dyoung
364 1.1 dyoung memset(&ifmr, 0, sizeof(ifmr));
365 1.1 dyoung estrlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
366 1.1 dyoung
367 1.5 pooka if (prog_ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) {
368 1.1 dyoung /*
369 1.1 dyoung * Interface doesn't support SIOC{G,S}IFMEDIA.
370 1.1 dyoung */
371 1.1 dyoung return;
372 1.1 dyoung }
373 1.1 dyoung
374 1.1 dyoung if (ifmr.ifm_count == 0) {
375 1.1 dyoung warnx("%s: no media types?", ifname);
376 1.1 dyoung return;
377 1.1 dyoung }
378 1.1 dyoung
379 1.1 dyoung media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
380 1.1 dyoung if (media_list == NULL)
381 1.1 dyoung err(EXIT_FAILURE, "malloc");
382 1.1 dyoung ifmr.ifm_ulist = media_list;
383 1.1 dyoung
384 1.5 pooka if (prog_ioctl(s, SIOCGIFMEDIA, &ifmr) == -1)
385 1.1 dyoung err(EXIT_FAILURE, "SIOCGIFMEDIA");
386 1.1 dyoung
387 1.1 dyoung printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
388 1.1 dyoung print_media_word(ifmr.ifm_current, " ");
389 1.1 dyoung if (ifmr.ifm_active != ifmr.ifm_current) {
390 1.1 dyoung printf(" (");
391 1.1 dyoung print_media_word(ifmr.ifm_active, " ");
392 1.1 dyoung printf(")");
393 1.1 dyoung }
394 1.1 dyoung printf("\n");
395 1.1 dyoung
396 1.1 dyoung if (ifmr.ifm_status & IFM_STATUS_VALID) {
397 1.1 dyoung const struct ifmedia_status_description *ifms;
398 1.1 dyoung int bitno, found = 0;
399 1.1 dyoung
400 1.1 dyoung printf("\tstatus: ");
401 1.1 dyoung for (bitno = 0; ifm_status_valid_list[bitno] != 0; bitno++) {
402 1.1 dyoung for (ifms = ifm_status_descriptions;
403 1.1 dyoung ifms->ifms_valid != 0; ifms++) {
404 1.1 dyoung if (ifms->ifms_type !=
405 1.1 dyoung IFM_TYPE(ifmr.ifm_current) ||
406 1.1 dyoung ifms->ifms_valid !=
407 1.1 dyoung ifm_status_valid_list[bitno])
408 1.1 dyoung continue;
409 1.1 dyoung printf("%s%s", found ? ", " : "",
410 1.1 dyoung IFM_STATUS_DESC(ifms, ifmr.ifm_status));
411 1.1 dyoung found = 1;
412 1.1 dyoung
413 1.1 dyoung /*
414 1.1 dyoung * For each valid indicator bit, there's
415 1.1 dyoung * only one entry for each media type, so
416 1.1 dyoung * terminate the inner loop now.
417 1.1 dyoung */
418 1.1 dyoung break;
419 1.1 dyoung }
420 1.1 dyoung }
421 1.1 dyoung
422 1.1 dyoung if (found == 0)
423 1.1 dyoung printf("unknown");
424 1.1 dyoung printf("\n");
425 1.1 dyoung }
426 1.1 dyoung
427 1.1 dyoung if (get_flag('m')) {
428 1.1 dyoung int type, printed_type;
429 1.1 dyoung
430 1.1 dyoung for (type = IFM_NMIN; type <= IFM_NMAX; type += IFM_NMIN) {
431 1.1 dyoung for (i = 0, printed_type = 0; i < ifmr.ifm_count; i++) {
432 1.1 dyoung if (IFM_TYPE(media_list[i]) != type)
433 1.1 dyoung continue;
434 1.1 dyoung if (printed_type == 0) {
435 1.1 dyoung printf("\tsupported %s media:\n",
436 1.1 dyoung get_media_type_string(type));
437 1.1 dyoung printed_type = 1;
438 1.1 dyoung }
439 1.1 dyoung printf("\t\tmedia ");
440 1.1 dyoung print_media_word(media_list[i], " mediaopt ");
441 1.1 dyoung printf("\n");
442 1.1 dyoung }
443 1.1 dyoung }
444 1.1 dyoung }
445 1.1 dyoung
446 1.1 dyoung free(media_list);
447 1.1 dyoung }
448 1.1 dyoung
449 1.1 dyoung static void
450 1.2 dyoung media_usage(prop_dictionary_t env)
451 1.2 dyoung {
452 1.2 dyoung fprintf(stderr,
453 1.2 dyoung "\t[ media type ] [ mediaopt opts ] [ -mediaopt opts ] "
454 1.2 dyoung "[ instance minst ]\n");
455 1.2 dyoung }
456 1.2 dyoung
457 1.2 dyoung static void
458 1.1 dyoung media_constructor(void)
459 1.1 dyoung {
460 1.1 dyoung if (register_flag('m') != 0)
461 1.1 dyoung err(EXIT_FAILURE, __func__);
462 1.2 dyoung usage_func_init(&usage, media_usage);
463 1.2 dyoung register_usage(&usage);
464 1.1 dyoung }
465