1*12e5c931Sguenther /* $OpenBSD: app.c,v 1.14 2017/02/03 08:23:46 guenther Exp $ */
2b393bef8Sniklas /* $EOM: app.c,v 1.6 1999/05/01 20:21:06 niklas Exp $ */
32040585eSniklas
42040585eSniklas /*
5eb840acdSniklas * Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved.
62040585eSniklas *
72040585eSniklas * Redistribution and use in source and binary forms, with or without
82040585eSniklas * modification, are permitted provided that the following conditions
92040585eSniklas * are met:
102040585eSniklas * 1. Redistributions of source code must retain the above copyright
112040585eSniklas * notice, this list of conditions and the following disclaimer.
122040585eSniklas * 2. Redistributions in binary form must reproduce the above copyright
132040585eSniklas * notice, this list of conditions and the following disclaimer in the
142040585eSniklas * documentation and/or other materials provided with the distribution.
152040585eSniklas *
162040585eSniklas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
172040585eSniklas * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
182040585eSniklas * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
192040585eSniklas * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
202040585eSniklas * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
212040585eSniklas * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
222040585eSniklas * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
232040585eSniklas * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
242040585eSniklas * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
252040585eSniklas * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
262040585eSniklas */
272040585eSniklas
282040585eSniklas /*
292040585eSniklas * This code was written under funding by Ericsson Radio Systems.
302040585eSniklas */
312040585eSniklas
322040585eSniklas /*
332040585eSniklas * XXX This is just a wrapper module for now. Later we might handle many
342040585eSniklas * applications simultaneously but right now, we assume one system-dependent
352040585eSniklas * one only.
362040585eSniklas */
372040585eSniklas
38*12e5c931Sguenther #include <netinet/in.h>
39*12e5c931Sguenther
402040585eSniklas #include "app.h"
412040585eSniklas #include "log.h"
422718e611Sderaadt #include "monitor.h"
433a722197Shshoexer #include "pf_key_v2.h"
442040585eSniklas
452040585eSniklas int app_socket;
462040585eSniklas
472040585eSniklas /* Set this to not get any applications setup. */
482040585eSniklas int app_none = 0;
492040585eSniklas
50b393bef8Sniklas /* Initialize applications. */
512040585eSniklas void
app_init(void)5230c1e3c7Sho app_init(void)
532040585eSniklas {
542040585eSniklas if (app_none)
552040585eSniklas return;
565c29cdadSderaadt app_socket = monitor_pf_key_v2_open();
572040585eSniklas if (app_socket == -1)
582040585eSniklas log_fatal("app_init: cannot open connection to application");
592040585eSniklas }
602040585eSniklas
612040585eSniklas void
app_handler(void)6230c1e3c7Sho app_handler(void)
632040585eSniklas {
643a722197Shshoexer pf_key_v2_handler(app_socket);
652040585eSniklas }
66