Browse code
feat: ssdp implementation
Ed L authored on 16/11/2022 17:44:33
Showing 2 changed files
Showing 2 changed files
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,53 @@ |
1 |
+(in-package :sockint) |
|
2 |
+;; MCAST_JOIN_GROUP |
|
3 |
+#+(or win32 windows)(defconstant mcast-join-group 41) |
|
4 |
+#+linux(defconstant mcast-join-group 42) |
|
5 |
+#+freebsd(defconstant mcast-join-group 80) |
|
6 |
+#+darwin(defconstant mcast-join-group 80) |
|
7 |
+ |
|
8 |
+;; IP_MULTICAST_LOOP |
|
9 |
+#+(or win32 windows)(defconstant ip-multicast-loop 11) |
|
10 |
+#+linux(defconstant ip-multicast-loop 34) |
|
11 |
+#+freebsd(defconstant ip-multicast-loop 11) |
|
12 |
+#+darwin(defconstant ip-multicast-loop 11) |
|
13 |
+ |
|
14 |
+;; IPV6_MULTICAST_LOOP |
|
15 |
+#+(or win32 windows)(defconstant ip6-multicast-loop 11) |
|
16 |
+#+linux(defconstant ip6-multicast-loop 19) |
|
17 |
+#+freebsd(defconstant ip6-multicast-loop 19) |
|
18 |
+#+darwin(defconstant ip6-multicast-loop 19) |
|
19 |
+ |
|
20 |
+;; IP_MULTICAST_IF |
|
21 |
+#+(or win32 windows)(defconstant ip-multicast-if 9) |
|
22 |
+#+linux(defconstant ip-multicast-if 32) |
|
23 |
+#+freebsd(defconstant ip-multicast-if 9) |
|
24 |
+#+darwin(defconstant ip-multicast-if 9) |
|
25 |
+ |
|
26 |
+;; IPV6_MULTICAST_IF |
|
27 |
+#+(or win32 windows)(defconstant ip6-multicast-if 9) |
|
28 |
+#+linux(defconstant ip6-multicast-if 17) |
|
29 |
+#+freebsd(defconstant ip6-multicast-if 9) |
|
30 |
+#+darwin(defconstant ip6-multicast-if 9) |
|
31 |
+ |
|
32 |
+;; IP_MULTICAST_TTL |
|
33 |
+#+(or win32 windows)(defconstant ip-multicast-ttl 10) |
|
34 |
+#+linux(defconstant ip-multicast-ttl 33) |
|
35 |
+#+freebsd(defconstant ip-multicast-ttl 10) |
|
36 |
+#+darwin(defconstant ip-multicast-ttl 10) |
|
37 |
+ |
|
38 |
+;; IPV6_MULTICAST_HOPS |
|
39 |
+#+(or win32 windows)(defconstant ipv6-multicast-hops 10) |
|
40 |
+#+linux(defconstant ipv6-multicast-hops 18) |
|
41 |
+#+freebsd(defconstant ipv6-multicast-hops 10) |
|
42 |
+#+darwin(defconstant ipv6-multicast-hops 10) |
|
43 |
+ |
|
44 |
+(in-package :sb-bsd-sockets) |
|
45 |
+ |
|
46 |
+(define-socket-option-bool |
|
47 |
+ sockopt-ip-multicast-loop :ip sockint::ip-multicast-loop) |
|
48 |
+(define-socket-option-int |
|
49 |
+ sockopt-ip-multicast-if :ip sockint::ip-multicast-if) |
|
50 |
+(define-socket-option-int |
|
51 |
+ sockopt-ip-multicast-ttl :ip sockint::ip-multicast-ttl) |
|
52 |
+ |
|
53 |
+ |
... | ... |
@@ -55,6 +55,22 @@ |
55 | 55 |
|
56 | 56 |
(defun setup-sockopt (socket addr) |
57 | 57 |
(setf (sb-bsd-sockets:sockopt-ip-multicast-loop socket) nil |
58 |
- (sb-bsd-sockets:sockopt-multicast-if socket) (addr->int addr) |
|
59 |
- (sb-bsd-sockets:sockopt-multicast-ttl socket) 2) |
|
58 |
+ (sb-bsd-sockets:sockopt-ip-multicast-if socket) (addr->int addr) |
|
59 |
+ (sb-bsd-sockets:sockopt-ip-multicast-ttl socket) 2) |
|
60 | 60 |
socket) |
61 |
+ |
|
62 |
+ |
|
63 |
+(macrolet ((def-keypress-fun (name) |
|
64 |
+ (let ((endpoint (:printv |
|
65 |
+ (format nil "/keypress/~{~:(~a~)~}" |
|
66 |
+ (coerce (fwoar.string-utils:split #\- |
|
67 |
+ (string name)) |
|
68 |
+ 'list))))) |
|
69 |
+ `(defun ,name () |
|
70 |
+ (drakma:http-request (puri:merge-uris ,endpoint |
|
71 |
+ (puri:parse-uri *roku*)) |
|
72 |
+ :method :post))))) |
|
73 |
+ (def-keypress-fun power-on) |
|
74 |
+ (def-keypress-fun power-off) |
|
75 |
+ (def-keypress-fun volume-up) |
|
76 |
+ (def-keypress-fun volume-down)) |