-tables.[ch]
+*+tcmdif.[ch]
*.d
-adns+tcmdif.[ch]
+*+tcmdif.[ch]
*.d
--- /dev/null
+#include <string.h>
+#include <errno.h>
+
+#include "chiark-tcl.h"
+#include "base+tcmdif.h"
# Arranges for generated .h files to #include the specified
# file. C-INCLUDE-SPECIFIER should include the <..> or "..".
#
-# Table TABLENAME C-ENTRY-TYPE
+# Table [*]TABLENAME C-ENTRY-TYPE
# Starts a table of commands or subcommands. The generated .h
# will contain a definition of C-ENTRY-TYPE containing
# const char *name;
# arguments, processes the command, and sets any result, as
# applicable.
#
+# `*' should be used if the table name is not useful for error
+# messages. It suppresses `TABLENAME ' from the front of the
+# autogenerated argument parsing error strings.
+#
# ExtraEntry C-ENTRY-TYPE
# Introduces a section of additional C code which will be inserted
# into the definition of C-ENTRY-TYPE by `Table'. The C
unshift @i, $this_indent;
}
- if (@i==0 && m/^Table\s+(\w+)\s+(\w+)$/) {
+ if (@i==0 && m/^Table\s+(\*?)(\w+)\s+(\w+)$/) {
zilch();
- $c_table= $1;
- $table_x{$c_table}{C}= $2;
- $entrytype_x{$2}= '' unless exists $entrytype_x{$2};
+ $c_table= $2;
+ $table_x{$c_table}{T}= $1;
+ $table_x{$c_table}{C}= $3;
+ $entrytype_x{$3}= '' unless exists $entrytype_x{$3};
} elsif (@i==0 && m/^Untabled$/) {
zilch();
$c_table= '';
$any_eerr= 0;
$any_eargc= 0;
$pa_hint= '';
- $pa_hint .= "$c_table " if length $c_table;
+ $pa_hint .= "$c_table " if length $c_table &&
+ !length $table_x{$c_table}{T};
$pa_hint.= $c_entry;
foreach $arg (@{ $r_entry->{A} }) {
$n= $arg->{N};
--- /dev/null
+/* from crypto.c */
+
+void memxor(Byte *dest, const Byte *src, int l);
+
+typedef struct {
+ const char *name;
+ int pad, use_algname;
+} PadOp;
+
+extern Tcl_ObjType blockcipherkey_type;
+
+/* from algtables.c */
+
+typedef struct {
+ const char *name;
+ int int_offset;
+} BlockCipherPropInfo, HashAlgPropInfo;
+
+typedef struct {
+ const char *name;
+ int hashsize, blocksize, statesize;
+ void (*init)(void *state);
+ void (*update)(void *state, const void *data, int len);
+ void (*final)(void *state, void *digest);
+ void (*oneshot)(void *digest, const void *data, int len);
+} HashAlgInfo;
+
+extern const HashAlgInfo hashalginfos[];
+
+typedef struct {
+ void (*make_schedule)(void *schedule, const void *key, int keylen);
+ void (*crypt)(const void *schedule, const void *in, void *out);
+ /* in and out may be the same, but if they aren't they may not overlap */
+ /* in and out for crypt will have been through block_byteswap */
+} BlockCipherPerDirectionInfo;
+
+typedef struct {
+ const char *name;
+ int blocksize, schedule_size, key_min, key_max;
+ BlockCipherPerDirectionInfo encrypt, decrypt;
+} BlockCipherAlgInfo;
+
+extern const BlockCipherAlgInfo blockcipheralginfos[];
+
+/* from bcmode.c */
+
+typedef struct {
+ const char *name;
+ int iv_blocks, buf_blocks, mac_blocks;
+
+ /* Each function is allowed to use up to buf_blocks * blocksize
+ * bytes of space in buf. data is blocks * blocksize bytes
+ * long. data should be modified in place by encrypt and decrypt;
+ * modes may not change the size of data. iv is always provided and
+ * is always of length iv_blocks * blocksize; encrypt and
+ * decrypt may modify the iv value (in which case the Tcl caller
+ * will get the modified IV) but this is not recommended. mac
+ * should leave the mac, which must be mac_blocks * blocksize
+ * bytes, in buf. (Therefore mac_blocks must be at least
+ * buf_blocks.)
+ */
+ const char *(*encrypt)(Byte *data, int nblocks,
+ const Byte *iv, Byte *buf,
+ const BlockCipherAlgInfo *alg, int encr,
+ const void *sch);
+ const char *(*decrypt)(Byte *data, int nblocks,
+ const Byte *iv, Byte *buf,
+ const BlockCipherAlgInfo *alg, int encr,
+ const void *sch);
+ const char *(*mac)(const Byte *data, int nblocks,
+ const Byte *iv, Byte *buf,
+ const BlockCipherAlgInfo *alg,
+ const void *sch);
+} BlockCipherModeInfo;
+
+extern const BlockCipherModeInfo blockciphermodeinfos[];
+
--- /dev/null
+ Tcl_RegisterObjType(&blockcipherkey_type);
--- /dev/null
+/* from sockaddr.c */
+
+typedef struct {
+ Byte *begin, *end;
+} SockAddr_Value;
+
+extern Tcl_ObjType sockaddr_type;
+
+void sockaddr_clear(SockAddr_Value*);
+void sockaddr_create(SockAddr_Value*, const struct sockaddr *addr, int len);
+int sockaddr_len(const SockAddr_Value*);
+const struct sockaddr *sockaddr_addr(const SockAddr_Value*);
+void sockaddr_free(const SockAddr_Value*);
+
+/* from dgram.c */
+
+extern const IdDataSpec dgram_socks;
+
+/* from misc.c */
+
+int setnonblock(int fd, int isnonblock);
+
--- /dev/null
+ Tcl_RegisterObjType(&sockaddr_type);
--- /dev/null
+*+tcmdif.[ch]
+*.d
BASE_DIR = ../base
EXTBASE = hbytes
-CFILES = addrmap chop hbytes hook parse ulongs
+CFILES = chop hbytes hook parse ulongs
include ../base/extension.make
--- /dev/null
+/*
+ */
+
+#ifndef CHIARK_TCL_HBYTES_H
+#define CHIARK_TCL_HBYTES_H
+
+#include "hbytes.h"
+
+typedef struct {
+ Byte *start; /* byl bytes */
+ Tcl_Obj *data; /* may be 0 to mean empty */
+} AddrMap_Entry;
+
+struct AddrMap_Value {
+ int byl, used, space;
+ AddrMap_Entry *entries;
+ /* Entries are sorted by start. Each entry gives value (or lack of
+ * it) for all A st START <= A < NEXT-START. Last entry has value
+ * (or lack of it) for all A >= START. First entry is always
+ * present and always has start all-bits-0. */
+}; /* internalRep.otherValuePtr */
+
+#include "hbytes+tcmdif.h"
+
+#endif /*CHIARK_TCL_HBYTES_H*/
+++ /dev/null
-int cht_pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
- int rc;
- rc= pat_somethingv(ip,var,&agg->sth,&hbytes_type); if (rc) return rc;
- agg->hb= OBJ_HBYTES(agg->sth.obj);
- return TCL_OK;
-}
-
-int cht_pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
- int rc;
- rc= Tcl_ConvertToType(ip,obj,&hbytes_type); if (rc) return rc;
- *val= *OBJ_HBYTES(obj);
- return TCL_OK;
-}
-
-Tcl_Obj *cht_ret_hb(Tcl_Interp *ip, HBytes_Value val) {
- Tcl_Obj *obj;
- obj= Tcl_NewObj();
- Tcl_InvalidateStringRep(obj);
- *OBJ_HBYTES(obj)= val;
- obj->typePtr= &hbytes_type;
- return obj;
-}
-
Init addrmapv @.am=0; cht_init_somethingv(&@.sth);
Fini addrmapv cht_fini_somethingv(ip, rc, &@.sth);
-Table hbytestoplevel TopLevel_Command
+Table *hbytestoplevel TopLevel_Command
hbytes
subcmd enum(HBytes/_SubCommand, "hbytes subcommand")
... obj
random
length int
=> hb
-# addr-map
-# subcmd enum(AddrMap/_SubCommand, "hbytes addr-map subcommand")
-# ... obj
-
-#Table addrmap AddrMap_SubCommand
-# lookup
-# map constv(&cht_addrmap_type)
-# addr hb
-# ?def obj
-# => obj
-# amend-range
-# map addrmapv
-# start hb
-# end hb
-# data obj
-# amend-mask
-# map addrmapv
-# prefix hb
-# preflen obj
-# data obj
-
return TCL_OK;
}
-int cht_do_hbytes_addr_map(ClientData cd, Tcl_Interp *ip,
- const AddrMap_SubCommand *subcmd,
- int objc, Tcl_Obj *const *objv) {
- return subcmd->func(0,ip,objc,objv);
-}
-
/* hbytes representing uint16_t's */
int cht_do_hbytes_h2ushort(ClientData cd, Tcl_Interp *ip,
return cht_initextension(ip, cht_hbytestoplevel_entries, &initd,
&cht_hbytes_type,
&cht_ulong_type,
- &cht_addrmap_type,
(Tcl_ObjType*)0);
}
#include "chiark_tcl_hbytes.h"
+int cht_pat_hbv(Tcl_Interp *ip, Tcl_Obj *var, HBytes_Var *agg) {
+ int rc;
+ rc= cht_pat_somethingv(ip,var,&agg->sth,&cht_hbytes_type);
+ if (rc) return rc;
+ agg->hb= OBJ_HBYTES(agg->sth.obj);
+ return TCL_OK;
+}
int cht_pat_hb(Tcl_Interp *ip, Tcl_Obj *obj, HBytes_Value *val) {
int rc;
rc= Tcl_ConvertToType(ip,obj,&cht_hbytes_type); if (rc) return rc;
--- /dev/null
+int cht_do_hbytes_addr_map(ClientData cd, Tcl_Interp *ip,
+ const AddrMap_SubCommand *subcmd,
+ int objc, Tcl_Obj *const *objv) {
+ return subcmd->func(0,ip,objc,objv);
+}
+
+xxxx
+extern int Chiark_tcl_hbytes_Init(Tcl_Interp *ip); /*called by load(3tcl)*/
+int Chiark_tcl_hbytes_Init(Tcl_Interp *ip) {
+ static int initd;
+
+ return cht_initextension(ip, cht_hbytestoplevel_entries, &initd,
+ &cht_addrmap_type,
+ (Tcl_ObjType*)0);
+}
--- /dev/null
+Table maskmaptoplevel TopLevel_Command
+ addr-map
+ subcmd enum(AddrMap/_SubCommand, "addr-map subcommand")
+ ... obj
+
+Table addrmap AddrMap_SubCommand
+ lookup
+ map constv(&cht_addrmap_type)
+ addr hb
+ ?def obj
+ => obj
+ amend-range
+ map addrmapv
+ start hb
+ end hb
+ data obj
+ amend-mask
+ map addrmapv
+ prefix hb
+ preflen obj
+ data obj
+
--- /dev/null
+/* from tuntap.c */
+
+extern const IdDataSpec tuntap_socks;
+
--- /dev/null
+
+Table tuntap_socket_raw TunSocket_SubCommand
+ create
+ ?ifname string
+ => iddata(&tuntap_socks)
+ close
+ sock iddata(&tuntap_socks)
+ ifname
+ sock iddata(&tuntap_socks)
+ => string
+ receive
+ sock iddata(&tuntap_socks)
+ data hb
+ on-transmit
+ sock iddata(&tuntap_socks)
+ mtu long
+ ?script obj
+