File tree 9 files changed +81
-2
lines changed
9 files changed +81
-2
lines changed Original file line number Diff line number Diff line change 1
- lsquic
2
- boringssl
1
+ c-src / * .o
2
+ c-src / * .so
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ BORINGSSL_COMMIT=251b5169fd44345f455438312ec4e18ae07fd58c
2
2
3
3
.PHONY : lsquic build test
4
4
5
+ all : src/ffi.lisp src/ffi-dns.lisp
6
+
5
7
lsquic :
6
8
git clone --recursive https://github.com/litespeedtech/lsquic.git --depth 1
7
9
git clone https://boringssl.googlesource.com/boringssl
@@ -13,3 +15,6 @@ lsquic:
13
15
14
16
src/ffi.lisp : lsquic.i Makefile
15
17
swig -cffi -noswig-lisp -module ffi -outdir src -I./lsquic/include/ lsquic.i
18
+
19
+ src/ffi-dns.lisp : dns.i Makefile
20
+ swig -cffi -noswig-lisp -module ffi-dns -outdir src -I./c-src dns.i
Original file line number Diff line number Diff line change
1
+ dns.so :
2
+ gcc -c -Wall -fpic dns.c
3
+ gcc -shared -o libdns.so dns.o
Original file line number Diff line number Diff line change
1
+ #include <arpa/inet.h>
2
+ #include <netdb.h>
3
+ #include <stdio.h>
4
+ #include <stdlib.h>
5
+ #include <string.h>
6
+ #include <sys/socket.h>
7
+ #include <sys/types.h>
8
+
9
+ struct sockaddr * gen_sockaddr (int family , const char * ip , u_short port ) {
10
+ struct sockaddr_storage * ss = malloc (sizeof (struct sockaddr_storage ));
11
+
12
+ switch (family )
13
+ {
14
+ case AF_INET :
15
+ {
16
+ struct sockaddr_in * addr = (struct sockaddr_in * ) ss ;
17
+ addr -> sin_family = AF_INET ;
18
+ addr -> sin_port = htons (port );
19
+ inet_pton (AF_INET , ip , & addr -> sin_addr );
20
+ break ;
21
+ }
22
+
23
+ case AF_INET6 :
24
+ {
25
+ struct sockaddr_in6 * addr = (struct sockaddr_in6 * ) ss ;
26
+ addr -> sin6_family = AF_INET6 ;
27
+ addr -> sin6_port = htons (port );
28
+ inet_pton (AF_INET6 , ip , & addr -> sin6_addr );
29
+ break ;
30
+ }
31
+
32
+ default :
33
+ return NULL ;
34
+ }
35
+ return (struct sockaddr * ) ss ;
36
+ }
Original file line number Diff line number Diff line change
1
+ #include <sys/types.h>
2
+ #include <sys/socket.h>
3
+ #include <netdb.h>
4
+
5
+ struct sockaddr * gen_sockaddr (int family , const char * ip , u_short port );
Original file line number Diff line number Diff line change
1
+ #include <sys/types.h>
2
+ #include <sys/socket.h>
3
+ #include <netdb.h>
Original file line number Diff line number Diff line change
1
+ %feature(" intern_function" , " lispify" );
2
+
3
+ %insert(" lisphead" ) %{
4
+ (in-package :lsquic)
5
+ %}
6
+
7
+ %include " dns.h"
Original file line number Diff line number Diff line change
1
+ ; ;; This file was automatically generated by SWIG (http://www.swig.org).
2
+ ; ;; Version 3.0.12
3
+ ; ;;
4
+ ; ;; Do not make changes to this file unless you know what you are doing--modify
5
+ ; ;; the SWIG interface file instead.
6
+
7
+ (in-package :lsquic )
8
+
9
+
10
+
11
+ (cffi :defcfun (" gen_sockaddr" #. (lispify " gen_sockaddr" ' function)) :pointer
12
+ (family :int )
13
+ (ip :string )
14
+ (port :pointer ))
15
+
16
+
Original file line number Diff line number Diff line change 8
8
(cffi :define-foreign-library lsquic
9
9
(:unix (:or " lsquic/src/liblsquic/liblsquic.so" )))
10
10
11
+ (cffi :define-foreign-library dns
12
+ (:unix (:or " c-src/libdns.so" )))
13
+
11
14
(defun lispify (name flag &optional (package *package* ))
12
15
" Borrowed from: https://github.com/mtstickney/cl-libqmlbind/blob/24df1d4248c8962eaadb9dc180e25afa14c7492d/cl-libqmlbind.lisp"
13
16
(intern (string-upcase (map ' string (lambda (c)
18
21
package ))
19
22
20
23
(cffi :use-foreign-library lsquic)
24
+ (cffi :use-foreign-library dns)
You can’t perform that action at this time.
0 commit comments