diff options
author | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-04-15 09:47:23 +0000 |
---|---|---|
committer | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-04-15 09:47:23 +0000 |
commit | f243da86ed3c515740870ce0a817f2e768b420fe (patch) | |
tree | b39801affc667465169392855e942e94fb94f4a3 /include | |
parent | 6766b42717e386d505ba5f3f7b4732e88eece54e (diff) |
* add (still incomplete) SMS and phonebook support from Sean Chiang
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@1765 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'include')
-rw-r--r-- | include/gsmd/usock.h | 164 | ||||
-rw-r--r-- | include/libgsmd/libgsmd.h | 1 | ||||
-rw-r--r-- | include/libgsmd/misc.h | 4 | ||||
-rw-r--r-- | include/libgsmd/phonebook.h | 52 | ||||
-rw-r--r-- | include/libgsmd/sms.h | 114 |
5 files changed, 332 insertions, 3 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h index cb5e0b9..2032230 100644 --- a/include/gsmd/usock.h +++ b/include/gsmd/usock.h @@ -21,6 +21,7 @@ enum gsmd_msg_type { GSMD_MSG_NETWORK = 6, GSMD_MSG_PHONE = 7, GSMD_MSG_PIN = 8, + GSMD_MSG_SMS = 9, __NUM_GSMD_MSGS }; @@ -63,6 +64,102 @@ enum gsmd_msg_network { GSMD_NETWORK_CIND_GET = 6, }; +enum gsmd_msg_sms { + GSMD_SMS_LIST = 1, + GSMD_SMS_READ = 2, + GSMD_SMS_SEND = 3, + GSMD_SMS_WRITE = 4, + GSMD_SMS_DELETE = 5, +}; + +/* SMS stat from 3GPP TS 07.05, Clause 3.1 */ +enum gsmd_msg_sms_type { + GSMD_SMS_REC_UNREAD = 0, + GSMD_SMS_REC_READ = 1, + GSMD_SMS_STO_UNSENT = 2, + GSMD_SMS_STO_SENT = 3, + GSMD_SMS_ALL = 4, +}; + +/* SMS format from 3GPP TS 07.05, Clause 3.2.3 */ +enum gsmd_msg_sms_fmt { + GSMD_SMS_FMT_PDU = 0, + GSMD_SMS_FMT_TEXT = 1, +}; + +/* Refer to GSM 03.40 subclause 9.2.3.1 */ +enum gsmd_sms_tp_mti { + GSMD_SMS_TP_MTI_DELIVER = 0, + GSMD_SMS_TP_MTI_DELIVER_REPORT = 0, + GSMD_SMS_TP_MTI_STATUS_REPORT = 2, + GSMD_SMS_TP_MTI_COMMAND = 2, + GSMD_SMS_TP_MTI_SUBMIT = 1, + GSMD_SMS_TP_MTI_SUBMIT_REPORT = 1, + GSMD_SMS_TP_MTI_RESERVED = 3, +}; + +/* Refer to GSM 03.40 subclause 9.2.3.2, */ +/* for SMS-DELIVER, SMS-STATUS-REPORT */ +enum gsmd_sms_tp_mms { + GSMD_SMS_TP_MMS_MORE = (0<<2), + GSMD_SMS_TP_MMS_NO_MORE = (1<<2), +}; + +/* Refer to GSM 03.40 subclause 9.2.3.3, */ +/* for SMS-SUBMIT */ +enum gsmd_sms_tp_vpf { + GSMD_SMS_TP_VPF_NOT_PRESENT = (0<<3), + GSMD_SMS_TP_VPF_RESERVED = (1<<3), + GSMD_SMS_TP_VPF_RELATIVE = (2<<3), + GSMD_SMS_TP_VPF_ABSOLUTE = (3<<3), +}; + +/* Refer to GSM 03.40 subclause 9.2.3.4, */ +/* for SMS-DELIVER */ +enum gsmd_sms_tp_sri { + GSMD_SMS_TP_SRI_NOT_RETURN = (0<<5), + GSMD_SMS_TP_SRI_STATUS_RETURN = (1<<5), +}; + +/* Refer to GSM 03.40 subclause 9.2.3.5, */ +/* for SMS-SUBMIT, SMS-COMMAND */ +enum gsmd_sms_tp_srr { + GSMD_SMS_TP_SRR_NOT_REQUEST = (0<<5), + GSMD_SMS_TP_SRR_STATUS_REQUEST = (1<<5), +}; + +/* Refer to GSM 03.40 subclause 9.2.3.17, */ +/* for SMS-SUBMIT, SMS-DELIVER */ +enum gsmd_sms_tp_rp { + GSMD_SMS_TP_RP_NOT_SET = (0<<7), + GSMD_SMS_TP_RP_SET = (1<<7), +}; + +/* Refer to GSM 03.40 subclause 9.2.3.23 */ +/* for SMS-SUBMIT, SMS-DELIVER */ +enum gsmd_sms_tp_udhi { + GSMD_SMS_TP_UDHI_NO_HEADER = (0<<6), + GSMD_SMS_TP_UDHI_WTIH_HEADER = (1<<6), +}; + +/* SMS delflg from 3GPP TS 07.05, Clause 3.5.4 */ +enum gsmd_msg_sms_delflg { + GSMD_SMS_DELFLG_INDEX = 0, + GSMD_SMS_DELFLG_READ = 1, + GSMD_SMS_DELFLG_READ_SENT = 2, + GSMD_SMS_DELFLG_LEAVING_UNREAD = 3, + GSMD_SMS_DELFLG_ALL = 4, +}; + +enum gsmd_msg_phonebook { + GSMD_PHONEBOOK_FIND = 1, + GSMD_PHONEBOOK_READ = 2, + GSMD_PHONEBOOK_READRG = 3, + GSMD_PHONEBOOK_WRITE = 4, + GSMD_PHONEBOOK_DELETE = 5, + GSMD_PHONEBOOK_GET_SUPPORT = 6, +}; + /* Length from 3GPP TS 04.08, Clause 10.5.4.7 */ #define GSMD_ADDR_MAXLEN 32 @@ -137,6 +234,72 @@ struct gsmd_evt_auxdata { } u; } __attribute__((packed)); +/* Refer to GSM 07.05 subclause 3.5.4 */ +struct gsmd_sms_delete { + u_int8_t index; + u_int8_t delflg; +} __attribute__ ((packed)); + +/* Refer to GSM 03.40 subclause 9.2.2.2 and GSM 07.05 subclause 4.3 */ +#define GSMD_SMS_DATA_MAXLEN 164 +struct gsmd_sms { + u_int8_t length; + char data[GSMD_SMS_DATA_MAXLEN+1]; +} __attribute__ ((packed)); + +/* Refer to GSM 07.05 subclause 4.4 */ +struct gsmd_sms_write { + u_int8_t stat; + struct gsmd_sms sms; +} __attribute__ ((packed)); + +/* Refer to GSM 03.40 subclause 9.2.2.2 */ +struct gsmd_sms_submit { + u_int8_t length; + char data[GSMD_SMS_DATA_MAXLEN+1]; +} __attribute__ ((packed)); + +/* Refer to GSM 03.40 subclause 9.2.2.1 */ +struct gsmd_sms_deliver { + u_int8_t length; + char origl_addr[12]; + u_int8_t proto_ident; + u_int8_t coding_scheme; + char time_stamp[7]; + char user_data[140]; +} __attribute__ ((packed)); + +/* Refer to GSM 07.07 subclause 8.12 */ +struct gsmd_phonebook_readrg { + u_int8_t index1; + u_int8_t index2; +} __attribute__ ((packed)); + +/* Refer to GSM 07.07 subclause 8.14 */ +/* FIXME: the nlength and tlength depend on SIM, use +CPBR=? to get */ +#define GSMD_PB_NUMB_MAXLEN 44 +#define GSMD_PB_TEXT_MAXLEN 14 +struct gsmd_phonebook { + u_int8_t index; + char numb[GSMD_PB_NUMB_MAXLEN+1]; + u_int8_t type; + char text[GSMD_PB_TEXT_MAXLEN+1]; +} __attribute__ ((packed)); + + +/* Refer to GSM 07.07 subclause 8.13 */ +/* FIXME: the tlength depends on SIM, use +CPBR=? to get */ +struct gsmd_phonebook_find { + char findtext[GSMD_PB_TEXT_MAXLEN+1]; +} __attribute__ ((packed)); + +/* Refer to GSM 07.07 subclause 8.12 */ +struct gsmd_phonebook_support { + u_int8_t index; + u_int8_t nlength; + u_int8_t tlength; +} __attribute__ ((packed)); + struct gsmd_msg_hdr { u_int8_t version; u_int8_t msg_type; @@ -147,7 +310,6 @@ struct gsmd_msg_hdr { u_int8_t data[]; } __attribute__((packed)); - #ifdef __GSMD__ #include <common/linux_list.h> diff --git a/include/libgsmd/libgsmd.h b/include/libgsmd/libgsmd.h index 8c34c6a..fc56890 100644 --- a/include/libgsmd/libgsmd.h +++ b/include/libgsmd/libgsmd.h @@ -65,5 +65,6 @@ extern int lgsm_subscriptions(struct lgsm_handle *lh, u_int32_t subscriptions); extern struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int payload_len); extern int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh); +extern int lgsm_handle_packet(struct lgsm_handle *lh, char *buf, int len); #endif diff --git a/include/libgsmd/misc.h b/include/libgsmd/misc.h index 95e219d..cbc2df0 100644 --- a/include/libgsmd/misc.h +++ b/include/libgsmd/misc.h @@ -1,5 +1,5 @@ -#ifndef _LIBGSMD_H -#define _LIBGSMD_H +#ifndef _LIBGSMD_MISC_H +#define _LIBGSMD_MISC_H /* libgsmd.h - Library API for gsmd, the GSM Daemon * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de> diff --git a/include/libgsmd/phonebook.h b/include/libgsmd/phonebook.h index 92c3a7f..a08d891 100644 --- a/include/libgsmd/phonebook.h +++ b/include/libgsmd/phonebook.h @@ -20,6 +20,36 @@ enum lgsm_pbook_type { LGSM_PB_TA_PHONEBOOK = 11, }; +/* Refer to GSM 07.07 subclause 8.14 */ +enum lgsm_pb_addr_type { + LGSM_PB_ATYPE_INTL = 145, + LGSM_PB_ATYPE_OTHE = 129, +}; + +/* Refer to GSM 07.07 subclause 8.12 */ +struct lgsm_phonebook_readrg { + int index1; + int index2; +}; + +/* Refer to GSM 07.07 subclause 8.14 */ +/* FIXME: the nlength and tlength depend on SIM, use +CPBR=? to get */ +#define LGSM_PB_NUMB_MAXLEN 44 +#define LGSM_PB_TEXT_MAXLEN 14 +struct lgsm_phonebook { + int index; + char numb[LGSM_PB_NUMB_MAXLEN+1]; + enum lgsm_pb_addr_type type; + char text[LGSM_PB_TEXT_MAXLEN+1]; +}; + +/* Refer to GSM 07.07 subclause 8.13 */ +/* FIXME: the tlength depends on SIM, use +CPBR=? to get */ +struct lgsm_phonebook_find { + char findtext[LGSM_PB_TEXT_MAXLEN+1]; +}; + +#if 0 /* Get a bitmask of supported phonebook types */ extern int lgsm_pb_get_types(struct lgsm_handle *lh, u_int32 *typemask); @@ -30,6 +60,7 @@ extern int lgsm_pb_get_range(struct lgsm_handle *lh, u_int32_t *nlength, *u_int32_t tlength); #define LGSM_PB_TEXT_MAXLEN 31 +#endif struct lgsm_pb_entry { struct lgsm_pb_entry *next; @@ -47,5 +78,26 @@ extern int lgsm_pb_get_entry(struct lgsm_handle *lh, extern int lgsm_pb_set_entry(struct lgsm_handle *lh, struct lgsm_pb_entry *pb); +/* Find phonebook entires which alphanumeric filed start + * with string <findtext> */ +extern int lgsm_pb_find_entry(struct lgsm_handle *lh, + const struct lgsm_phonebook_find *pb_find); + +/* Read phonebook entry in location number index */ +extern int lgsm_pb_read_entry(struct lgsm_handle *lh, int index); + +/* Read phonebook entries in location number range */ +extern int lgsm_pb_read_entryies(struct lgsm_handle *lh, + const struct lgsm_phonebook_readrg *pb_readrg); + +/* Delete phonebook entry in location index */ +extern int lgsmd_pb_del_entry(struct lgsm_handle *lh, int index); + +/* Write phonebook entry in location */ +extern int lgsmd_pb_write_entry(struct lgsm_handle *lh, + const struct lgsm_phonebook *pb); + +/* Get the location range/nlength/tlength supported */ +extern int lgsm_pb_get_support(struct lgsm_handle *lh); #endif diff --git a/include/libgsmd/sms.h b/include/libgsmd/sms.h new file mode 100644 index 0000000..a07fc74 --- /dev/null +++ b/include/libgsmd/sms.h @@ -0,0 +1,114 @@ +#ifndef _LIBGSMD_SMS_H +#define _LIBGSMD_SMS_H + +#include <libgsmd/libgsmd.h> + +/* Short Message Service */ + +/* Data Coding Scheme, refer to GSM 03.38 Clause 4 */ +#define B5_COMPRESSED (1<<5) +#define B4_CLASSMEANING (1<<4) +enum { + MESSAGE_CLASS_CLASS0 = 0x00, + MESSAGE_CLASS_CLASS1 = 0x01, + MESSAGE_CLASS_CLASS2 = 0x10, + MESSAGE_CLASS_CLASS3 = 0x11, +}; + +enum { + ALPHABET_DEFAULT = (0x00<<2), + ALPHABET_8BIT = (0x01<<2), + ALPHABET_UCS2 = (0x10<<2), + ALPHABET_RESERVED = (0x11<<2), +}; + +/* Coding of Alpha fields in the SIM for UCS2, (3GPP TS 11.11 Annex B) */ +//enum { + +//}; + + +/* SMS delflg from 3GPP TS 07.05, Clause 3.5.4 */ +enum lgsm_msg_sms_delflg { + LGSM_SMS_DELFLG_INDEX = 0, + LGSM_SMS_DELFLG_READ = 1, + LGSM_SMS_DELFLG_READ_SENT = 2, + LGSM_SMS_DELFLG_LEAVING_UNREAD = 3, + LGSM_SMS_DELFLG_ALL = 4, +}; + +/* SMS stat from 3GPP TS 07.05, Clause 3.1 */ +/* FIXME: only support PDU mode */ +enum lgsm_msg_sms_stat { + LGSM_SMS_REC_UNREAD = 0, + LGSM_SMS_REC_READ = 1, + LGSM_SMS_STO_UNSENT = 2, + LGSM_SMS_STO_SENT = 3, + LGSM_SMS_ALL = 4, +}; + +/* Refer to GSM 07.05 subclause 3.5.4 */ +struct lgsm_sms_delete { + int index; + enum lgsm_msg_sms_delflg delflg; +}; + +/* Refer to GSM 03.40 subclause 9.2.2.2 */ +#define LGSM_SMS_ADDR_MAXLEN 12 +#define LGSM_SMS_DATA_MAXLEN 140 +struct lgsm_sms { + /* FIXME: max length of data, + * 7 bit coding - 160(140*8/7); ucs2 coding - 70(140/2) */ + char addr[LGSM_SMS_ADDR_MAXLEN+1]; + char data[LGSM_SMS_DATA_MAXLEN+1]; +}; + +/* GSM 03.40 subclause 9.2.2.2 and GSM 07.05 subclause 4.4 and subclause 3.1 */ +struct lgsm_sms_write { + enum lgsm_msg_sms_stat stat; + struct lgsm_sms sms; +}; + +/* List Messages */ +extern int lgsm_sms_list(struct lgsm_handle *lh, enum gsmd_msg_sms_type stat); + +/* Read Message */ +extern int lgsm_sms_read(struct lgsm_handle *lh, int index); + +/* Delete Message */ +extern int lgsmd_sms_delete(struct lgsm_handle *lh, + const struct lgsm_sms_delete *sms_del); + +/* Send Message */ +extern int lgsmd_sms_send(struct lgsm_handle *lh, const struct lgsm_sms *sms); + +/* Write Message to Memory */ +extern int lgsmd_sms_write(struct lgsm_handle *lh, + const struct lgsm_sms_write *sms_write); + +/* Packing of 7-bit characters, refer to GSM 03.38 subclause 6.1.2.1.1 */ +extern int packing_7bit_character(char *src, char *dest); + +/* Packing of 7-bit characters, refer to GSM 03.38 subclause 6.1.2.1.1 */ +extern int unpacking_7bit_character(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int packing_UCS2_80(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int unpacking_UCS2_80(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int packing_UCS2_81(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int unpacking_UCS2_81(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int packing_UCS2_82(char *src, char *dest); + +/* Refer to 3GPP TS 11.11 Annex B */ +extern int unpacking_UCS2_82(char *src, char *dest); + +#endif + |