type
stringclasses
5 values
content
stringlengths
9
163k
functions
void statusline_addstr(const char *str) { mvwaddstr(bottom, 1, 0, str); refresh(); wrefresh(bottom); }
functions
void statusline_addhlstr(const char *str) { #if defined(A_BOLD) && defined(A_NORMAL) && defined(A_DIM) const char *p = str, *start = str; char *tmp; int pos = 0; while(1) { if(!*p || strchr("<>", *p)) { if(p - start > 0) { wattrset(bottom, (*p == '>') ? A_BOLD : A_NORMAL); tmp = xstrndup(start, p - st...
functions
int statusline_askchoice(const char *msg, const char *choices, short dflt) { char *s; int ch; assert((dflt >= 0) && (dflt <= strlen(choices))); if(dflt) { s = strdup_printf("%s [%c]", msg, choices[dflt - 1]); statusline_addhlstr(s); free(s); }
functions
int statusline_ask_boolean(const char *msg, int def) { int ret; char *msg2 = strconcat(msg, def ? _(" (Y/n)?") : _(" (y/N)?"), NULL); char ch; statusline_addstr(msg2); free(msg2); ch = tolower(getch()); if(ch == *(S_("keybinding for no|n"))) ret = FALSE; else if(ch == *(S_("keybinding for yes|y"))) ret...
functions
void refresh_statusline() { werase(bottom); wattrset(bottom, COLOR_PAIR(CP_FOOTER)); mvwhline(bottom, 0, 0, UI_HLINE_CHAR, COLS); refresh(); wrefresh(bottom); }
functions
void clear_statusline() { wmove(bottom, 1, 0); wclrtoeol(bottom); wrefresh(bottom); refresh(); }
functions
void display_help(int help) { int i; char **tbl; WINDOW *helpw; switch(help) { case HELP_MAIN: tbl = mainhelp; break; case HELP_EDITOR: tbl = editorhelp; break; default:return; }
functions
void get_commands() { int ch; for(;;) { can_resize = TRUE; /* it's safe to resize now */ if(!opt_get_bool(BOOL_SHOW_CURSOR)) hide_cursor(); if(should_resize) refresh_screen(); ch = getch(); if(!opt_get_bool(BOOL_SHOW_CURSOR)) show_cursor(); can_resize = FALSE; /* it's not safe to resize anymore ...
functions
else if(event.bstate & BUTTON4_PRESSED) { scroll_list_up(); }
functions
else if(event.bstate & BUTTON5_PRESSED) { scroll_list_down(); }
functions
void ui_remove_items() { if(list_is_empty()) return; if(statusline_ask_boolean(_("Remove selected item(s)"), FALSE)) remove_selected_items(); clear_statusline(); refresh_list(); }
functions
void ui_merge_items() { if(statusline_ask_boolean(_("Merge selected items"), FALSE)) merge_selected_items(); clear_statusline(); refresh_list(); }
functions
void ui_remove_duplicates() { if(statusline_ask_boolean(_("Remove duplicates"), FALSE)) remove_duplicates(); clear_statusline(); refresh_list(); }
functions
void ui_clear_database() { if(statusline_ask_boolean(_("Clear WHOLE database"), FALSE)) { close_database(); refresh_list(); }
functions
void ui_find(int next) { int item = -1; static char findstr[MAX_FIELD_LEN]; int search_fields[] = {NAME, EMAIL, NICK, -1}
functions
void ui_print_number_of_items() { char *str = strdup_printf(" " "|%3d/%3d", selected_items(), db_n_items()); attrset(COLOR_PAIR(CP_HEADER)); mvaddstr(0, COLS-strlen(str), str); free(str); }
functions
void ui_read_database() { char *msg; if(!list_is_empty()) { msg = strdup_printf(_("Your current data will be lost - " "Press '%c' to continue"), *(S_("keybinding for yes|y"))); if(!statusline_ask_boolean(msg, FALSE)) { free(msg); return; }
functions
void ui_print_database() { FILE *handle; char *command = opt_get_str(STR_PRINT_COMMAND); int mode; if(list_is_empty()) return; switch(statusline_askchoice(_("Print <a>ll, print <s>elected, or <c>ancel?"), S_("keybindings:all/selected/cancel|asc"), 3)) { case 1: mode = ENUM_ALL; break; case 2: if( ...
functions
void ui_open_datafile() { char *filename; filename = ask_filename(_("File to open: ")); if(!filename || ! *filename) { free(filename); refresh_screen(); return; }
defines
#define STOP_DMA_TIMEOUT 4000 /* us */
defines
#define STOP_DMA_ITER 100 /* us */
defines
#define VALID_KEY_TYPES \
defines
#define isValidKeyType(_t) ((1 << (_t)) & VALID_KEY_TYPES)
defines
#define set11nTries(_series, _index) \
defines
#define set11nRate(_series, _index) \
defines
#define set11nPktDurRTSCTS(_series, _index) \
defines
#define set11nRateFlags(_series, _index) \
defines
#define VALID_PKT_TYPES \
defines
#define isValidPktType(_t) ((1<<(_t)) & VALID_PKT_TYPES)
defines
#define VALID_TX_RATES \
defines
#define isValidTxRate(_r) ((1<<(_r)) & VALID_TX_RATES)
defines
#define RTSCTS (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)
defines
#define RTSCTS (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)
functions
HAL_BOOL ar5416StopTxDma(struct ath_hal *ah, u_int q) { u_int i; HALASSERT(q < AH_PRIVATE(ah)->ah_caps.halTotalQueues); HALASSERT(AH5212(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE); OS_REG_WRITE(ah, AR_Q_TXD, 1 << q); for (i = STOP_DMA_TIMEOUT/STOP_DMA_ITER; i != 0; i--) { if (ar5212NumTxPending(ah, q...
functions
AH_DEBUG if (i == 0) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: queue %u DMA did not stop in 400 msec\n", __func__, q); HALDEBUG(ah, HAL_DEBUG_ANY, "%s: QSTS 0x%x Q_TXE 0x%x Q_TXD 0x%x Q_CBR 0x%x\n", __func__, OS_REG_READ(ah, AR_QSTS(q)), OS_REG_READ(ah, AR_Q_TXE), OS_REG_READ(ah, AR_Q_TXD), OS_REG...
functions
HAL_BOOL ar5416SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int txPower, u_int txRate0, u_int txTries0, u_int keyIx, u_int antMode, u_int flags, u_int rtsctsRate, u_int rtsctsDuration, u_int compicvLen, u_int compivLen, u_int comp) { struct ar5416_...
functions
HAL_BOOL ar5416SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int txRate1, u_int txTries1, u_int txRate2, u_int txTries2, u_int txRate3, u_int txTries3) { struct ar5416_desc *ads = AR5416DESC(ds); if (txTries1) { HALASSERT(isValidTxRate(txRate1)); ads->ds_ctl2 |= SM(txTries1, AR_XmitDataTries1); ad...
functions
HAL_BOOL ar5416FillTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg, const struct ath_desc *ds0) { struct ar5416_desc *ads = AR5416DESC(ds); HALASSERT((segLen &~ AR_BufLen) == 0); if (firstSeg) { /* * First descriptor, don't clobber xmit control data * set...
functions
else if (lastSeg) { /* !firstSeg && lastSeg */ /* * Last descriptor in a multi-descriptor frame, * copy the multi-rate transmit parameters from * the first frame for processing on completion. */ ads->ds_ctl0 = 0; ads->ds_ctl1 = segLen; #ifdef AH_NEED_DESC_SWAP ads->ds_ctl2 = __bswap32(AR5416DESC_C...
functions
HAL_BOOL ar5416ChainTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int pktLen, u_int hdrLen, HAL_PKT_TYPE type, u_int keyIx, HAL_CIPHER cipher, uint8_t delims, u_int segLen, HAL_BOOL firstSeg, HAL_BOOL lastSeg) { struct ar5416_desc *ads = AR5416DESC(ds); uint32_t *ds_txstatus = AR5416_DS_TXSTATUS(ah,ads);...
functions
else if (lastSeg) { /* !firstSeg && lastSeg */ ads->ds_ctl0 = 0; ads->ds_ctl1 |= segLen; }
functions
HAL_BOOL ar5416SetupFirstTxDesc(struct ath_hal *ah, struct ath_desc *ds, u_int aggrLen, u_int flags, u_int txPower, u_int txRate0, u_int txTries0, u_int antMode, u_int rtsctsRate, u_int rtsctsDuration) { struct ar5416_desc *ads = AR5416DESC(ds); struct ath_hal_5212 *ahp = AH5212(ah); HALASSERT(txTries0 != 0); ...
functions
HAL_BOOL ar5416SetupLastTxDesc(struct ath_hal *ah, struct ath_desc *ds, const struct ath_desc *ds0) { struct ar5416_desc *ads = AR5416DESC(ds); ads->ds_ctl1 &= ~AR_MoreAggr; ads->ds_ctl6 &= ~AR_PadDelim; /* hack to copy rate info to last desc for later processing */ #ifdef AH_NEED_DESC_SWAP ads->ds_ctl2 = __bs...
functions
void ar5416SwapTxDesc(struct ath_desc *ds) { ds->ds_data = __bswap32(ds->ds_data); ds->ds_ctl0 = __bswap32(ds->ds_ctl0); ds->ds_ctl1 = __bswap32(ds->ds_ctl1); ds->ds_hw[0] = __bswap32(ds->ds_hw[0]); ds->ds_hw[1] = __bswap32(ds->ds_hw[1]); ds->ds_hw[2] = __bswap32(ds->ds_hw[2]); ds->ds_hw[3] = __bswap32(ds->ds_hw...
functions
HAL_STATUS ar5416ProcTxDesc(struct ath_hal *ah, struct ath_desc *ds, struct ath_tx_status *ts) { struct ar5416_desc *ads = AR5416DESC(ds); uint32_t *ds_txstatus = AR5416_DS_TXSTATUS(ah,ads); #ifdef AH_NEED_DESC_SWAP if ((ds_txstatus[9] & __bswap32(AR_TxDone)) == 0) return HAL_EINPROGRESS; ar5416SwapTxDesc(ds); ...
functions
HAL_BOOL ar5416SetGlobalTxTimeout(struct ath_hal *ah, u_int tu) { struct ath_hal_5416 *ahp = AH5416(ah); if (tu > 0xFFFF) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad global tx timeout %u\n", __func__, tu); /* restore default handling */ ahp->ah_globaltxtimeout = (u_int) -1; return AH_FALSE; }
functions
u_int ar5416GetGlobalTxTimeout(struct ath_hal *ah) { return MS(OS_REG_READ(ah, AR_GTXTO), AR_GTXTO_TIMEOUT_LIMIT); }
functions
void ar5416Set11nRateScenario(struct ath_hal *ah, struct ath_desc *ds, u_int durUpdateEn, u_int rtsctsRate, HAL_11N_RATE_SERIES series[], u_int nseries) { struct ar5416_desc *ads = AR5416DESC(ds); HALASSERT(nseries == 4); (void)nseries; ads->ds_ctl2 = set11nTries(series, 0) | set11nTries(series, ...
functions
void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims) { struct ar5416_desc *ads = AR5416DESC(ds); uint32_t *ds_txstatus = AR5416_DS_TXSTATUS(ah,ads); ads->ds_ctl1 |= (AR_IsAggr | AR_MoreAggr); ads->ds_ctl6 &= ~AR_PadDelim; ads->ds_ctl6 |= SM(numDelims, AR_PadDelim); ads->ds_ctl6 ...
functions
void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds) { struct ar5416_desc *ads = AR5416DESC(ds); ads->ds_ctl1 &= (~AR_IsAggr & ~AR_MoreAggr); ads->ds_ctl6 &= ~AR_PadDelim; ads->ds_ctl6 &= ~AR_AggrLen; }
functions
void ar5416Set11nBurstDuration(struct ath_hal *ah, struct ath_desc *ds, u_int burstDuration) { struct ar5416_desc *ads = AR5416DESC(ds); ads->ds_ctl2 &= ~AR_BurstDur; ads->ds_ctl2 |= SM(burstDuration, AR_BurstDur); }
includes
#include <grp.h>
includes
#include <pwd.h>
includes
#include <errno.h>
includes
#include <stdbool.h>
includes
#include <signal.h>
includes
#include <stdlib.h>
includes
#include <string.h>
includes
#include <unistd.h>
includes
#include <sys/wait.h>
includes
#include <glib.h>
includes
#include <glib/gstdio.h>
defines
#define PINK_FLOYD " ..uu. \n" \
defines
#define HANDLE_SIGNAL(sig) \
functions
void cleanup(void) { dispatch_free(); syscall_free(); sydbox_config_rmfilter_all(); if (NULL != ctx) { if (NULL != ctx->children) g_hash_table_foreach(ctx->children, tchild_kill_one, NULL); context_free(ctx); ctx = NULL; }
functions
void sig_cleanup(int signum) { struct sigaction action; g_fprintf(stderr, "Caught signal %d, exiting\n", signum); cleanup(); sigaction(signum, NULL, &action); action.sa_handler = SIG_DFL; sigaction(signum, &action, NULL); raise(signum); }
functions
G_GNUC_NORETURN sydbox_execute_child(int argc G_GNUC_UNUSED, char **argv) { if (trace_me() < 0) { g_printerr("failed to set tracing: %s", g_strerror(errno)); _exit(-1); }
functions
int sydbox_execute_parent(int argc G_GNUC_UNUSED, char **argv G_GNUC_UNUSED, pid_t pid) { int status, retval; struct sigaction new_action, old_action; struct tchild *eldest; new_action.sa_handler = sig_cleanup; sigemptyset(&new_action.sa_mask); new_action.sa_flags = 0; do { ...
functions
int sydbox_internal_main(int argc, char **argv) { pid_t pid; dispatch_init(); syscall_init(); ctx = context_new(); g_atexit(cleanup); /* * options are loaded from config file, updated from the environment, and * then overridden by the user passed parameters. */ if (!sydbox_...
main
int main(int argc, char **argv) { GError *parse_error = NULL; GOptionContext *context; context = g_option_context_new("-- command [args]"); g_option_context_add_main_entries(context, entries, PACKAGE); g_option_context_set_summary(context, PACKAGE "-" VERSION GIT_HEAD " - ptrace based sandbox"); ...
includes
#include <linux/export.h>
includes
#include <asm/unaligned.h>
includes
#include <net/bluetooth/bluetooth.h>
includes
#include <net/bluetooth/hci_core.h>
includes
#include <net/bluetooth/hci_mon.h>
defines
#define hci_pi(sk) ((struct hci_pinfo *) sk)
defines
#define HCI_SFLT_MAX_OGF 5
structs
struct hci_pinfo { struct bt_sock bt; struct hci_dev *hdev; struct hci_filter filter; __u32 cmsg_mask; unsigned short channel; };
structs
struct hci_sec_filter { __u32 type_mask; __u32 event_mask[2]; __u32 ocf_mask[HCI_SFLT_MAX_OGF + 1][4]; };
functions
int hci_test_bit(int nr, void *addr) { return *((__u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31)); }
functions
bool is_filtered_packet(struct sock *sk, struct sk_buff *skb) { struct hci_filter *flt; int flt_type, flt_event; /* Apply filter */ flt = &hci_pi(sk)->filter; if (bt_cb(skb)->pkt_type == HCI_VENDOR_PKT) flt_type = 0; else flt_type = bt_cb(skb)->pkt_type & HCI_FLT_TYPE_BITS; if (!test_bit(flt_type, &flt->t...
functions
void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb) { struct sock *sk; struct sk_buff *skb_copy = NULL; BT_DBG("hdev %p len %d", hdev, skb->len); read_lock(&hci_sk_list.lock); sk_for_each(sk, &hci_sk_list.head) { struct sk_buff *nskb; if (sk->sk_state != BT_BOUND || hci_pi(sk)->hdev != hdev) ...
functions
void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, struct sock *skip_sk) { struct sock *sk; BT_DBG("channel %u len %d", channel, skb->len); read_lock(&hci_sk_list.lock); sk_for_each(sk, &hci_sk_list.head) { struct sk_buff *nskb; /* Skip the original socket */ if (sk == skip_sk) c...
functions
void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb) { struct sk_buff *skb_copy = NULL; struct hci_mon_hdr *hdr; __le16 opcode; if (!atomic_read(&monitor_promisc)) return; BT_DBG("hdev %p len %d", hdev, skb->len); switch (bt_cb(skb)->pkt_type) { case HCI_COMMAND_PKT: opcode = cpu_to_le16(HC...
functions
void send_monitor_replay(struct sock *sk) { struct hci_dev *hdev; read_lock(&hci_dev_list_lock); list_for_each_entry(hdev, &hci_dev_list, list) { struct sk_buff *skb; skb = create_monitor_event(hdev, HCI_DEV_REG); if (!skb) continue; if (sock_queue_rcv_skb(sk, skb)) kfree_skb(skb); }
functions
void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) { struct hci_event_hdr *hdr; struct hci_ev_stack_internal *ev; struct sk_buff *skb; skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC); if (!skb) return; hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE); hdr->evt = H...
functions
void hci_sock_dev_event(struct hci_dev *hdev, int event) { struct hci_ev_si_device ev; BT_DBG("hdev %s event %d", hdev->name, event); /* Send event to monitor */ if (atomic_read(&monitor_promisc)) { struct sk_buff *skb; skb = create_monitor_event(hdev, event); if (skb) { hci_send_to_channel(HCI_CHANNEL_...
functions
int hci_sock_release(struct socket *sock) { struct sock *sk = sock->sk; struct hci_dev *hdev; BT_DBG("sock %p sk %p", sock, sk); if (!sk) return 0; hdev = hci_pi(sk)->hdev; if (hci_pi(sk)->channel == HCI_CHANNEL_MONITOR) atomic_dec(&monitor_promisc); bt_sock_unlink(&hci_sk_list, sk); if (hdev) { if ...
functions
int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg) { bdaddr_t bdaddr; int err; if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) return -EFAULT; hci_dev_lock(hdev); err = hci_bdaddr_list_add(&hdev->blacklist, &bdaddr, BDADDR_BREDR); hci_dev_unlock(hdev); return err; }
functions
int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg) { bdaddr_t bdaddr; int err; if (copy_from_user(&bdaddr, arg, sizeof(bdaddr))) return -EFAULT; hci_dev_lock(hdev); err = hci_bdaddr_list_del(&hdev->blacklist, &bdaddr, BDADDR_BREDR); hci_dev_unlock(hdev); return err; }
functions
int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg) { struct hci_dev *hdev = hci_pi(sk)->hdev; if (!hdev) return -EBADFD; if (test_bit(HCI_USER_CHANNEL, &hdev->dev_flags)) return -EBUSY; if (test_bit(HCI_UNCONFIGURED, &hdev->dev_flags)) return -EOPNOTSUPP; if (hdev->dev_typ...
functions
int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *) arg; struct sock *sk = sock->sk; int err; BT_DBG("cmd %x arg %lx", cmd, arg); lock_sock(sk); if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) { err = -EBADFD; goto done; }
functions
int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) { struct sockaddr_hci haddr; struct sock *sk = sock->sk; struct hci_dev *hdev = NULL; int len, err = 0; BT_DBG("sock %p sk %p", sock, sk); if (!addr) return -EINVAL; memset(&haddr, 0, sizeof(haddr)); len = min_t(unsigned int, s...
functions
int hci_sock_getname(struct socket *sock, struct sockaddr *addr, int *addr_len, int peer) { struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr; struct sock *sk = sock->sk; struct hci_dev *hdev; int err = 0; BT_DBG("sock %p sk %p", sock, sk); if (peer) return -EOPNOTSUPP; lock_sock(sk); hdev ...
functions
void hci_sock_cmsg(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) { __u32 mask = hci_pi(sk)->cmsg_mask; if (mask & HCI_CMSG_DIR) { int incoming = bt_cb(skb)->incoming; put_cmsg(msg, SOL_HCI, HCI_CMSG_DIR, sizeof(incoming), &incoming); }
functions
int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { int noblock = flags & MSG_DONTWAIT; struct sock *sk = sock->sk; struct sk_buff *skb; int copied, err; BT_DBG("sock %p, sk %p", sock, sk); if (flags & (MSG_OOB)) return -EOPNOTSUPP; if (sk->sk_st...
functions
int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { struct sock *sk = sock->sk; struct hci_dev *hdev; struct sk_buff *skb; int err; BT_DBG("sock %p sk %p", sock, sk); if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_...
functions
int hci_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int len) { struct hci_ufilter uf = { .opcode = 0 }
functions
int hci_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) { struct hci_ufilter uf; struct sock *sk = sock->sk; int len, opt, err = 0; BT_DBG("sk %p, opt %d", sk, optname); if (get_user(len, optlen)) return -EFAULT; lock_sock(sk); if (hci_pi(sk)-...
functions
int hci_sock_create(struct net *net, struct socket *sock, int protocol, int kern) { struct sock *sk; BT_DBG("sock %p", sock); if (sock->type != SOCK_RAW) return -ESOCKTNOSUPPORT; sock->ops = &hci_sock_ops; sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto); if (!sk) return -ENOMEM; sock_i...