static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc, char *argv[]) { char buf[256]; char pin[32], *pin_ptr; int pin_len, i; if (argc < 2) { printf("Invalid 'wps_pin' command - at least two arguments, " "UUID and PIN, are required.\n"); return -1; } memset(pin, 0, sizeof(pin)); pin_ptr = pin; for(i=1; i<argc; i++) { snprintf(pin_ptr, sizeof(pin), "%s", argv[i]); pin_ptr += strlen(argv[i]); } pin_len = process_wps_pin_input(pin); if((pin_len == 8) && (!is_valid_pin(pin))) { printf("Invalid PIN\n"); return -1; } snprintf(buf, sizeof(buf), "WPS_PIN %s %s", argv[0], pin); return wpa_ctrl_command(ctrl, buf); }
/* Parse the WPS pin to use into p1 and p2 */ void parse_static_pin(char *pin) { int len = 0; char p1[5] = { 0 }; char p2[4] = { 0 }; if(pin) { len = strlen(pin); if((len == 4 || len == 7 || len == 8) && is_valid_pin(pin) != 0) { memcpy((void *) &p1, pin, sizeof(p1)-1); set_static_p1((char *) &p1); set_key_status(KEY2_WIP); if(len > 4) { memcpy((void *) &p2, pin+sizeof(p1)-1, sizeof(p2)-1); set_static_p2((char *) &p2); } } else { //cprintf(CRITICAL, "[X] ERROR: Invalid pin specified! Ignoring '%s'.\n", pin); set_max_pin_attempts(1); set_pin_string_mode(1); set_static_p1(pin); } } }
void fastio_digitalWrite(int pin, int value) { if (! is_valid_pin(pin)) return; digitalWrite(pin_base + pin, value); }
int fastio_digitalRead(int pin) { if (! is_valid_pin(pin)) return -1; return digitalRead(pin_base + pin); }
PinFunction HAL_Validate_Pin_Function(pin_t pin, PinFunction pinFunction) { if (!is_valid_pin(pin)) return PF_NONE; if (pinFunction==PF_ADC && PIN_MAP[pin].adc_channel!=ADC_CHANNEL_NONE) return PF_ADC; if (pinFunction==PF_TIMER && PIN_MAP[pin].timer_peripheral!=NULL) return PF_TIMER; return PF_DIO; }
static gboolean cb_ss_control(int type, const char *sc, const char *sia, const char *sib, const char *sic, const char *dn, DBusMessage *msg, void *data) { struct ofono_call_barring *cb = data; DBusConnection *conn = ofono_dbus_get_connection(); int cls = BEARER_CLASS_DEFAULT; const char *fac; DBusMessage *reply; void *operation = NULL; int i; if (cb->pending) { reply = __ofono_error_busy(msg); g_dbus_send_message(conn, reply); return TRUE; } DBG("Received call barring ss control request"); DBG("type: %d, sc: %s, sia: %s, sib: %s, sic: %s, dn: %s", type, sc, sia, sib, sic, dn); fac = cb_ss_service_to_fac(sc); if (!fac) return FALSE; cb_set_query_bounds(cb, fac, type == SS_CONTROL_TYPE_QUERY); i = 0; while (cb_locks[i].name && strcmp(cb_locks[i].fac, fac)) i++; cb->ss_req_lock = i; if (strlen(sic) > 0) goto bad_format; if (strlen(dn) > 0) goto bad_format; if (type != SS_CONTROL_TYPE_QUERY && !is_valid_pin(sia, PIN_TYPE_NET)) goto bad_format; switch (type) { case SS_CONTROL_TYPE_ACTIVATION: case SS_CONTROL_TYPE_DEACTIVATION: case SS_CONTROL_TYPE_REGISTRATION: case SS_CONTROL_TYPE_ERASURE: operation = cb->driver->set; break; case SS_CONTROL_TYPE_QUERY: operation = cb->driver->query; break; default: break; } if (!operation) { reply = __ofono_error_not_implemented(msg); g_dbus_send_message(conn, reply); return TRUE; } /* According to 27.007, AG, AC and AB only work with mode = 0 * We support query by querying all relevant types, since we must * do this for the deactivation case anyway */ if ((!strcmp(fac, "AG") || !strcmp(fac, "AC") || !strcmp(fac, "AB")) && (type == SS_CONTROL_TYPE_ACTIVATION || type == SS_CONTROL_TYPE_REGISTRATION)) goto bad_format; if (strlen(sib) > 0) { long service_code; char *end; service_code = strtoul(sib, &end, 10); if (end == sib || *end != '\0') goto bad_format; cls = mmi_service_code_to_bearer_class(service_code); if (cls == 0) goto bad_format; } cb->ss_req_cls = cls; cb->pending = dbus_message_ref(msg); switch (type) { case SS_CONTROL_TYPE_ACTIVATION: case SS_CONTROL_TYPE_REGISTRATION: cb->ss_req_type = SS_CONTROL_TYPE_ACTIVATION; cb->driver->set(cb, fac, 1, sia, cls, cb_ss_set_lock_callback, cb); break; case SS_CONTROL_TYPE_ERASURE: case SS_CONTROL_TYPE_DEACTIVATION: cb->ss_req_type = SS_CONTROL_TYPE_DEACTIVATION; cb->driver->set(cb, fac, 0, sia, cls, cb_ss_set_lock_callback, cb); break; case SS_CONTROL_TYPE_QUERY: cb->ss_req_type = SS_CONTROL_TYPE_QUERY; cb_ss_query_next_lock(cb); break; } return TRUE; bad_format: reply = __ofono_error_invalid_format(msg); g_dbus_send_message(conn, reply); return TRUE; }
PinMode HAL_Get_Pin_Mode(pin_t pin) { return (!is_valid_pin(pin)) ? PIN_MODE_NONE : PIN_MAP[pin].pin_mode; }